3 The internal header file includes the common header files, defines
4 internal structure and functions used by PeiVariable module.
6 Copyright (c) 2006 - 2008, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #ifndef _PEI_VARIABLE_H_
18 #define _PEI_VARIABLE_H_
21 #include <Ppi/ReadOnlyVariable2.h>
23 #include <Library/DebugLib.h>
24 #include <Library/PeimEntryPoint.h>
25 #include <Library/HobLib.h>
26 #include <Library/PcdLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/PeiServicesTablePointerLib.h>
29 #include <Library/PeiServicesLib.h>
31 #include <VariableFormat.h>
34 // Define GET_PAD_SIZE to optimize compiler
36 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
37 #define GET_PAD_SIZE(a) (0)
39 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
42 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))
45 VARIABLE_HEADER
*CurrPtr
;
46 VARIABLE_HEADER
*EndPtr
;
47 VARIABLE_HEADER
*StartPtr
;
48 } VARIABLE_POINTER_TRACK
;
50 #define VARIABLE_INDEX_TABLE_VOLUME 122
52 #define EFI_VARIABLE_INDEX_TABLE_GUID \
53 { 0x8cfdb8c8, 0xd6b2, 0x40f3, { 0x8e, 0x97, 0x02, 0x30, 0x7c, 0xc9, 0x8b, 0x7c } }
58 VARIABLE_HEADER
*EndPtr
;
59 VARIABLE_HEADER
*StartPtr
;
60 UINT16 Index
[VARIABLE_INDEX_TABLE_VOLUME
];
61 } VARIABLE_INDEX_TABLE
;
68 Provide the functionality of the variable services.
70 @param FileHandle Handle of the file being invoked.
71 Type EFI_PEI_FILE_HANDLE is defined in FfsFindNextFile().
72 @param PeiServices General purpose services available to every PEIM.
74 @retval EFI_SUCCESS If the interface could be successfully installed
75 @retval Others Returned from PeiServicesInstallPpi()
80 PeimInitializeVariableServices (
81 IN EFI_PEI_FILE_HANDLE FileHandle
,
82 IN CONST EFI_PEI_SERVICES
**PeiServices
86 This service retrieves a variable's value using its name and GUID.
88 Read the specified variable from the UEFI variable store. If the Data
89 buffer is too small to hold the contents of the variable, the error
90 EFI_BUFFER_TOO_SMALL is returned and DataSize is set to the required buffer
91 size to obtain the data.
93 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.
94 @param VariableName A pointer to a null-terminated string that is the variable's name.
95 @param VariableGuid A pointer to an EFI_GUID that is the variable's GUID. The combination of
96 VariableGuid and VariableName must be unique.
97 @param Attributes If non-NULL, on return, points to the variable's attributes.
98 @param DataSize On entry, points to the size in bytes of the Data buffer.
99 On return, points to the size of the data returned in Data.
100 @param Data Points to the buffer which will hold the returned variable value.
102 @retval EFI_SUCCESS The variable was read successfully.
103 @retval EFI_NOT_FOUND The variable could not be found.
104 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the resulting data.
105 DataSize is updated with the size required for
106 the specified variable.
107 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid, DataSize or Data is NULL.
108 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.
114 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI
*This
,
115 IN CONST CHAR16
*VariableName
,
116 IN CONST EFI_GUID
*VariableGuid
,
117 OUT UINT32
*Attributes
,
118 IN OUT UINTN
*DataSize
,
123 Return the next variable name and GUID.
125 This function is called multiple times to retrieve the VariableName
126 and VariableGuid of all variables currently available in the system.
127 On each call, the previous results are passed into the interface,
128 and, on return, the interface returns the data for the next
129 interface. When the entire variable list has been returned,
130 EFI_NOT_FOUND is returned.
132 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.
134 @param VariableNameSize On entry, points to the size of the buffer pointed to by VariableName.
135 @param VariableName On entry, a pointer to a null-terminated string that is the variable's name.
136 On return, points to the next variable's null-terminated name string.
138 @param VariableGuid On entry, a pointer to an UEFI _GUID that is the variable's GUID.
139 On return, a pointer to the next variable's GUID.
141 @retval EFI_SUCCESS The variable was read successfully.
142 @retval EFI_NOT_FOUND The variable could not be found.
143 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the resulting
144 data. VariableNameSize is updated with the size
145 required for the specified variable.
146 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid or
147 VariableNameSize is NULL.
148 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.
153 PeiGetNextVariableName (
154 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI
*This
,
155 IN OUT UINTN
*VariableNameSize
,
156 IN OUT CHAR16
*VariableName
,
157 IN OUT EFI_GUID
*VariableGuid
161 Get one variable by the index count.
163 @param IndexTable The pointer to variable index table.
164 @param Count The index count of variable in index table.
166 @return The pointer to variable header indexed by count.
171 IN VARIABLE_INDEX_TABLE
*IndexTable
,
176 Record Variable in VariableIndex HOB.
178 Record Variable in VariableIndex HOB and update the length of variable index table.
180 @param IndexTable The pointer to variable index table.
181 @param Variable The pointer to the variable that will be recorded.
185 VariableIndexTableUpdate (
186 IN OUT VARIABLE_INDEX_TABLE
*IndexTable
,
187 IN VARIABLE_HEADER
*Variable