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