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.
20 #ifndef _FS_VARIABLE_H
21 #define _FS_VARIABLE_H
24 // Statements that include other header files
28 #include <Library/BaseLib.h>
29 #include <Library/PcdLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/UefiBootServicesTableLib.h>
32 #include <Library/UefiRuntimeLib.h>
33 #include <Library/DebugLib.h>
34 #include <Library/UefiLib.h>
35 #include <Library/HobLib.h>
36 #include <Library/DxeServicesTableLib.h>
37 #include <Library/DevicePathLib.h>
39 #include <Guid/HobList.h>
40 #include <Guid/FlashMapHob.h>
41 #include <Guid/VariableFormat.h>
42 #include <Guid/GlobalVariable.h>
43 #include <Protocol/Variable.h>
44 #include <Protocol/VariableWrite.h>
45 #include <Protocol/SimpleFileSystem.h>
46 #include <Protocol/BlockIo.h>
49 #include "EfiFlashMap.h"
50 #include "VariableStorage.h"
52 #define VOLATILE_VARIABLE_STORE_SIZE FixedPcdGet32(PcdVariableStoreSize)
53 #define VARIABLE_SCRATCH_SIZE MAX(FixedPcdGet32(PcdMaxVariableSize), FixedPcdGet32(PcdMaxHardwareErrorVariableSize))
54 #define VARIABLE_RECLAIM_THRESHOLD (1024)
56 /// The size of a 3 character ISO639 language code.
58 #define ISO_639_2_ENTRY_SIZE 3
60 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
65 } VARIABLE_POINTER_TYPE
;
71 } VARIABLE_STORAGE_TYPE
;
74 VARIABLE_HEADER
*CurrPtr
;
75 VARIABLE_HEADER
*EndPtr
;
76 VARIABLE_HEADER
*StartPtr
;
77 VARIABLE_STORAGE_TYPE Type
;
78 } VARIABLE_POINTER_TRACK
;
80 #define VARIABLE_MEMBER_OFFSET(Member, StartOffset) \
81 ( sizeof (VARIABLE_STORE_HEADER) + (StartOffset) + \
82 (UINTN) ((UINT8 *) &((VARIABLE_HEADER*) 0)->Member - (UINT8 *) &((VARIABLE_HEADER*) 0)->StartId) \
87 EFI_EVENT_NOTIFY GoVirtualChildEvent
[MaxType
];
88 VARIABLE_STORAGE
*VariableStore
[MaxType
]; // Instance of VariableStorage
89 VOID
*VariableBase
[MaxType
]; // Start address of variable storage
90 UINTN LastVariableOffset
[MaxType
]; // The position to write new variable to (index from VariableBase)
91 VOID
*Scratch
; // Buffer used during reclaim
92 UINTN CommonVariableTotalSize
;
93 UINTN HwErrVariableTotalSize
;
94 CHAR8 PlatformLangCodes
[256]; //Pre-allocate 256 bytes space to accommodate the PlatformlangCodes.
95 CHAR8 LangCodes
[256]; //Pre-allocate 256 bytes space to accommodate the langCodes.
96 CHAR8 PlatformLang
[8]; //Pre-allocate 8 bytes space to accommodate the Platformlang variable.
97 CHAR8 Lang
[4]; //Pre-allocate 4 bytes space to accommodate the lang variable.
106 VariableServiceInitialize (
107 IN EFI_HANDLE ImageHandle
,
108 IN EFI_SYSTEM_TABLE
*SystemTable
113 VariableClassAddressChangeEvent (
121 IN CHAR16
*VariableName
,
122 IN EFI_GUID
*VendorGuid
,
123 OUT UINT32
*Attributes OPTIONAL
,
124 IN OUT UINTN
*DataSize
,
130 GetNextVariableName (
131 IN OUT UINTN
*VariableNameSize
,
132 IN OUT CHAR16
*VariableName
,
133 IN OUT EFI_GUID
*VendorGuid
139 IN CHAR16
*VariableName
,
140 IN EFI_GUID
*VendorGuid
,
141 IN UINT32 Attributes
,
146 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
150 IN UINT32 Attributes
,
151 OUT UINT64
*MaximumVariableStorageSize
,
152 OUT UINT64
*RemainingVariableStorageSize
,
153 OUT UINT64
*MaximumVariableSize
155 #endif // EFI_SPECIFICATION_VERSION >= 0x00020000