\r
**/\r
\r
-#ifndef _VARIABLE_H\r
-#define _VARIABLE_H\r
-\r
-//\r
-// Statements that include other header files\r
-//\r
+#ifndef _VARIABLE_H_\r
+#define _VARIABLE_H_\r
\r
#include <Uefi.h>\r
\r
#include <Library/PcdLib.h>\r
#include <VariableFormat.h>\r
\r
-#define VARIABLE_STORE_SIZE FixedPcdGet32(PcdVariableStoreSize)\r
-#define SCRATCH_SIZE FixedPcdGet32(PcdMaxVariableSize)\r
-\r
-//\r
-// Define GET_PAD_SIZE to optimize compiler\r
-//\r
-#if ((ALIGNMENT == 0) || (ALIGNMENT == 1))\r
-#define GET_PAD_SIZE(a) (0)\r
-#else\r
-#define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))\r
-#endif\r
-\r
#define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))\r
\r
typedef enum {\r
UINT32 FvbInstance;\r
} ESAL_VARIABLE_GLOBAL;\r
\r
+///\r
+/// Don't use module globals after the SetVirtualAddress map is signaled\r
+///\r
extern ESAL_VARIABLE_GLOBAL *mVariableModuleGlobal;\r
\r
-//\r
-// Functions\r
-//\r
+/**\r
+ Initializes variable store area for non-volatile and volatile variable.\r
+\r
+ This function allocates and initializes memory space for global context of ESAL\r
+ variable service and variable store area for non-volatile and volatile variable.\r
+\r
+ @param ImageHandle The Image handle of this driver.\r
+ @param SystemTable The pointer of EFI_SYSTEM_TABLE.\r
+\r
+ @retval EFI_SUCCESS Function successfully executed.\r
+ @retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
VariableCommonInitialize (\r
IN EFI_SYSTEM_TABLE *SystemTable\r
);\r
\r
+/**\r
+ Entry point of EmuVariable service module.\r
+\r
+ This function is the entry point of EmuVariable service module.\r
+ It registers all interfaces of Variable Services, initializes\r
+ variable store for non-volatile and volatile variables, and registers\r
+ notification function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r
+\r
+ @param ImageHandle The Image handle of this driver.\r
+ @param SystemTable The pointer of EFI_SYSTEM_TABLE.\r
+\r
+ @retval EFI_SUCCESS Variable service successfully initialized.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
VariableServiceInitialize (\r
IN EFI_SYSTEM_TABLE *SystemTable\r
);\r
\r
+/**\r
+ Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r
+\r
+ This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r
+ It convers pointer to new virtual address.\r
+\r
+ @param Event Event whose notification function is being invoked.\r
+ @param Context Pointer to the notification function's context.\r
+\r
+**/\r
VOID\r
EFIAPI\r
VariableClassAddressChangeEvent (\r
IN VOID *Context\r
);\r
\r
+/**\r
+ This code finds variable in storage blocks (Volatile or Non-Volatile).\r
+ \r
+ @param VariableName A Null-terminated Unicode string that is the name of\r
+ the vendor's variable.\r
+ @param VendorGuid A unique identifier for the vendor.\r
+ @param Attributes If not NULL, a pointer to the memory location to return the \r
+ attributes bitmask for the variable.\r
+ @param DataSize Size of Data found. If size is less than the\r
+ data, this value contains the required size.\r
+ @param Data On input, the size in bytes of the return Data buffer. \r
+ On output, the size of data returned in Data.\r
+ @param Global Pointer to VARIABLE_GLOBAL structure\r
+ @param Instance Instance of the Firmware Volume.\r
+\r
+ @retval EFI_SUCCESS The function completed successfully. \r
+ @retval EFI_NOT_FOUND The variable was not found.\r
+ @retval EFI_BUFFER_TOO_SMALL DataSize is too small for the result. DataSize has \r
+ been updated with the size needed to complete the request.\r
+ @retval EFI_INVALID_PARAMETER VariableName or VendorGuid or DataSize is NULL.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
GetVariable (\r
IN UINT32 Instance\r
);\r
\r
+/**\r
+\r
+ This code finds the next available variable.\r
+\r
+ @param VariableNameSize Size of the variable.\r
+ @param VariableName On input, supplies the last VariableName that was returned by GetNextVariableName().\r
+ On output, returns the Null-terminated Unicode string of the current variable.\r
+ @param VendorGuid On input, supplies the last VendorGuid that was returned by GetNextVariableName().\r
+ On output, returns the VendorGuid of the current variable. \r
+ @param Global Pointer to VARIABLE_GLOBAL structure.\r
+ @param Instance Instance of the Firmware Volume.\r
+\r
+ @retval EFI_SUCCESS The function completed successfully. \r
+ @retval EFI_NOT_FOUND The next variable was not found.\r
+ @retval EFI_BUFFER_TOO_SMALL VariableNameSize is too small for the result. \r
+ VariableNameSize has been updated with the size needed to complete the request.\r
+ @retval EFI_INVALID_PARAMETER VariableNameSize or VariableName or VendorGuid is NULL.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
GetNextVariableName (\r
IN UINT32 Instance\r
);\r
\r
+/**\r
+\r
+ This code sets variable in storage blocks (Volatile or Non-Volatile).\r
+\r
+ @param VariableName A Null-terminated Unicode string that is the name of the vendor's\r
+ variable. Each VariableName is unique for each \r
+ VendorGuid. VariableName must contain 1 or more \r
+ Unicode characters. If VariableName is an empty Unicode \r
+ string, then EFI_INVALID_PARAMETER is returned.\r
+ @param VendorGuid A unique identifier for the vendor\r
+ @param Attributes Attributes bitmask to set for the variable\r
+ @param DataSize The size in bytes of the Data buffer. A size of zero causes the\r
+ variable to be deleted.\r
+ @param Data The contents for the variable\r
+ @param Global Pointer to VARIABLE_GLOBAL structure\r
+ @param VolatileOffset The offset of last volatile variable\r
+ @param NonVolatileOffset The offset of last non-volatile variable\r
+ @param Instance Instance of the Firmware Volume.\r
+\r
+ @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as \r
+ defined by the Attributes.\r
+ @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied, or the \r
+ DataSize exceeds the maximum allowed, or VariableName is an empty \r
+ Unicode string, or VendorGuid is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r
+ @retval EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure.\r
+ @retval EFI_WRITE_PROTECTED The variable in question is read-only or cannot be deleted.\r
+ @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
SetVariable (\r
IN UINT32 Instance\r
);\r
\r
+/**\r
+\r
+ This code returns information about the EFI variables.\r
+\r
+ @param Attributes Attributes bitmask to specify the type of variables\r
+ on which to return information.\r
+ @param MaximumVariableStorageSize On output the maximum size of the storage space available for \r
+ the EFI variables associated with the attributes specified. \r
+ @param RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI \r
+ variables associated with the attributes specified.\r
+ @param MaximumVariableSize Returns the maximum size of an individual EFI variable \r
+ associated with the attributes specified.\r
+ @param Global Pointer to VARIABLE_GLOBAL structure.\r
+ @param Instance Instance of the Firmware Volume.\r
+\r
+ @retval EFI_SUCCESS Valid answer returned.\r
+ @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied\r
+ @retval EFI_UNSUPPORTED The attribute is not supported on this platform, and the \r
+ MaximumVariableStorageSize, RemainingVariableStorageSize, \r
+ MaximumVariableSize are undefined.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
QueryVariableInfo (\r