summaryrefslogtreecommitdiffstats
path: root/EdkModulePkg/Universal/EmuVariable
diff options
context:
space:
mode:
authordavidhuang <davidhuang@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-06 06:42:48 +0000
committerdavidhuang <davidhuang@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-06 06:42:48 +0000
commit045f4521f2dffa1f788ea12f2952782f3db627de (patch)
treeaeefaa4f3520bbdb8ac68c44b892782df7e87b07 /EdkModulePkg/Universal/EmuVariable
parent1de04b4f83050f9a8f6c3eedce27f841591972f3 (diff)
downloadedk2-045f4521f2dffa1f788ea12f2952782f3db627de.tar.gz
edk2-045f4521f2dffa1f788ea12f2952782f3db627de.tar.bz2
edk2-045f4521f2dffa1f788ea12f2952782f3db627de.zip
1)Add a new module CapsuleRuntime under EdkModulePkg\Universal\Capsule\RuntimeDxe.And add the module into Nt32.fpd
2)Modify the related files to fit for the runtime services UpdateCapsule/QueryCapsuleCapabilities defined in UEFI2.0 spec 3)Modify the related files to fit for the runtime services QueryVariableInfo defined in UEFI2.0 spec git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@790 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Universal/EmuVariable')
-rw-r--r--EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c119
-rw-r--r--EdkModulePkg/Universal/EmuVariable/RuntimeDxe/InitVariable.c33
-rw-r--r--EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Ipf/InitVariable.c17
-rw-r--r--EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Variable.h14
4 files changed, 183 insertions, 0 deletions
diff --git a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c
index beb404f42c..6614bb03e9 100644
--- a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c
+++ b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c
@@ -656,6 +656,125 @@ Returns:
return EFI_SUCCESS;
}
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+EFI_STATUS
+EFIAPI
+QueryVariableInfo (
+ IN UINT32 Attributes,
+ OUT UINT64 *MaximumVariableStorageSize,
+ OUT UINT64 *RemainingVariableStorageSize,
+ OUT UINT64 *MaximumVariableSize,
+ IN VARIABLE_GLOBAL *Global,
+ IN UINT32 Instance
+ )
+/*++
+
+Routine Description:
+
+ This code returns information about the EFI variables.
+
+Arguments:
+
+ Attributes Attributes bitmask to specify the type of variables
+ on which to return information.
+ MaximumVariableStorageSize Pointer to the maximum size of the storage space available
+ for the EFI variables associated with the attributes specified.
+ RemainingVariableStorageSize Pointer to the remaining size of the storage space available
+ for the EFI variables associated with the attributes specified.
+ MaximumVariableSize Pointer to the maximum size of the individual EFI variables
+ associated with the attributes specified.
+ Global Pointer to VARIABLE_GLOBAL structure.
+ Instance Instance of the Firmware Volume.
+
+Returns:
+
+ EFI STATUS
+ EFI_INVALID_PARAMETER - An invalid combination of attribute bits was supplied.
+ EFI_SUCCESS - Query successfully.
+ EFI_UNSUPPORTED - The attribute is not supported on this platform.
+
+--*/
+{
+ VARIABLE_HEADER *Variable;
+ VARIABLE_HEADER *NextVariable;
+ UINT64 VariableSize;
+ VARIABLE_STORE_HEADER *VariableStoreHeader;
+
+ if(MaximumVariableStorageSize == NULL || RemainingVariableStorageSize == NULL || MaximumVariableSize == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if((Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)) == 0) {
+ //
+ // Make sure the Attributes combination is supported by the platform.
+ //
+ return EFI_UNSUPPORTED;
+ } else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {
+ //
+ // Make sure if runtime bit is set, boot service bit is set also.
+ //
+ return EFI_INVALID_PARAMETER;
+ } else if (EfiAtRuntime () && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {
+ //
+ // Make sure RT Attribute is set if we are in Runtime phase.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {
+ //
+ // Query is Volatile related.
+ //
+ VariableStoreHeader = (VARIABLE_STORE_HEADER *) ((UINTN) Global->VolatileVariableBase);
+ } else {
+ //
+ // Query is Non-Volatile related.
+ //
+ VariableStoreHeader = (VARIABLE_STORE_HEADER *) ((UINTN) Global->NonVolatileVariableBase);
+ }
+
+ //
+ // Now let's fill *MaximumVariableStorageSize *RemainingVariableStorageSize
+ // with the storage size (excluding the storage header size)
+ //
+ *MaximumVariableStorageSize = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER);
+ *RemainingVariableStorageSize = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER);
+
+ //
+ // Let *MaximumVariableSize be MAX_VARIABLE_SIZE
+ //
+ *MaximumVariableSize = MAX_VARIABLE_SIZE;
+
+ //
+ // Point to the starting address of the variables.
+ //
+ Variable = (VARIABLE_HEADER *) (VariableStoreHeader + 1);
+
+ //
+ // Now walk through the related variable store.
+ //
+ while (Variable < GetEndPointer (VariableStoreHeader)) {
+ if (Variable->StartId != VARIABLE_DATA) {
+ break;
+ }
+
+ NextVariable = (VARIABLE_HEADER *) (GetVariableDataPtr (Variable) + Variable->DataSize + GET_PAD_SIZE (Variable->DataSize));
+ VariableSize = (UINT64) (UINTN) NextVariable - (UINT64) (UINTN) Variable;
+
+ if (Variable->State == VAR_ADDED) {
+ *RemainingVariableStorageSize -= VariableSize;
+ }
+
+ //
+ // Go to the next one.
+ //
+ Variable = NextVariable;
+ }
+
+ return EFI_SUCCESS;
+}
+#endif
+
EFI_STATUS
EFIAPI
InitializeVariableStore (
diff --git a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/InitVariable.c b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/InitVariable.c
index 0ad86642ea..477869cf00 100644
--- a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/InitVariable.c
+++ b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/InitVariable.c
@@ -114,6 +114,36 @@ Returns:
);
}
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+EFI_STATUS
+EFIAPI
+RuntimeServiceQueryVariableInfo (
+ IN UINT32 Attributes,
+ OUT UINT64 *MaximumVariableStorageSize,
+ OUT UINT64 *RemainingVariableStorageSize,
+ OUT UINT64 *MaximumVariableSize
+ )
+/*++
+
+Routine Description:
+
+Arguments:
+
+Returns:
+
+--*/
+{
+ return QueryVariableInfo (
+ Attributes,
+ MaximumVariableStorageSize,
+ RemainingVariableStorageSize,
+ MaximumVariableSize,
+ &mVariableModuleGlobal->VariableBase[Physical],
+ mVariableModuleGlobal->FvbInstance
+ );
+}
+#endif
+
VOID
EFIAPI
VariableClassAddressChangeEvent (
@@ -166,6 +196,9 @@ Returns:
SystemTable->RuntimeServices->GetVariable = RuntimeServiceGetVariable;
SystemTable->RuntimeServices->GetNextVariableName = RuntimeServiceGetNextVariableName;
SystemTable->RuntimeServices->SetVariable = RuntimeServiceSetVariable;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ SystemTable->RuntimeServices->QueryVariableInfo = RuntimeServiceQueryVariableInfo;
+#endif
//
// Now install the Variable Runtime Architectural Protocol on a new handle
diff --git a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Ipf/InitVariable.c b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Ipf/InitVariable.c
index 061e6db73d..ee2a4852a0 100644
--- a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Ipf/InitVariable.c
+++ b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Ipf/InitVariable.c
@@ -89,6 +89,19 @@ Returns:
);
return ReturnVal;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ case EsalQueryVariableInfo:
+ ReturnVal.Status = QueryVariableInfo (
+ (UINT32) Arg2,
+ (UINT64 *) Arg3,
+ (UINT64 *) Arg4,
+ (UINT64 *) Arg5,
+ &Global->VariableBase[VirtualMode],
+ Global->FvbInstance
+ );
+ return ReturnVal;
+#endif
+
default:
ReturnVal.Status = EFI_SAL_INVALID_ARGUMENT;
return ReturnVal;
@@ -160,6 +173,10 @@ Returns:
EsalGetNextVariableName,
EsalVariableCommonEntry,
EsalSetVariable,
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ EsalVariableCommonEntry,
+ EsalQueryVariableInfo,
+#endif
NULL
);
diff --git a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Variable.h b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Variable.h
index d1fd5e271e..55423a25b9 100644
--- a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Variable.h
+++ b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Variable.h
@@ -140,4 +140,18 @@ SetVariable (
)
;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+EFI_STATUS
+EFIAPI
+QueryVariableInfo (
+ IN UINT32 Attributes,
+ OUT UINT64 *MaximumVariableStorageSize,
+ OUT UINT64 *RemainingVariableStorageSize,
+ OUT UINT64 *MaximumVariableSize,
+ IN VARIABLE_GLOBAL *Global,
+ IN UINT32 Instance
+ )
+;
+#endif
+
#endif