3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 // Statements that include other header files
27 // The package level header files this module uses
31 // The protocols, PPI and GUID defintions for this module
33 #include <Protocol/VariableWrite.h>
34 #include <Protocol/Variable.h>
36 // The Library classes this module consumes
38 #include <Library/BaseMemoryLib.h>
39 #include <Library/MemoryAllocationLib.h>
40 #include <Library/DebugLib.h>
41 #include <Library/UefiRuntimeLib.h>
42 #include <Library/UefiDriverEntryPoint.h>
43 #include <Library/UefiBootServicesTableLib.h>
44 #include <Library/UefiLib.h>
45 #include <Library/BaseLib.h>
48 // BugBug: We need relcate the head file.
50 #include <Common/Variable.h>
52 #define VARIABLE_STORE_SIZE (64 * 1024)
53 #define SCRATCH_SIZE (4 * 1024)
56 // Define GET_PAD_SIZE to optimize compiler
58 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
59 #define GET_PAD_SIZE(a) (0)
61 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
64 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
69 } VARIABLE_POINTER_TYPE
;
72 VARIABLE_HEADER
*CurrPtr
;
73 VARIABLE_HEADER
*EndPtr
;
74 VARIABLE_HEADER
*StartPtr
;
76 } VARIABLE_POINTER_TRACK
;
79 EFI_PHYSICAL_ADDRESS VolatileVariableBase
;
80 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase
;
81 EFI_LOCK VariableServicesLock
;
85 VARIABLE_GLOBAL VariableGlobal
[2];
86 UINTN VolatileLastVariableOffset
;
87 UINTN NonVolatileLastVariableOffset
;
89 } ESAL_VARIABLE_GLOBAL
;
91 extern ESAL_VARIABLE_GLOBAL
*mVariableModuleGlobal
;
98 VariableCommonInitialize (
99 IN EFI_HANDLE ImageHandle
,
100 IN EFI_SYSTEM_TABLE
*SystemTable
106 VariableServiceInitialize (
107 IN EFI_HANDLE ImageHandle
,
108 IN EFI_SYSTEM_TABLE
*SystemTable
114 VariableClassAddressChangeEvent (
123 IN CHAR16
*VariableName
,
124 IN EFI_GUID
* VendorGuid
,
125 OUT UINT32
*Attributes OPTIONAL
,
126 IN OUT UINTN
*DataSize
,
128 IN VARIABLE_GLOBAL
* Global
,
135 GetNextVariableName (
136 IN OUT UINTN
*VariableNameSize
,
137 IN OUT CHAR16
*VariableName
,
138 IN OUT EFI_GUID
*VendorGuid
,
139 IN VARIABLE_GLOBAL
*Global
,
147 IN CHAR16
*VariableName
,
148 IN EFI_GUID
*VendorGuid
,
149 IN UINT32 Attributes
,
152 IN VARIABLE_GLOBAL
*Global
,
153 IN UINTN
*VolatileOffset
,
154 IN UINTN
*NonVolatileOffset
,
162 IN UINT32 Attributes
,
163 OUT UINT64
*MaximumVariableStorageSize
,
164 OUT UINT64
*RemainingVariableStorageSize
,
165 OUT UINT64
*MaximumVariableSize
,
166 IN VARIABLE_GLOBAL
*Global
,