-/*++\r
+/** @file\r
\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+ The internal header file includes the common header files, defines\r
+ internal structure and functions used by RuntimeVariable module.\r
+\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
All rights reserved. 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
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
-Module Name:\r
-\r
- Variable.h\r
-\r
-Abstract:\r
-\r
---*/\r
+**/\r
\r
-#ifndef _VARIABLE_H\r
-#define _VARIABLE_H\r
+#ifndef _VARIABLE_H_\r
+#define _VARIABLE_H_\r
\r
#include <PiDxe.h>\r
#include <Protocol/VariableWrite.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
#include <Library/UefiLib.h>\r
#include <Library/BaseLib.h>\r
+#include <Library/SynchronizationLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Guid/FlashMapHob.h>\r
-#include <Guid/FlashMapHob.h>\r
-#include <VariableFormat.h>\r
+#include <Guid/GlobalVariable.h>\r
+#include <Guid/EventGroup.h>\r
+#include <Guid/VariableFormat.h>\r
\r
#define VARIABLE_RECLAIM_THRESHOLD (1024)\r
\r
-#define VARIABLE_STORE_SIZE (64 * 1024)\r
-#define SCRATCH_SIZE (4 * 1024)\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
- Physical,\r
- Virtual\r
-} VARIABLE_POINTER_TYPE;\r
-\r
typedef struct {\r
VARIABLE_HEADER *CurrPtr;\r
VARIABLE_HEADER *EndPtr;\r
EFI_PHYSICAL_ADDRESS VolatileVariableBase;\r
EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;\r
EFI_LOCK VariableServicesLock;\r
+ UINT32 ReentrantState;\r
} VARIABLE_GLOBAL;\r
\r
typedef struct {\r
- VARIABLE_GLOBAL VariableGlobal[2];\r
+ VARIABLE_GLOBAL VariableGlobal;\r
UINTN VolatileLastVariableOffset;\r
UINTN NonVolatileLastVariableOffset;\r
UINT32 FvbInstance;\r
-} ESAL_VARIABLE_GLOBAL;\r
-\r
-extern ESAL_VARIABLE_GLOBAL *mVariableModuleGlobal;\r
-\r
-//\r
-// Functions\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-VariableCommonInitialize (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-VariableServiceInitialize (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- );\r
+} VARIABLE_MODULE_GLOBAL;\r
\r
-VOID\r
-EFIAPI\r
-VariableClassAddressChangeEvent (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- );\r
+typedef struct {\r
+ EFI_GUID *Guid;\r
+ CHAR16 *Name;\r
+ UINT32 Attributes;\r
+ UINTN DataSize;\r
+ VOID *Data;\r
+} VARIABLE_CACHE_ENTRY;\r
\r
-EFI_STATUS\r
-EFIAPI\r
-GetVariable (\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
- IN UINT32 Instance\r
- );\r
+/**\r
+ Writes a buffer to variable storage space, in the working block.\r
\r
-EFI_STATUS\r
-EFIAPI\r
-GetNextVariableName (\r
- IN OUT UINTN *VariableNameSize,\r
- IN OUT CHAR16 *VariableName,\r
- IN OUT EFI_GUID *VendorGuid,\r
- IN VARIABLE_GLOBAL *Global,\r
- IN UINT32 Instance\r
- );\r
+ This function writes a buffer to variable storage space into firmware\r
+ volume block device. The destination is specified by parameter\r
+ VariableBase. Fault Tolerant Write protocol is used for writing.\r
\r
-EFI_STATUS\r
-EFIAPI\r
-SetVariable (\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
- IN UINT32 Instance\r
- );\r
+ @param VariableBase Base address of variable to write\r
+ @param Buffer Point to the data buffer\r
+ @param BufferSize The number of bytes of the data Buffer\r
\r
-EFI_STATUS\r
-EFIAPI\r
-QueryVariableInfo (\r
- IN UINT32 Attributes,\r
- OUT UINT64 *MaximumVariableStorageSize,\r
- OUT UINT64 *RemainingVariableStorageSize,\r
- OUT UINT64 *MaximumVariableSize,\r
- IN VARIABLE_GLOBAL *Global,\r
- IN UINT32 Instance\r
- );\r
-\r
-EFI_STATUS\r
-GetFvbHandleByAddress (\r
- IN EFI_PHYSICAL_ADDRESS VariableStoreBase,\r
- OUT EFI_HANDLE *FvbHandle\r
- );\r
+ @retval EFI_SUCCESS The function completed successfully\r
+ @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol\r
+ @retval EFI_ABORTED The function could not complete successfully\r
\r
+**/\r
EFI_STATUS\r
FtwVariableSpace (\r
- IN EFI_PHYSICAL_ADDRESS VariableBaseAddress,\r
+ IN EFI_PHYSICAL_ADDRESS VariableBase,\r
IN UINT8 *Buffer,\r
IN UINTN BufferSize\r
);\r
\r
+\r
#endif\r