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 #include <Protocol/VariableWrite.h>
25 #include <Protocol/FaultTolerantWriteLite.h>
26 #include <Protocol/FirmwareVolumeBlock.h>
27 #include <Protocol/Variable.h>
28 #include <Library/PcdLib.h>
29 #include <Library/UefiDriverEntryPoint.h>
30 #include <Library/DxeServicesTableLib.h>
31 #include <Library/UefiRuntimeLib.h>
32 #include <Library/DebugLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/FvbServiceLib.h>
35 #include <Library/UefiBootServicesTableLib.h>
36 #include <Library/UefiLib.h>
37 #include <Library/BaseLib.h>
38 #include <Library/MemoryAllocationLib.h>
39 #include <Library/HobLib.h>
40 #include <Common/FlashMap.h>
41 #include <Guid/FlashMapHob.h>
44 // BugBug: We need relcate the head file.
46 #include <Common/Variable.h>
48 #define VARIABLE_RECLAIM_THRESHOLD (1024)
50 #define VARIABLE_STORE_SIZE (64 * 1024)
51 #define SCRATCH_SIZE (4 * 1024)
54 // Define GET_PAD_SIZE to optimize compiler
56 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
57 #define GET_PAD_SIZE(a) (0)
59 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
62 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
67 } VARIABLE_POINTER_TYPE
;
70 VARIABLE_HEADER
*CurrPtr
;
71 VARIABLE_HEADER
*EndPtr
;
72 VARIABLE_HEADER
*StartPtr
;
74 } VARIABLE_POINTER_TRACK
;
77 EFI_PHYSICAL_ADDRESS VolatileVariableBase
;
78 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase
;
79 EFI_LOCK VariableServicesLock
;
83 VARIABLE_GLOBAL VariableGlobal
[2];
84 UINTN VolatileLastVariableOffset
;
85 UINTN NonVolatileLastVariableOffset
;
87 } ESAL_VARIABLE_GLOBAL
;
89 extern ESAL_VARIABLE_GLOBAL
*mVariableModuleGlobal
;
96 VariableCommonInitialize (
97 IN EFI_HANDLE ImageHandle
,
98 IN EFI_SYSTEM_TABLE
*SystemTable
103 VariableServiceInitialize (
104 IN EFI_HANDLE ImageHandle
,
105 IN EFI_SYSTEM_TABLE
*SystemTable
110 VariableClassAddressChangeEvent (
118 IN CHAR16
*VariableName
,
119 IN EFI_GUID
* VendorGuid
,
120 OUT UINT32
*Attributes OPTIONAL
,
121 IN OUT UINTN
*DataSize
,
123 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
,
140 IN CHAR16
*VariableName
,
141 IN EFI_GUID
*VendorGuid
,
142 IN UINT32 Attributes
,
145 IN VARIABLE_GLOBAL
*Global
,
146 IN UINTN
*VolatileOffset
,
147 IN UINTN
*NonVolatileOffset
,
154 IN UINT32 Attributes
,
155 OUT UINT64
*MaximumVariableStorageSize
,
156 OUT UINT64
*RemainingVariableStorageSize
,
157 OUT UINT64
*MaximumVariableSize
,
158 IN VARIABLE_GLOBAL
*Global
,
163 GetFvbHandleByAddress (
164 IN EFI_PHYSICAL_ADDRESS VariableStoreBase
,
165 OUT EFI_HANDLE
*FvbHandle
170 IN EFI_PHYSICAL_ADDRESS VariableBaseAddress
,