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