]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Variable/Pei/Variable.h
Code Scrub:
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / Pei / Variable.h
CommitLineData
504214c4 1/** @file\r
8d3a5c82 2\r
504214c4
LG
3 The internal header file includes the common header files, defines\r
4 internal structure and functions used by PeiVariable module.\r
5\r
6Copyright (c) 2006 - 2008, Intel Corporation\r
8d3a5c82 7All rights reserved. This program and the accompanying materials\r
8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
504214c4 15**/\r
8d3a5c82 16\r
33479ddf 17#ifndef _PEI_VARIABLE_H_\r
18#define _PEI_VARIABLE_H_\r
8d3a5c82 19\r
20#include <PiPei.h>\r
21#include <Ppi/ReadOnlyVariable2.h>\r
33479ddf 22\r
8d3a5c82 23#include <Library/DebugLib.h>\r
24#include <Library/PeimEntryPoint.h>\r
25#include <Library/HobLib.h>\r
26#include <Library/PcdLib.h>\r
27#include <Library/BaseMemoryLib.h>\r
28#include <Library/PeiServicesTablePointerLib.h>\r
33479ddf 29#include <Library/PeiServicesLib.h>\r
30\r
3cfb790c 31#include <VariableFormat.h>\r
8d3a5c82 32\r
33//\r
34// Define GET_PAD_SIZE to optimize compiler\r
35//\r
36#if ((ALIGNMENT == 0) || (ALIGNMENT == 1))\r
37#define GET_PAD_SIZE(a) (0)\r
38#else\r
39#define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))\r
40#endif\r
41\r
9cad030b 42#define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))\r
43\r
8d3a5c82 44typedef struct {\r
45 VARIABLE_HEADER *CurrPtr;\r
46 VARIABLE_HEADER *EndPtr;\r
47 VARIABLE_HEADER *StartPtr;\r
48} VARIABLE_POINTER_TRACK;\r
49\r
50#define VARIABLE_INDEX_TABLE_VOLUME 122\r
51\r
52#define EFI_VARIABLE_INDEX_TABLE_GUID \\r
53 { 0x8cfdb8c8, 0xd6b2, 0x40f3, { 0x8e, 0x97, 0x02, 0x30, 0x7c, 0xc9, 0x8b, 0x7c } }\r
54\r
55typedef struct {\r
56 UINT16 Length;\r
57 UINT16 GoneThrough;\r
58 VARIABLE_HEADER *EndPtr;\r
59 VARIABLE_HEADER *StartPtr;\r
60 UINT16 Index[VARIABLE_INDEX_TABLE_VOLUME];\r
61} VARIABLE_INDEX_TABLE;\r
62\r
63\r
64//\r
65// Functions\r
66//\r
33479ddf 67/**\r
68 Provide the functionality of the variable services.\r
69 \r
70 @param FileHandle Handle of the file being invoked. \r
71 Type EFI_PEI_FILE_HANDLE is defined in FfsFindNextFile().\r
72 @param PeiServices General purpose services available to every PEIM.\r
73\r
74 @retval EFI_SUCCESS If the interface could be successfully installed\r
75 @retval Others Returned from PeiServicesInstallPpi()\r
76\r
77**/\r
8d3a5c82 78EFI_STATUS\r
79EFIAPI\r
80PeimInitializeVariableServices (\r
33479ddf 81 IN EFI_PEI_FILE_HANDLE FileHandle,\r
82 IN CONST EFI_PEI_SERVICES **PeiServices\r
83 );\r
8d3a5c82 84\r
33479ddf 85/**\r
86 This service retrieves a variable's value using its name and GUID.\r
87\r
88 Read the specified variable from the UEFI variable store. If the Data \r
89 buffer is too small to hold the contents of the variable, the error\r
90 EFI_BUFFER_TOO_SMALL is returned and DataSize is set to the required buffer\r
91 size to obtain the data.\r
92\r
93 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r
94 @param VariableName A pointer to a null-terminated string that is the variable's name.\r
95 @param VariableGuid A pointer to an EFI_GUID that is the variable's GUID. The combination of\r
96 VariableGuid and VariableName must be unique.\r
97 @param Attributes If non-NULL, on return, points to the variable's attributes.\r
98 @param DataSize On entry, points to the size in bytes of the Data buffer.\r
99 On return, points to the size of the data returned in Data.\r
100 @param Data Points to the buffer which will hold the returned variable value.\r
101\r
102 @retval EFI_SUCCESS The variable was read successfully.\r
103 @retval EFI_NOT_FOUND The variable could not be found.\r
104 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the resulting data. \r
105 DataSize is updated with the size required for \r
106 the specified variable.\r
107 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid, DataSize or Data is NULL.\r
108 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.\r
8d3a5c82 109\r
33479ddf 110**/\r
8d3a5c82 111EFI_STATUS\r
112EFIAPI\r
113PeiGetVariable (\r
114 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
115 IN CONST CHAR16 *VariableName,\r
116 IN CONST EFI_GUID *VariableGuid,\r
117 OUT UINT32 *Attributes,\r
118 IN OUT UINTN *DataSize,\r
119 OUT VOID *Data\r
33479ddf 120 );\r
8d3a5c82 121\r
33479ddf 122/**\r
123 Return the next variable name and GUID.\r
8d3a5c82 124\r
33479ddf 125 This function is called multiple times to retrieve the VariableName \r
126 and VariableGuid of all variables currently available in the system. \r
127 On each call, the previous results are passed into the interface, \r
128 and, on return, the interface returns the data for the next \r
129 interface. When the entire variable list has been returned, \r
130 EFI_NOT_FOUND is returned.\r
8d3a5c82 131\r
33479ddf 132 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r
8d3a5c82 133\r
33479ddf 134 @param VariableNameSize On entry, points to the size of the buffer pointed to by VariableName.\r
135 @param VariableName On entry, a pointer to a null-terminated string that is the variable's name.\r
136 On return, points to the next variable's null-terminated name string.\r
8d3a5c82 137\r
33479ddf 138 @param VariableGuid On entry, a pointer to an UEFI _GUID that is the variable's GUID. \r
139 On return, a pointer to the next variable's GUID.\r
8d3a5c82 140\r
33479ddf 141 @retval EFI_SUCCESS The variable was read successfully.\r
142 @retval EFI_NOT_FOUND The variable could not be found.\r
143 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the resulting\r
144 data. VariableNameSize is updated with the size\r
145 required for the specified variable.\r
146 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid or\r
147 VariableNameSize is NULL.\r
148 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.\r
8d3a5c82 149\r
33479ddf 150**/\r
8d3a5c82 151EFI_STATUS\r
152EFIAPI\r
153PeiGetNextVariableName (\r
154 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
155 IN OUT UINTN *VariableNameSize,\r
156 IN OUT CHAR16 *VariableName,\r
157 IN OUT EFI_GUID *VariableGuid\r
33479ddf 158 );\r
8d3a5c82 159\r
160/**\r
161 Get one variable by the index count.\r
162\r
163 @param IndexTable The pointer to variable index table.\r
164 @param Count The index count of variable in index table.\r
165\r
166 @return The pointer to variable header indexed by count.\r
167\r
168**/\r
169VARIABLE_HEADER *\r
170GetVariableByIndex (\r
171 IN VARIABLE_INDEX_TABLE *IndexTable,\r
172 IN UINT32 Count\r
173 );\r
174\r
175/**\r
176 Record Variable in VariableIndex HOB.\r
177\r
178 Record Variable in VariableIndex HOB and update the length of variable index table.\r
179\r
180 @param IndexTable The pointer to variable index table.\r
181 @param Variable The pointer to the variable that will be recorded.\r
182\r
8d3a5c82 183**/\r
184VOID\r
185VariableIndexTableUpdate (\r
186 IN OUT VARIABLE_INDEX_TABLE *IndexTable,\r
187 IN VARIABLE_HEADER *Variable\r
188 );\r
189\r
33479ddf 190#endif\r