+++ /dev/null
-/** @file\r
-\r
- The internal header file includes the common header files, defines\r
- internal structure and functions used by EmuVariable module.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _VARIABLE_H_\r
-#define _VARIABLE_H_\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/VariableWrite.h>\r
-#include <Protocol/Variable.h>\r
-\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiRuntimeLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Guid/VariableFormat.h>\r
-#include <Guid/GlobalVariable.h>\r
-\r
-#include <Guid/EventGroup.h>\r
-\r
-#define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))\r
-\r
-///\r
-/// The size of a 3 character ISO639 language code.\r
-///\r
-#define ISO_639_2_ENTRY_SIZE 3\r
-\r
-typedef enum {\r
- Physical,\r
- Virtual\r
-} VARIABLE_POINTER_TYPE;\r
-\r
-typedef struct {\r
- VARIABLE_HEADER *CurrPtr;\r
- VARIABLE_HEADER *EndPtr;\r
- VARIABLE_HEADER *StartPtr;\r
- BOOLEAN Volatile;\r
-} VARIABLE_POINTER_TRACK;\r
-\r
-typedef struct {\r
- EFI_PHYSICAL_ADDRESS VolatileVariableBase;\r
- EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;\r
- EFI_LOCK VariableServicesLock;\r
-} VARIABLE_GLOBAL;\r
-\r
-typedef struct {\r
- VARIABLE_GLOBAL VariableGlobal[2];\r
- UINTN VolatileLastVariableOffset;\r
- UINTN NonVolatileLastVariableOffset;\r
- UINTN CommonVariableTotalSize;\r
- UINTN HwErrVariableTotalSize;\r
- CHAR8 *PlatformLangCodes;\r
- CHAR8 *LangCodes;\r
- CHAR8 *PlatformLang;\r
- CHAR8 Lang[ISO_639_2_ENTRY_SIZE + 1];\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
- 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_HANDLE ImageHandle,\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_HANDLE ImageHandle,\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 EFI_EVENT Event,\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
-\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
-EmuGetVariable (\r
- IN CHAR16 *VariableName,\r
- IN EFI_GUID *VendorGuid,\r
- OUT UINT32 *Attributes OPTIONAL,\r
- IN OUT UINTN *DataSize,\r
- OUT VOID *Data,\r
- IN VARIABLE_GLOBAL *Global\r
- );\r
-\r
-/**\r
-\r
- This code finds the next available variable.\r
-\r
- @param VariableNameSize The size of the VariableName buffer. The size must be large enough to fit input\r
- string supplied in VariableName buffer.\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
-\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 The 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
- @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and\r
- GUID of an existing variable.\r
- @retval EFI_INVALID_PARAMETER Null-terminator is not found in the first VariableNameSize bytes of\r
- the input VariableName buffer.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGetNextVariableName (\r
- IN OUT UINTN *VariableNameSize,\r
- IN OUT CHAR16 *VariableName,\r
- IN OUT EFI_GUID *VendorGuid,\r
- IN VARIABLE_GLOBAL *Global\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
-\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
-EmuSetVariable (\r
- IN CHAR16 *VariableName,\r
- IN EFI_GUID *VendorGuid,\r
- IN UINT32 Attributes,\r
- IN UINTN DataSize,\r
- IN VOID *Data,\r
- IN VARIABLE_GLOBAL *Global,\r
- IN UINTN *VolatileOffset,\r
- IN UINTN *NonVolatileOffset\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
-\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
-EmuQueryVariableInfo (\r
- IN UINT32 Attributes,\r
- OUT UINT64 *MaximumVariableStorageSize,\r
- OUT UINT64 *RemainingVariableStorageSize,\r
- OUT UINT64 *MaximumVariableSize,\r
- IN VARIABLE_GLOBAL *Global\r
- );\r
-\r
-#endif\r