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.
18 Tiano PEIM to provide the variable functionality
22 #ifndef _PEI_VARIABLE_H
23 #define _PEI_VARIABLE_H
26 #include <Ppi/ReadOnlyVariable.h>
27 #include <Ppi/ReadOnlyVariable2.h>
28 #include <Library/DebugLib.h>
29 #include <Library/PeimEntryPoint.h>
30 #include <Library/HobLib.h>
31 #include <Library/PcdLib.h>
32 #include <Library/BaseMemoryLib.h>
33 #include <Library/PeiServicesTablePointerLib.h>
34 #include <VariableFormat.h>
37 // Define GET_PAD_SIZE to optimize compiler
39 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
40 #define GET_PAD_SIZE(a) (0)
42 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
45 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))
47 #define NAMESIZE_OF_VARIABLE(Variable) \
48 ((((Variable)->DataSize == (UINT32) -1) || \
49 ((Variable)->Attributes == (UINT32) -1) || \
50 ((Variable)->NameSize == (UINT32) -1)) ? \
52 (Variable)->NameSize \
55 #define DATASIZE_OF_VARIABLE(Variable) \
56 ((((Variable)->DataSize == (UINT32) -1) || \
57 ((Variable)->Attributes == (UINT32) -1) || \
58 ((Variable)->NameSize == (UINT32) -1)) ? \
60 (Variable)->DataSize \
63 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
65 #define GET_VARIABLE_DATA_PTR(a) \
66 (UINT8 *) ((UINTN) GET_VARIABLE_NAME_PTR (a) + NAMESIZE_OF_VARIABLE(a) + GET_PAD_SIZE (NAMESIZE_OF_VARIABLE(a)))
69 VARIABLE_HEADER
*CurrPtr
;
70 VARIABLE_HEADER
*EndPtr
;
71 VARIABLE_HEADER
*StartPtr
;
72 } VARIABLE_POINTER_TRACK
;
74 #define VARIABLE_INDEX_TABLE_VOLUME 122
76 #define EFI_VARIABLE_INDEX_TABLE_GUID \
77 { 0x8cfdb8c8, 0xd6b2, 0x40f3, { 0x8e, 0x97, 0x02, 0x30, 0x7c, 0xc9, 0x8b, 0x7c } }
82 VARIABLE_HEADER
*EndPtr
;
83 VARIABLE_HEADER
*StartPtr
;
84 UINT16 Index
[VARIABLE_INDEX_TABLE_VOLUME
];
85 } VARIABLE_INDEX_TABLE
;
93 PeimInitializeVariableServices (
94 IN EFI_FFS_FILE_HEADER
*FfsHeader
,
95 IN EFI_PEI_SERVICES
**PeiServices
101 TODO: Add function description
105 FfsHeader - TODO: add argument description
106 PeiServices - TODO: add argument description
110 TODO: add return values
118 IN EFI_PEI_SERVICES
**PeiServices
,
119 IN CHAR16
*VariableName
,
120 IN EFI_GUID
* VendorGuid
,
121 OUT UINT32
*Attributes OPTIONAL
,
122 IN OUT UINTN
*DataSize
,
129 TODO: Add function description
133 PeiServices - TODO: add argument description
134 VariableName - TODO: add argument description
135 VendorGuid - TODO: add argument description
136 Attributes - TODO: add argument description
137 DataSize - TODO: add argument description
138 Data - TODO: add argument description
142 TODO: add return values
150 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI
*This
,
151 IN CONST CHAR16
*VariableName
,
152 IN CONST EFI_GUID
*VariableGuid
,
153 OUT UINT32
*Attributes
,
154 IN OUT UINTN
*DataSize
,
161 Provide the read variable functionality of the variable services.
165 PeiServices - General purpose services available to every PEIM.
167 VariableName - The variable name
169 VendorGuid - The vendor's GUID
171 Attributes - Pointer to the attribute
173 DataSize - Size of data
175 Data - Pointer to data
179 EFI_SUCCESS - The interface could be successfully installed
181 EFI_NOT_FOUND - The variable could not be discovered
183 EFI_BUFFER_TOO_SMALL - The caller buffer is not large enough
190 PeiGetNextVariableName2 (
191 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI
*This
,
192 IN OUT UINTN
*VariableNameSize
,
193 IN OUT CHAR16
*VariableName
,
194 IN OUT EFI_GUID
*VariableGuid
200 Provide the get next variable functionality of the variable services.
204 PeiServices - General purpose services available to every PEIM.
205 VariabvleNameSize - The variable name's size.
206 VariableName - A pointer to the variable's name.
207 VariableGuid - A pointer to the EFI_GUID structure.
209 VariableNameSize - Size of the variable name
211 VariableName - The variable name
213 VendorGuid - The vendor's GUID
217 EFI_SUCCESS - The interface could be successfully installed
219 EFI_NOT_FOUND - The variable could not be discovered
226 PeiGetNextVariableName (
227 IN EFI_PEI_SERVICES
**PeiServices
,
228 IN OUT UINTN
*VariableNameSize
,
229 IN OUT CHAR16
*VariableName
,
230 IN OUT EFI_GUID
*VendorGuid
236 TODO: Add function description
240 PeiServices - TODO: add argument description
241 VariableNameSize - TODO: add argument description
242 VariableName - TODO: add argument description
243 VendorGuid - TODO: add argument description
247 TODO: add return values
253 Get one variable by the index count.
255 @param IndexTable The pointer to variable index table.
256 @param Count The index count of variable in index table.
258 @return The pointer to variable header indexed by count.
263 IN VARIABLE_INDEX_TABLE
*IndexTable
,
268 Record Variable in VariableIndex HOB.
270 Record Variable in VariableIndex HOB and update the length of variable index table.
272 @param IndexTable The pointer to variable index table.
273 @param Variable The pointer to the variable that will be recorded.
279 VariableIndexTableUpdate (
280 IN OUT VARIABLE_INDEX_TABLE
*IndexTable
,
281 IN VARIABLE_HEADER
*Variable
284 #endif // _PEI_VARIABLE_H