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 <Guid/FlashMapHob.h>
41 #include <Guid/FlashMapHob.h>
42 #include <VariableFormat.h>
44 #define VARIABLE_RECLAIM_THRESHOLD (1024)
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
99 VariableServiceInitialize (
100 IN EFI_HANDLE ImageHandle
,
101 IN EFI_SYSTEM_TABLE
*SystemTable
106 VariableClassAddressChangeEvent (
114 IN CHAR16
*VariableName
,
115 IN EFI_GUID
* VendorGuid
,
116 OUT UINT32
*Attributes OPTIONAL
,
117 IN OUT UINTN
*DataSize
,
119 IN VARIABLE_GLOBAL
* Global
,
125 GetNextVariableName (
126 IN OUT UINTN
*VariableNameSize
,
127 IN OUT CHAR16
*VariableName
,
128 IN OUT EFI_GUID
*VendorGuid
,
129 IN VARIABLE_GLOBAL
*Global
,
136 IN CHAR16
*VariableName
,
137 IN EFI_GUID
*VendorGuid
,
138 IN UINT32 Attributes
,
141 IN VARIABLE_GLOBAL
*Global
,
142 IN UINTN
*VolatileOffset
,
143 IN UINTN
*NonVolatileOffset
,
150 IN UINT32 Attributes
,
151 OUT UINT64
*MaximumVariableStorageSize
,
152 OUT UINT64
*RemainingVariableStorageSize
,
153 OUT UINT64
*MaximumVariableSize
,
154 IN VARIABLE_GLOBAL
*Global
,
159 GetFvbHandleByAddress (
160 IN EFI_PHYSICAL_ADDRESS VariableStoreBase
,
161 OUT EFI_HANDLE
*FvbHandle
166 IN EFI_PHYSICAL_ADDRESS VariableBaseAddress
,