]> git.proxmox.com Git - mirror_edk2.git/blob - 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
1 /*++
2
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
8
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.
11
12 Module Name:
13
14 Variable.h
15
16 Abstract:
17
18 Tiano PEIM to provide the variable functionality
19
20 --*/
21
22 #ifndef _PEI_VARIABLE_H
23 #define _PEI_VARIABLE_H
24
25 #include <PiPei.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>
35
36 //
37 // Define GET_PAD_SIZE to optimize compiler
38 //
39 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
40 #define GET_PAD_SIZE(a) (0)
41 #else
42 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
43 #endif
44
45 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))
46
47 #define NAMESIZE_OF_VARIABLE(Variable) \
48 ((((Variable)->DataSize == (UINT32) -1) || \
49 ((Variable)->Attributes == (UINT32) -1) || \
50 ((Variable)->NameSize == (UINT32) -1)) ? \
51 0 : \
52 (Variable)->NameSize \
53 )
54
55 #define DATASIZE_OF_VARIABLE(Variable) \
56 ((((Variable)->DataSize == (UINT32) -1) || \
57 ((Variable)->Attributes == (UINT32) -1) || \
58 ((Variable)->NameSize == (UINT32) -1)) ? \
59 0 : \
60 (Variable)->DataSize \
61 )
62
63 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
64
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)))
67
68 typedef struct {
69 VARIABLE_HEADER *CurrPtr;
70 VARIABLE_HEADER *EndPtr;
71 VARIABLE_HEADER *StartPtr;
72 } VARIABLE_POINTER_TRACK;
73
74 #define VARIABLE_INDEX_TABLE_VOLUME 122
75
76 #define EFI_VARIABLE_INDEX_TABLE_GUID \
77 { 0x8cfdb8c8, 0xd6b2, 0x40f3, { 0x8e, 0x97, 0x02, 0x30, 0x7c, 0xc9, 0x8b, 0x7c } }
78
79 typedef struct {
80 UINT16 Length;
81 UINT16 GoneThrough;
82 VARIABLE_HEADER *EndPtr;
83 VARIABLE_HEADER *StartPtr;
84 UINT16 Index[VARIABLE_INDEX_TABLE_VOLUME];
85 } VARIABLE_INDEX_TABLE;
86
87
88 //
89 // Functions
90 //
91 EFI_STATUS
92 EFIAPI
93 PeimInitializeVariableServices (
94 IN EFI_FFS_FILE_HEADER *FfsHeader,
95 IN EFI_PEI_SERVICES **PeiServices
96 )
97 /*++
98
99 Routine Description:
100
101 TODO: Add function description
102
103 Arguments:
104
105 FfsHeader - TODO: add argument description
106 PeiServices - TODO: add argument description
107
108 Returns:
109
110 TODO: add return values
111
112 --*/
113 ;
114
115 EFI_STATUS
116 EFIAPI
117 PeiGetVariable (
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,
123 OUT VOID *Data
124 )
125 /*++
126
127 Routine Description:
128
129 TODO: Add function description
130
131 Arguments:
132
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
139
140 Returns:
141
142 TODO: add return values
143
144 --*/
145 ;
146
147 EFI_STATUS
148 EFIAPI
149 PeiGetVariable2 (
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,
155 OUT VOID *Data
156 )
157 /*++
158
159 Routine Description:
160
161 Provide the read variable functionality of the variable services.
162
163 Arguments:
164
165 PeiServices - General purpose services available to every PEIM.
166
167 VariableName - The variable name
168
169 VendorGuid - The vendor's GUID
170
171 Attributes - Pointer to the attribute
172
173 DataSize - Size of data
174
175 Data - Pointer to data
176
177 Returns:
178
179 EFI_SUCCESS - The interface could be successfully installed
180
181 EFI_NOT_FOUND - The variable could not be discovered
182
183 EFI_BUFFER_TOO_SMALL - The caller buffer is not large enough
184
185 --*/
186 ;
187
188 EFI_STATUS
189 EFIAPI
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
195 )
196 /*++
197
198 Routine Description:
199
200 Provide the get next variable functionality of the variable services.
201
202 Arguments:
203
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.
208
209 VariableNameSize - Size of the variable name
210
211 VariableName - The variable name
212
213 VendorGuid - The vendor's GUID
214
215 Returns:
216
217 EFI_SUCCESS - The interface could be successfully installed
218
219 EFI_NOT_FOUND - The variable could not be discovered
220
221 --*/
222 ;
223
224 EFI_STATUS
225 EFIAPI
226 PeiGetNextVariableName (
227 IN EFI_PEI_SERVICES **PeiServices,
228 IN OUT UINTN *VariableNameSize,
229 IN OUT CHAR16 *VariableName,
230 IN OUT EFI_GUID *VendorGuid
231 )
232 /*++
233
234 Routine Description:
235
236 TODO: Add function description
237
238 Arguments:
239
240 PeiServices - TODO: add argument description
241 VariableNameSize - TODO: add argument description
242 VariableName - TODO: add argument description
243 VendorGuid - TODO: add argument description
244
245 Returns:
246
247 TODO: add return values
248
249 --*/
250 ;
251
252 /**
253 Get one variable by the index count.
254
255 @param IndexTable The pointer to variable index table.
256 @param Count The index count of variable in index table.
257
258 @return The pointer to variable header indexed by count.
259
260 **/
261 VARIABLE_HEADER *
262 GetVariableByIndex (
263 IN VARIABLE_INDEX_TABLE *IndexTable,
264 IN UINT32 Count
265 );
266
267 /**
268 Record Variable in VariableIndex HOB.
269
270 Record Variable in VariableIndex HOB and update the length of variable index table.
271
272 @param IndexTable The pointer to variable index table.
273 @param Variable The pointer to the variable that will be recorded.
274
275 @retval VOID
276
277 **/
278 VOID
279 VariableIndexTableUpdate (
280 IN OUT VARIABLE_INDEX_TABLE *IndexTable,
281 IN VARIABLE_HEADER *Variable
282 );
283
284 #endif // _PEI_VARIABLE_H