]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/VariablePei/Variable.h
Align the header of variable from 1 to 4, which can avoid the size of variable conten...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / VariablePei / Variable.h
CommitLineData
7ba905c9 1/*++\r
2\r
3Copyright (c) 2006 - 2007, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 Variable.h\r
15\r
16Abstract:\r
17\r
18 Tiano PEIM to provide the variable functionality\r
19\r
20--*/\r
21\r
22#ifndef _PEI_VARIABLE_H\r
23#define _PEI_VARIABLE_H\r
24\r
25#include <PiPei.h>\r
26#include <Ppi/ReadOnlyVariable.h>\r
27#include <Ppi/ReadOnlyVariable2.h>\r
28#include <Library/DebugLib.h>\r
29#include <Library/PeimEntryPoint.h>\r
30#include <Library/HobLib.h>\r
31#include <Library/PcdLib.h>\r
32#include <Library/BaseMemoryLib.h>\r
33#include <Library/PeiServicesTablePointerLib.h>\r
34#include <VariableFormat.h>\r
35\r
36//\r
37// Define GET_PAD_SIZE to optimize compiler\r
38//\r
39#if ((ALIGNMENT == 0) || (ALIGNMENT == 1))\r
40#define GET_PAD_SIZE(a) (0)\r
41#else\r
42#define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))\r
43#endif\r
44\r
9cad030b 45#define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))\r
46\r
7ba905c9 47#define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))\r
48\r
49#define GET_VARIABLE_DATA_PTR(a) \\r
9cad030b 50 (UINT8 *) ((UINTN) GET_VARIABLE_NAME_PTR (a) + NameSizeOfVariable(a) + GET_PAD_SIZE (NameSizeOfVariable(a) ))\r
7ba905c9 51\r
52typedef struct {\r
53 VARIABLE_HEADER *CurrPtr;\r
54 VARIABLE_HEADER *EndPtr;\r
55 VARIABLE_HEADER *StartPtr;\r
56} VARIABLE_POINTER_TRACK;\r
57\r
58#define VARIABLE_INDEX_TABLE_VOLUME 122\r
59\r
60#define EFI_VARIABLE_INDEX_TABLE_GUID \\r
61 { 0x8cfdb8c8, 0xd6b2, 0x40f3, { 0x8e, 0x97, 0x02, 0x30, 0x7c, 0xc9, 0x8b, 0x7c } }\r
62\r
63typedef struct {\r
64 UINT16 Length;\r
65 UINT16 GoneThrough;\r
66 VARIABLE_HEADER *EndPtr;\r
67 VARIABLE_HEADER *StartPtr;\r
68 UINT16 Index[VARIABLE_INDEX_TABLE_VOLUME];\r
69} VARIABLE_INDEX_TABLE;\r
70\r
71\r
72//\r
73// Functions\r
74//\r
75EFI_STATUS\r
76EFIAPI\r
77PeimInitializeVariableServices (\r
78 IN EFI_FFS_FILE_HEADER *FfsHeader,\r
79 IN EFI_PEI_SERVICES **PeiServices\r
80 )\r
81/*++\r
82\r
83Routine Description:\r
84\r
85 TODO: Add function description\r
86\r
87Arguments:\r
88\r
89 FfsHeader - TODO: add argument description\r
90 PeiServices - TODO: add argument description\r
91\r
92Returns:\r
93\r
94 TODO: add return values\r
95\r
96--*/\r
97;\r
98\r
99EFI_STATUS\r
100EFIAPI\r
101PeiGetVariable (\r
102 IN EFI_PEI_SERVICES **PeiServices,\r
103 IN CHAR16 *VariableName,\r
104 IN EFI_GUID * VendorGuid,\r
105 OUT UINT32 *Attributes OPTIONAL,\r
106 IN OUT UINTN *DataSize,\r
107 OUT VOID *Data\r
108 )\r
109/*++\r
110\r
111Routine Description:\r
112\r
113 TODO: Add function description\r
114\r
115Arguments:\r
116\r
117 PeiServices - TODO: add argument description\r
118 VariableName - TODO: add argument description\r
119 VendorGuid - TODO: add argument description\r
120 Attributes - TODO: add argument description\r
121 DataSize - TODO: add argument description\r
122 Data - TODO: add argument description\r
123\r
124Returns:\r
125\r
126 TODO: add return values\r
127\r
128--*/\r
129;\r
130\r
131EFI_STATUS\r
132EFIAPI\r
133PeiGetVariable2 (\r
134 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
135 IN CONST CHAR16 *VariableName,\r
136 IN CONST EFI_GUID *VariableGuid,\r
137 OUT UINT32 *Attributes,\r
138 IN OUT UINTN *DataSize,\r
139 OUT VOID *Data\r
140 )\r
141/*++\r
142\r
143Routine Description:\r
144\r
145 Provide the read variable functionality of the variable services.\r
146\r
147Arguments:\r
148\r
149 PeiServices - General purpose services available to every PEIM.\r
150\r
151 VariableName - The variable name\r
152\r
153 VendorGuid - The vendor's GUID\r
154\r
155 Attributes - Pointer to the attribute\r
156\r
157 DataSize - Size of data\r
158\r
159 Data - Pointer to data\r
160\r
161Returns:\r
162\r
163 EFI_SUCCESS - The interface could be successfully installed\r
164\r
165 EFI_NOT_FOUND - The variable could not be discovered\r
166\r
167 EFI_BUFFER_TOO_SMALL - The caller buffer is not large enough\r
168\r
169--*/\r
170; \r
171 \r
172EFI_STATUS\r
173EFIAPI\r
174PeiGetNextVariableName2 (\r
175 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
176 IN OUT UINTN *VariableNameSize,\r
177 IN OUT CHAR16 *VariableName,\r
178 IN OUT EFI_GUID *VariableGuid\r
179 )\r
180/*++\r
181\r
182Routine Description:\r
183\r
184 Provide the get next variable functionality of the variable services.\r
185\r
186Arguments:\r
187\r
188 PeiServices - General purpose services available to every PEIM.\r
189 VariabvleNameSize - The variable name's size.\r
190 VariableName - A pointer to the variable's name.\r
191 VariableGuid - A pointer to the EFI_GUID structure.\r
192\r
193 VariableNameSize - Size of the variable name\r
194\r
195 VariableName - The variable name\r
196\r
197 VendorGuid - The vendor's GUID\r
198\r
199Returns:\r
200\r
201 EFI_SUCCESS - The interface could be successfully installed\r
202\r
203 EFI_NOT_FOUND - The variable could not be discovered\r
204\r
205--*/\r
206;\r
207 \r
208EFI_STATUS\r
209EFIAPI\r
210PeiGetNextVariableName (\r
211 IN EFI_PEI_SERVICES **PeiServices,\r
212 IN OUT UINTN *VariableNameSize,\r
213 IN OUT CHAR16 *VariableName,\r
214 IN OUT EFI_GUID *VendorGuid\r
215 )\r
216/*++\r
217\r
218Routine Description:\r
219\r
220 TODO: Add function description\r
221\r
222Arguments:\r
223\r
224 PeiServices - TODO: add argument description\r
225 VariableNameSize - TODO: add argument description\r
226 VariableName - TODO: add argument description\r
227 VendorGuid - TODO: add argument description\r
228\r
229Returns:\r
230\r
231 TODO: add return values\r
232\r
233--*/\r
234;\r
235\r
236/**\r
237 Get one variable by the index count.\r
238\r
239 @param IndexTable The pointer to variable index table.\r
240 @param Count The index count of variable in index table.\r
241\r
242 @return The pointer to variable header indexed by count.\r
243\r
244**/\r
245VARIABLE_HEADER *\r
246GetVariableByIndex (\r
247 IN VARIABLE_INDEX_TABLE *IndexTable,\r
248 IN UINT32 Count\r
249 );\r
250\r
251/**\r
252 Record Variable in VariableIndex HOB.\r
253\r
254 Record Variable in VariableIndex HOB and update the length of variable index table.\r
255\r
256 @param IndexTable The pointer to variable index table.\r
257 @param Variable The pointer to the variable that will be recorded.\r
258\r
259 @retval VOID\r
260\r
261**/\r
262VOID\r
263VariableIndexTableUpdate (\r
264 IN OUT VARIABLE_INDEX_TABLE *IndexTable,\r
265 IN VARIABLE_HEADER *Variable\r
266 );\r
267\r
268#endif // _PEI_VARIABLE_H\r