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
29 #include <Protocol/VariableWrite.h>
30 #include <Protocol/Variable.h>
32 #include <Library/BaseMemoryLib.h>
33 #include <Library/MemoryAllocationLib.h>
34 #include <Library/DebugLib.h>
35 #include <Library/UefiRuntimeLib.h>
36 #include <Library/UefiDriverEntryPoint.h>
37 #include <Library/UefiBootServicesTableLib.h>
38 #include <Library/UefiLib.h>
39 #include <Library/BaseLib.h>
42 // BugBug: We need relcate the head file.
44 #include <Common/Variable.h>
46 #define VARIABLE_STORE_SIZE (64 * 1024)
47 #define SCRATCH_SIZE (4 * 1024)
50 // Define GET_PAD_SIZE to optimize compiler
52 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
53 #define GET_PAD_SIZE(a) (0)
55 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
58 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
63 } VARIABLE_POINTER_TYPE
;
66 VARIABLE_HEADER
*CurrPtr
;
67 VARIABLE_HEADER
*EndPtr
;
68 VARIABLE_HEADER
*StartPtr
;
70 } VARIABLE_POINTER_TRACK
;
73 EFI_PHYSICAL_ADDRESS VolatileVariableBase
;
74 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase
;
75 EFI_LOCK VariableServicesLock
;
79 VARIABLE_GLOBAL VariableGlobal
[2];
80 UINTN VolatileLastVariableOffset
;
81 UINTN NonVolatileLastVariableOffset
;
83 } ESAL_VARIABLE_GLOBAL
;
85 extern ESAL_VARIABLE_GLOBAL
*mVariableModuleGlobal
;
92 VariableCommonInitialize (
93 IN EFI_HANDLE ImageHandle
,
94 IN EFI_SYSTEM_TABLE
*SystemTable
100 VariableServiceInitialize (
101 IN EFI_HANDLE ImageHandle
,
102 IN EFI_SYSTEM_TABLE
*SystemTable
108 VariableClassAddressChangeEvent (
117 IN CHAR16
*VariableName
,
118 IN EFI_GUID
* VendorGuid
,
119 OUT UINT32
*Attributes OPTIONAL
,
120 IN OUT UINTN
*DataSize
,
122 IN VARIABLE_GLOBAL
* Global
,
129 GetNextVariableName (
130 IN OUT UINTN
*VariableNameSize
,
131 IN OUT CHAR16
*VariableName
,
132 IN OUT EFI_GUID
*VendorGuid
,
133 IN VARIABLE_GLOBAL
*Global
,
141 IN CHAR16
*VariableName
,
142 IN EFI_GUID
*VendorGuid
,
143 IN UINT32 Attributes
,
146 IN VARIABLE_GLOBAL
*Global
,
147 IN UINTN
*VolatileOffset
,
148 IN UINTN
*NonVolatileOffset
,
156 IN UINT32 Attributes
,
157 OUT UINT64
*MaximumVariableStorageSize
,
158 OUT UINT64
*RemainingVariableStorageSize
,
159 OUT UINT64
*MaximumVariableSize
,
160 IN VARIABLE_GLOBAL
*Global
,