]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/VariablePei/Variable.h
Change C functions, xxxSizeOfVariable(), to MACRO, which can avoid the ICC compile...
[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
ab5f0d6d 47#define NAMESIZE_OF_VARIABLE(Variable) \\r
48 ((((Variable)->DataSize == (UINT32) -1) || \\r
49 ((Variable)->Attributes == (UINT32) -1) || \\r
50 ((Variable)->NameSize == (UINT32) -1)) ? \\r
51 0 : \\r
52 (Variable)->NameSize \\r
53 )\r
54\r
55#define DATASIZE_OF_VARIABLE(Variable) \\r
56 ((((Variable)->DataSize == (UINT32) -1) || \\r
57 ((Variable)->Attributes == (UINT32) -1) || \\r
58 ((Variable)->NameSize == (UINT32) -1)) ? \\r
59 0 : \\r
60 (Variable)->DataSize \\r
61 )\r
62\r
7ba905c9 63#define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))\r
64\r
65#define GET_VARIABLE_DATA_PTR(a) \\r
ab5f0d6d 66 (UINT8 *) ((UINTN) GET_VARIABLE_NAME_PTR (a) + NAMESIZE_OF_VARIABLE(a) + GET_PAD_SIZE (NAMESIZE_OF_VARIABLE(a)))\r
7ba905c9 67\r
68typedef struct {\r
69 VARIABLE_HEADER *CurrPtr;\r
70 VARIABLE_HEADER *EndPtr;\r
71 VARIABLE_HEADER *StartPtr;\r
72} VARIABLE_POINTER_TRACK;\r
73\r
74#define VARIABLE_INDEX_TABLE_VOLUME 122\r
75\r
76#define EFI_VARIABLE_INDEX_TABLE_GUID \\r
77 { 0x8cfdb8c8, 0xd6b2, 0x40f3, { 0x8e, 0x97, 0x02, 0x30, 0x7c, 0xc9, 0x8b, 0x7c } }\r
78\r
79typedef struct {\r
80 UINT16 Length;\r
81 UINT16 GoneThrough;\r
82 VARIABLE_HEADER *EndPtr;\r
83 VARIABLE_HEADER *StartPtr;\r
84 UINT16 Index[VARIABLE_INDEX_TABLE_VOLUME];\r
85} VARIABLE_INDEX_TABLE;\r
86\r
87\r
88//\r
89// Functions\r
90//\r
91EFI_STATUS\r
92EFIAPI\r
93PeimInitializeVariableServices (\r
94 IN EFI_FFS_FILE_HEADER *FfsHeader,\r
95 IN EFI_PEI_SERVICES **PeiServices\r
96 )\r
97/*++\r
98\r
99Routine Description:\r
100\r
101 TODO: Add function description\r
102\r
103Arguments:\r
104\r
105 FfsHeader - TODO: add argument description\r
106 PeiServices - TODO: add argument description\r
107\r
108Returns:\r
109\r
110 TODO: add return values\r
111\r
112--*/\r
113;\r
114\r
115EFI_STATUS\r
116EFIAPI\r
117PeiGetVariable (\r
118 IN EFI_PEI_SERVICES **PeiServices,\r
119 IN CHAR16 *VariableName,\r
120 IN EFI_GUID * VendorGuid,\r
121 OUT UINT32 *Attributes OPTIONAL,\r
122 IN OUT UINTN *DataSize,\r
123 OUT VOID *Data\r
124 )\r
125/*++\r
126\r
127Routine Description:\r
128\r
129 TODO: Add function description\r
130\r
131Arguments:\r
132\r
133 PeiServices - TODO: add argument description\r
134 VariableName - TODO: add argument description\r
135 VendorGuid - TODO: add argument description\r
136 Attributes - TODO: add argument description\r
137 DataSize - TODO: add argument description\r
138 Data - TODO: add argument description\r
139\r
140Returns:\r
141\r
142 TODO: add return values\r
143\r
144--*/\r
145;\r
146\r
147EFI_STATUS\r
148EFIAPI\r
149PeiGetVariable2 (\r
150 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
151 IN CONST CHAR16 *VariableName,\r
152 IN CONST EFI_GUID *VariableGuid,\r
153 OUT UINT32 *Attributes,\r
154 IN OUT UINTN *DataSize,\r
155 OUT VOID *Data\r
156 )\r
157/*++\r
158\r
159Routine Description:\r
160\r
161 Provide the read variable functionality of the variable services.\r
162\r
163Arguments:\r
164\r
165 PeiServices - General purpose services available to every PEIM.\r
166\r
167 VariableName - The variable name\r
168\r
169 VendorGuid - The vendor's GUID\r
170\r
171 Attributes - Pointer to the attribute\r
172\r
173 DataSize - Size of data\r
174\r
175 Data - Pointer to data\r
176\r
177Returns:\r
178\r
179 EFI_SUCCESS - The interface could be successfully installed\r
180\r
181 EFI_NOT_FOUND - The variable could not be discovered\r
182\r
183 EFI_BUFFER_TOO_SMALL - The caller buffer is not large enough\r
184\r
185--*/\r
186; \r
187 \r
188EFI_STATUS\r
189EFIAPI\r
190PeiGetNextVariableName2 (\r
191 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
192 IN OUT UINTN *VariableNameSize,\r
193 IN OUT CHAR16 *VariableName,\r
194 IN OUT EFI_GUID *VariableGuid\r
195 )\r
196/*++\r
197\r
198Routine Description:\r
199\r
200 Provide the get next variable functionality of the variable services.\r
201\r
202Arguments:\r
203\r
204 PeiServices - General purpose services available to every PEIM.\r
205 VariabvleNameSize - The variable name's size.\r
206 VariableName - A pointer to the variable's name.\r
207 VariableGuid - A pointer to the EFI_GUID structure.\r
208\r
209 VariableNameSize - Size of the variable name\r
210\r
211 VariableName - The variable name\r
212\r
213 VendorGuid - The vendor's GUID\r
214\r
215Returns:\r
216\r
217 EFI_SUCCESS - The interface could be successfully installed\r
218\r
219 EFI_NOT_FOUND - The variable could not be discovered\r
220\r
221--*/\r
222;\r
223 \r
224EFI_STATUS\r
225EFIAPI\r
226PeiGetNextVariableName (\r
227 IN EFI_PEI_SERVICES **PeiServices,\r
228 IN OUT UINTN *VariableNameSize,\r
229 IN OUT CHAR16 *VariableName,\r
230 IN OUT EFI_GUID *VendorGuid\r
231 )\r
232/*++\r
233\r
234Routine Description:\r
235\r
236 TODO: Add function description\r
237\r
238Arguments:\r
239\r
240 PeiServices - TODO: add argument description\r
241 VariableNameSize - TODO: add argument description\r
242 VariableName - TODO: add argument description\r
243 VendorGuid - TODO: add argument description\r
244\r
245Returns:\r
246\r
247 TODO: add return values\r
248\r
249--*/\r
250;\r
251\r
252/**\r
253 Get one variable by the index count.\r
254\r
255 @param IndexTable The pointer to variable index table.\r
256 @param Count The index count of variable in index table.\r
257\r
258 @return The pointer to variable header indexed by count.\r
259\r
260**/\r
261VARIABLE_HEADER *\r
262GetVariableByIndex (\r
263 IN VARIABLE_INDEX_TABLE *IndexTable,\r
264 IN UINT32 Count\r
265 );\r
266\r
267/**\r
268 Record Variable in VariableIndex HOB.\r
269\r
270 Record Variable in VariableIndex HOB and update the length of variable index table.\r
271\r
272 @param IndexTable The pointer to variable index table.\r
273 @param Variable The pointer to the variable that will be recorded.\r
274\r
275 @retval VOID\r
276\r
277**/\r
278VOID\r
279VariableIndexTableUpdate (\r
280 IN OUT VARIABLE_INDEX_TABLE *IndexTable,\r
281 IN VARIABLE_HEADER *Variable\r
282 );\r
283\r
284#endif // _PEI_VARIABLE_H\r