]>
Commit | Line | Data |
---|---|---|
504214c4 | 1 | /** @file\r |
8d3a5c82 | 2 | \r |
504214c4 | 3 | The internal header file includes the common header files, defines\r |
8a2d4996 | 4 | internal structure and functions used by Variable modules.\r |
504214c4 | 5 | \r |
efb01a10 | 6 | Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r |
e5eed7d3 | 7 | This program and the accompanying materials\r |
8d3a5c82 | 8 | are licensed and made available under the terms and conditions of the BSD License\r |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
504214c4 | 15 | **/\r |
8d3a5c82 | 16 | \r |
7c80e839 | 17 | #ifndef _VARIABLE_H_\r |
18 | #define _VARIABLE_H_\r | |
8d3a5c82 | 19 | \r |
39099938 | 20 | #include <PiDxe.h>\r |
8d3a5c82 | 21 | #include <Protocol/VariableWrite.h>\r |
88a5561c | 22 | #include <Protocol/FaultTolerantWrite.h>\r |
8d3a5c82 | 23 | #include <Protocol/FirmwareVolumeBlock.h>\r |
24 | #include <Protocol/Variable.h>\r | |
ff843847 | 25 | #include <Protocol/VariableLock.h>\r |
efb01a10 | 26 | #include <Protocol/VarCheck.h>\r |
8d3a5c82 | 27 | #include <Library/PcdLib.h>\r |
0f7aff72 | 28 | #include <Library/HobLib.h>\r |
8d3a5c82 | 29 | #include <Library/UefiDriverEntryPoint.h>\r |
30 | #include <Library/DxeServicesTableLib.h>\r | |
31 | #include <Library/UefiRuntimeLib.h>\r | |
32 | #include <Library/DebugLib.h>\r | |
33 | #include <Library/BaseMemoryLib.h>\r | |
8d3a5c82 | 34 | #include <Library/UefiBootServicesTableLib.h>\r |
35 | #include <Library/UefiLib.h>\r | |
36 | #include <Library/BaseLib.h>\r | |
4cf894eb | 37 | #include <Library/SynchronizationLib.h>\r |
8d3a5c82 | 38 | #include <Library/MemoryAllocationLib.h>\r |
052ad7e1 | 39 | #include <Guid/GlobalVariable.h>\r |
01a5c994 | 40 | #include <Guid/EventGroup.h>\r |
3709c4cd | 41 | #include <Guid/VariableFormat.h>\r |
d6550260 | 42 | #include <Guid/SystemNvDataGuid.h>\r |
3e02ebb2 | 43 | #include <Guid/FaultTolerantWrite.h>\r |
a5f15e30 | 44 | #include <Guid/HardwareErrorVariable.h>\r |
4edb1866 | 45 | #include <Guid/VarErrorFlag.h>\r |
8d3a5c82 | 46 | \r |
6675a21f SZ |
47 | #define VARIABLE_ATTRIBUTE_BS_RT (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)\r |
48 | #define VARIABLE_ATTRIBUTE_NV_BS_RT (VARIABLE_ATTRIBUTE_BS_RT | EFI_VARIABLE_NON_VOLATILE)\r | |
49 | #define VARIABLE_ATTRIBUTE_NV_BS_RT_AT (VARIABLE_ATTRIBUTE_NV_BS_RT | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS)\r | |
50 | \r | |
255a3f33 RN |
51 | ///\r |
52 | /// The size of a 3 character ISO639 language code.\r | |
53 | ///\r | |
54 | #define ISO_639_2_ENTRY_SIZE 3\r | |
55 | \r | |
0f7aff72 RN |
56 | typedef enum {\r |
57 | VariableStoreTypeVolatile,\r | |
58 | VariableStoreTypeHob,\r | |
59 | VariableStoreTypeNv,\r | |
60 | VariableStoreTypeMax\r | |
61 | } VARIABLE_STORE_TYPE;\r | |
62 | \r | |
8d3a5c82 | 63 | typedef struct {\r |
64 | VARIABLE_HEADER *CurrPtr;\r | |
23b06935 SZ |
65 | //\r |
66 | // If both ADDED and IN_DELETED_TRANSITION variable are present,\r | |
67 | // InDeletedTransitionPtr will point to the IN_DELETED_TRANSITION one.\r | |
68 | // Otherwise, CurrPtr will point to the ADDED or IN_DELETED_TRANSITION one,\r | |
69 | // and InDeletedTransitionPtr will be NULL at the same time.\r | |
70 | //\r | |
71 | VARIABLE_HEADER *InDeletedTransitionPtr;\r | |
8d3a5c82 | 72 | VARIABLE_HEADER *EndPtr;\r |
73 | VARIABLE_HEADER *StartPtr;\r | |
74 | BOOLEAN Volatile;\r | |
75 | } VARIABLE_POINTER_TRACK;\r | |
76 | \r | |
77 | typedef struct {\r | |
0f7aff72 | 78 | EFI_PHYSICAL_ADDRESS HobVariableBase;\r |
8d3a5c82 | 79 | EFI_PHYSICAL_ADDRESS VolatileVariableBase;\r |
80 | EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;\r | |
81 | EFI_LOCK VariableServicesLock;\r | |
fdb7765f | 82 | UINT32 ReentrantState;\r |
8d3a5c82 | 83 | } VARIABLE_GLOBAL;\r |
84 | \r | |
85 | typedef struct {\r | |
052ad7e1 | 86 | VARIABLE_GLOBAL VariableGlobal;\r |
8d3a5c82 | 87 | UINTN VolatileLastVariableOffset;\r |
88 | UINTN NonVolatileLastVariableOffset;\r | |
4edb1866 SZ |
89 | UINTN CommonVariableSpace;\r |
90 | UINTN CommonMaxUserVariableSpace;\r | |
91 | UINTN CommonRuntimeVariableSpace;\r | |
2fcdca1d | 92 | UINTN CommonVariableTotalSize;\r |
4edb1866 | 93 | UINTN CommonUserVariableTotalSize;\r |
2fcdca1d | 94 | UINTN HwErrVariableTotalSize;\r |
255a3f33 RN |
95 | CHAR8 *PlatformLangCodes;\r |
96 | CHAR8 *LangCodes;\r | |
97 | CHAR8 *PlatformLang;\r | |
98 | CHAR8 Lang[ISO_639_2_ENTRY_SIZE + 1];\r | |
8a9e0b72 | 99 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbInstance;\r |
052ad7e1 A |
100 | } VARIABLE_MODULE_GLOBAL;\r |
101 | \r | |
102 | typedef struct {\r | |
103 | EFI_GUID *Guid;\r | |
104 | CHAR16 *Name;\r | |
b2bd493e SZ |
105 | UINTN VariableSize;\r |
106 | } VARIABLE_ENTRY_CONSISTENCY;\r | |
8d3a5c82 | 107 | \r |
ff843847 | 108 | typedef struct {\r |
ff843847 | 109 | LIST_ENTRY Link;\r |
efb01a10 SZ |
110 | EFI_GUID Guid;\r |
111 | //CHAR16 *Name;\r | |
ff843847 RN |
112 | } VARIABLE_ENTRY;\r |
113 | \r | |
335e2681 SZ |
114 | /**\r |
115 | Flush the HOB variable to flash.\r | |
116 | \r | |
117 | @param[in] VariableName Name of variable has been updated or deleted.\r | |
118 | @param[in] VendorGuid Guid of variable has been updated or deleted.\r | |
119 | \r | |
120 | **/\r | |
121 | VOID\r | |
122 | FlushHobVariableToFlash (\r | |
123 | IN CHAR16 *VariableName,\r | |
124 | IN EFI_GUID *VendorGuid\r | |
125 | );\r | |
126 | \r | |
c24b392c | 127 | /**\r |
128 | Writes a buffer to variable storage space, in the working block.\r | |
129 | \r | |
8a2d4996 | 130 | This function writes a buffer to variable storage space into a firmware\r |
131 | volume block device. The destination is specified by the parameter\r | |
c24b392c | 132 | VariableBase. Fault Tolerant Write protocol is used for writing.\r |
133 | \r | |
8a2d4996 | 134 | @param VariableBase Base address of the variable to write.\r |
128ef095 | 135 | @param VariableBuffer Point to the variable data buffer.\r |
c24b392c | 136 | \r |
8a2d4996 | 137 | @retval EFI_SUCCESS The function completed successfully.\r |
138 | @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol.\r | |
139 | @retval EFI_ABORTED The function could not complete successfully.\r | |
c24b392c | 140 | \r |
141 | **/\r | |
142 | EFI_STATUS\r | |
143 | FtwVariableSpace (\r | |
144 | IN EFI_PHYSICAL_ADDRESS VariableBase,\r | |
128ef095 | 145 | IN VARIABLE_STORE_HEADER *VariableBuffer\r |
c24b392c | 146 | );\r |
147 | \r | |
148 | \r | |
8a2d4996 | 149 | /**\r |
150 | Update the variable region with Variable information. These are the same \r | |
151 | arguments as the EFI Variable services.\r | |
152 | \r | |
153 | @param[in] VariableName Name of variable.\r | |
154 | \r | |
155 | @param[in] VendorGuid Guid of variable.\r | |
156 | \r | |
157 | @param[in] Data Variable data.\r | |
158 | \r | |
159 | @param[in] DataSize Size of data. 0 means delete.\r | |
160 | \r | |
161 | @param[in] Attributes Attribues of the variable.\r | |
162 | \r | |
23b06935 | 163 | @param[in, out] Variable The variable information that is used to keep track of variable usage.\r |
8a2d4996 | 164 | \r |
165 | @retval EFI_SUCCESS The update operation is success.\r | |
166 | \r | |
167 | @retval EFI_OUT_OF_RESOURCES Variable region is full, cannot write other data into this region.\r | |
168 | \r | |
169 | **/\r | |
170 | EFI_STATUS\r | |
171 | UpdateVariable (\r | |
172 | IN CHAR16 *VariableName,\r | |
173 | IN EFI_GUID *VendorGuid,\r | |
174 | IN VOID *Data,\r | |
175 | IN UINTN DataSize,\r | |
176 | IN UINT32 Attributes OPTIONAL,\r | |
23b06935 | 177 | IN OUT VARIABLE_POINTER_TRACK *Variable\r |
8a2d4996 | 178 | );\r |
179 | \r | |
180 | \r | |
181 | /**\r | |
182 | Return TRUE if ExitBootServices () has been called.\r | |
183 | \r | |
184 | @retval TRUE If ExitBootServices () has been called.\r | |
185 | **/\r | |
186 | BOOLEAN\r | |
187 | AtRuntime (\r | |
188 | VOID\r | |
189 | );\r | |
190 | \r | |
191 | /**\r | |
192 | Initializes a basic mutual exclusion lock.\r | |
193 | \r | |
194 | This function initializes a basic mutual exclusion lock to the released state \r | |
195 | and returns the lock. Each lock provides mutual exclusion access at its task \r | |
196 | priority level. Since there is no preemption or multiprocessor support in EFI,\r | |
197 | acquiring the lock only consists of raising to the locks TPL.\r | |
198 | If Lock is NULL, then ASSERT().\r | |
199 | If Priority is not a valid TPL value, then ASSERT().\r | |
200 | \r | |
201 | @param Lock A pointer to the lock data structure to initialize.\r | |
202 | @param Priority EFI TPL is associated with the lock.\r | |
203 | \r | |
204 | @return The lock.\r | |
205 | \r | |
206 | **/\r | |
207 | EFI_LOCK *\r | |
208 | InitializeLock (\r | |
209 | IN OUT EFI_LOCK *Lock,\r | |
210 | IN EFI_TPL Priority\r | |
211 | );\r | |
212 | \r | |
213 | \r | |
214 | /**\r | |
215 | Acquires lock only at boot time. Simply returns at runtime.\r | |
216 | \r | |
217 | This is a temperary function that will be removed when\r | |
218 | EfiAcquireLock() in UefiLib can handle the call in UEFI\r | |
219 | Runtimer driver in RT phase.\r | |
220 | It calls EfiAcquireLock() at boot time, and simply returns\r | |
221 | at runtime.\r | |
222 | \r | |
223 | @param Lock A pointer to the lock to acquire.\r | |
224 | \r | |
225 | **/\r | |
226 | VOID\r | |
227 | AcquireLockOnlyAtBootTime (\r | |
228 | IN EFI_LOCK *Lock\r | |
229 | );\r | |
230 | \r | |
231 | \r | |
232 | /**\r | |
233 | Releases lock only at boot time. Simply returns at runtime.\r | |
234 | \r | |
235 | This is a temperary function which will be removed when\r | |
236 | EfiReleaseLock() in UefiLib can handle the call in UEFI\r | |
237 | Runtimer driver in RT phase.\r | |
238 | It calls EfiReleaseLock() at boot time and simply returns\r | |
239 | at runtime.\r | |
240 | \r | |
241 | @param Lock A pointer to the lock to release.\r | |
242 | \r | |
243 | **/\r | |
244 | VOID\r | |
245 | ReleaseLockOnlyAtBootTime (\r | |
246 | IN EFI_LOCK *Lock\r | |
247 | ); \r | |
248 | \r | |
249 | /**\r | |
250 | Retrive the FVB protocol interface by HANDLE.\r | |
251 | \r | |
252 | @param[in] FvBlockHandle The handle of FVB protocol that provides services for\r | |
253 | reading, writing, and erasing the target block.\r | |
254 | @param[out] FvBlock The interface of FVB protocol\r | |
255 | \r | |
256 | @retval EFI_SUCCESS The interface information for the specified protocol was returned.\r | |
257 | @retval EFI_UNSUPPORTED The device does not support the FVB protocol.\r | |
258 | @retval EFI_INVALID_PARAMETER FvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.\r | |
259 | \r | |
260 | **/\r | |
261 | EFI_STATUS\r | |
262 | GetFvbByHandle (\r | |
263 | IN EFI_HANDLE FvBlockHandle,\r | |
264 | OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r | |
265 | );\r | |
266 | \r | |
267 | \r | |
268 | /**\r | |
269 | Retrive the Swap Address Range protocol interface.\r | |
270 | \r | |
271 | @param[out] SarProtocol The interface of SAR protocol\r | |
272 | \r | |
273 | @retval EFI_SUCCESS The SAR protocol instance was found and returned in SarProtocol.\r | |
274 | @retval EFI_NOT_FOUND The SAR protocol instance was not found.\r | |
275 | @retval EFI_INVALID_PARAMETER SarProtocol is NULL.\r | |
276 | \r | |
277 | **/\r | |
278 | EFI_STATUS\r | |
279 | GetSarProtocol (\r | |
280 | OUT VOID **SarProtocol\r | |
281 | );\r | |
282 | \r | |
283 | /**\r | |
284 | Function returns an array of handles that support the FVB protocol\r | |
285 | in a buffer allocated from pool. \r | |
286 | \r | |
287 | @param[out] NumberHandles The number of handles returned in Buffer.\r | |
288 | @param[out] Buffer A pointer to the buffer to return the requested\r | |
289 | array of handles that support FVB protocol.\r | |
290 | \r | |
291 | @retval EFI_SUCCESS The array of handles was returned in Buffer, and the number of\r | |
292 | handles in Buffer was returned in NumberHandles.\r | |
293 | @retval EFI_NOT_FOUND No FVB handle was found.\r | |
294 | @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results.\r | |
295 | @retval EFI_INVALID_PARAMETER NumberHandles is NULL or Buffer is NULL.\r | |
296 | \r | |
297 | **/\r | |
298 | EFI_STATUS\r | |
299 | GetFvbCountAndBuffer (\r | |
300 | OUT UINTN *NumberHandles,\r | |
301 | OUT EFI_HANDLE **Buffer\r | |
302 | );\r | |
303 | \r | |
304 | /**\r | |
305 | Initializes variable store area for non-volatile and volatile variable.\r | |
306 | \r | |
307 | @retval EFI_SUCCESS Function successfully executed.\r | |
308 | @retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.\r | |
309 | \r | |
310 | **/\r | |
311 | EFI_STATUS\r | |
312 | VariableCommonInitialize (\r | |
313 | VOID\r | |
314 | );\r | |
315 | \r | |
316 | /**\r | |
317 | This function reclaims variable storage if free size is below the threshold.\r | |
318 | \r | |
319 | **/\r | |
320 | VOID\r | |
321 | ReclaimForOS(\r | |
322 | VOID\r | |
323 | ); \r | |
324 | \r | |
325 | \r | |
326 | /**\r | |
327 | Initializes variable write service after FVB was ready.\r | |
328 | \r | |
329 | @retval EFI_SUCCESS Function successfully executed.\r | |
330 | @retval Others Fail to initialize the variable service.\r | |
331 | \r | |
332 | **/\r | |
333 | EFI_STATUS\r | |
334 | VariableWriteServiceInitialize (\r | |
335 | VOID\r | |
336 | );\r | |
337 | \r | |
338 | /**\r | |
339 | Retrive the SMM Fault Tolerent Write protocol interface.\r | |
340 | \r | |
341 | @param[out] FtwProtocol The interface of SMM Ftw protocol\r | |
342 | \r | |
343 | @retval EFI_SUCCESS The SMM SAR protocol instance was found and returned in SarProtocol.\r | |
344 | @retval EFI_NOT_FOUND The SMM SAR protocol instance was not found.\r | |
345 | @retval EFI_INVALID_PARAMETER SarProtocol is NULL.\r | |
346 | \r | |
347 | **/\r | |
348 | EFI_STATUS\r | |
349 | GetFtwProtocol (\r | |
350 | OUT VOID **FtwProtocol\r | |
351 | );\r | |
352 | \r | |
353 | /**\r | |
354 | Get the proper fvb handle and/or fvb protocol by the given Flash address.\r | |
355 | \r | |
356 | @param[in] Address The Flash address.\r | |
357 | @param[out] FvbHandle In output, if it is not NULL, it points to the proper FVB handle.\r | |
358 | @param[out] FvbProtocol In output, if it is not NULL, it points to the proper FVB protocol.\r | |
359 | \r | |
360 | **/\r | |
361 | EFI_STATUS\r | |
362 | GetFvbInfoByAddress (\r | |
363 | IN EFI_PHYSICAL_ADDRESS Address,\r | |
364 | OUT EFI_HANDLE *FvbHandle OPTIONAL,\r | |
365 | OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvbProtocol OPTIONAL\r | |
366 | );\r | |
367 | \r | |
4edb1866 SZ |
368 | /**\r |
369 | Finds variable in storage blocks of volatile and non-volatile storage areas.\r | |
370 | \r | |
371 | This code finds variable in storage blocks of volatile and non-volatile storage areas.\r | |
372 | If VariableName is an empty string, then we just return the first\r | |
373 | qualified variable without comparing VariableName and VendorGuid.\r | |
374 | If IgnoreRtCheck is TRUE, then we ignore the EFI_VARIABLE_RUNTIME_ACCESS attribute check\r | |
375 | at runtime when searching existing variable, only VariableName and VendorGuid are compared.\r | |
376 | Otherwise, variables without EFI_VARIABLE_RUNTIME_ACCESS are not visible at runtime.\r | |
377 | \r | |
378 | @param VariableName Name of the variable to be found.\r | |
379 | @param VendorGuid Vendor GUID to be found.\r | |
380 | @param PtrTrack VARIABLE_POINTER_TRACK structure for output,\r | |
381 | including the range searched and the target position.\r | |
382 | @param Global Pointer to VARIABLE_GLOBAL structure, including\r | |
383 | base of volatile variable storage area, base of\r | |
384 | NV variable storage area, and a lock.\r | |
385 | @param IgnoreRtCheck Ignore EFI_VARIABLE_RUNTIME_ACCESS attribute\r | |
386 | check at runtime when searching variable.\r | |
387 | \r | |
388 | @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while\r | |
389 | VendorGuid is NULL.\r | |
390 | @retval EFI_SUCCESS Variable successfully found.\r | |
391 | @retval EFI_NOT_FOUND Variable not found\r | |
392 | \r | |
393 | **/\r | |
394 | EFI_STATUS\r | |
395 | FindVariable (\r | |
396 | IN CHAR16 *VariableName,\r | |
397 | IN EFI_GUID *VendorGuid,\r | |
398 | OUT VARIABLE_POINTER_TRACK *PtrTrack,\r | |
399 | IN VARIABLE_GLOBAL *Global,\r | |
400 | IN BOOLEAN IgnoreRtCheck\r | |
401 | );\r | |
402 | \r | |
8a2d4996 | 403 | /**\r |
404 | \r | |
405 | This code finds variable in storage blocks (Volatile or Non-Volatile).\r | |
406 | \r | |
407 | @param VariableName Name of Variable to be found.\r | |
408 | @param VendorGuid Variable vendor GUID.\r | |
409 | @param Attributes Attribute value of the variable found.\r | |
410 | @param DataSize Size of Data found. If size is less than the\r | |
411 | data, this value contains the required size.\r | |
412 | @param Data Data pointer.\r | |
413 | \r | |
414 | @return EFI_INVALID_PARAMETER Invalid parameter.\r | |
415 | @return EFI_SUCCESS Find the specified variable.\r | |
416 | @return EFI_NOT_FOUND Not found.\r | |
417 | @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.\r | |
418 | \r | |
419 | **/\r | |
420 | EFI_STATUS\r | |
421 | EFIAPI\r | |
422 | VariableServiceGetVariable (\r | |
423 | IN CHAR16 *VariableName,\r | |
424 | IN EFI_GUID *VendorGuid,\r | |
425 | OUT UINT32 *Attributes OPTIONAL,\r | |
426 | IN OUT UINTN *DataSize,\r | |
427 | OUT VOID *Data\r | |
428 | );\r | |
429 | \r | |
430 | /**\r | |
431 | \r | |
432 | This code Finds the Next available variable.\r | |
433 | \r | |
efb01a10 SZ |
434 | Caution: This function may receive untrusted input.\r |
435 | This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r | |
436 | \r | |
8a2d4996 | 437 | @param VariableNameSize Size of the variable name.\r |
438 | @param VariableName Pointer to variable name.\r | |
439 | @param VendorGuid Variable Vendor Guid.\r | |
440 | \r | |
441 | @return EFI_INVALID_PARAMETER Invalid parameter.\r | |
442 | @return EFI_SUCCESS Find the specified variable.\r | |
443 | @return EFI_NOT_FOUND Not found.\r | |
444 | @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.\r | |
445 | \r | |
446 | **/\r | |
447 | EFI_STATUS\r | |
448 | EFIAPI\r | |
449 | VariableServiceGetNextVariableName (\r | |
450 | IN OUT UINTN *VariableNameSize,\r | |
451 | IN OUT CHAR16 *VariableName,\r | |
452 | IN OUT EFI_GUID *VendorGuid\r | |
453 | );\r | |
454 | \r | |
455 | /**\r | |
456 | \r | |
457 | This code sets variable in storage blocks (Volatile or Non-Volatile).\r | |
458 | \r | |
efb01a10 SZ |
459 | Caution: This function may receive untrusted input.\r |
460 | This function may be invoked in SMM mode, and datasize and data are external input.\r | |
461 | This function will do basic validation, before parse the data.\r | |
462 | \r | |
8a2d4996 | 463 | @param VariableName Name of Variable to be found.\r |
464 | @param VendorGuid Variable vendor GUID.\r | |
465 | @param Attributes Attribute value of the variable found\r | |
466 | @param DataSize Size of Data found. If size is less than the\r | |
467 | data, this value contains the required size.\r | |
468 | @param Data Data pointer.\r | |
469 | \r | |
470 | @return EFI_INVALID_PARAMETER Invalid parameter.\r | |
471 | @return EFI_SUCCESS Set successfully.\r | |
472 | @return EFI_OUT_OF_RESOURCES Resource not enough to set variable.\r | |
473 | @return EFI_NOT_FOUND Not found.\r | |
474 | @return EFI_WRITE_PROTECTED Variable is read-only.\r | |
475 | \r | |
476 | **/\r | |
477 | EFI_STATUS\r | |
478 | EFIAPI\r | |
479 | VariableServiceSetVariable (\r | |
480 | IN CHAR16 *VariableName,\r | |
481 | IN EFI_GUID *VendorGuid,\r | |
482 | IN UINT32 Attributes,\r | |
483 | IN UINTN DataSize,\r | |
484 | IN VOID *Data\r | |
485 | );\r | |
486 | \r | |
b2bd493e SZ |
487 | /**\r |
488 | \r | |
489 | This code returns information about the EFI variables.\r | |
490 | \r | |
efb01a10 SZ |
491 | Caution: This function may receive untrusted input.\r |
492 | This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r | |
493 | \r | |
b2bd493e SZ |
494 | @param Attributes Attributes bitmask to specify the type of variables\r |
495 | on which to return information.\r | |
496 | @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available\r | |
497 | for the EFI variables associated with the attributes specified.\r | |
498 | @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available\r | |
499 | for EFI variables associated with the attributes specified.\r | |
500 | @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables\r | |
501 | associated with the attributes specified.\r | |
502 | \r | |
503 | @return EFI_SUCCESS Query successfully.\r | |
504 | \r | |
505 | **/\r | |
506 | EFI_STATUS\r | |
507 | EFIAPI\r | |
508 | VariableServiceQueryVariableInfoInternal (\r | |
509 | IN UINT32 Attributes,\r | |
510 | OUT UINT64 *MaximumVariableStorageSize,\r | |
511 | OUT UINT64 *RemainingVariableStorageSize,\r | |
512 | OUT UINT64 *MaximumVariableSize\r | |
513 | );\r | |
514 | \r | |
8a2d4996 | 515 | /**\r |
516 | \r | |
517 | This code returns information about the EFI variables.\r | |
518 | \r | |
efb01a10 SZ |
519 | Caution: This function may receive untrusted input.\r |
520 | This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r | |
521 | \r | |
8a2d4996 | 522 | @param Attributes Attributes bitmask to specify the type of variables\r |
523 | on which to return information.\r | |
524 | @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available\r | |
525 | for the EFI variables associated with the attributes specified.\r | |
526 | @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available\r | |
527 | for EFI variables associated with the attributes specified.\r | |
528 | @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables\r | |
529 | associated with the attributes specified.\r | |
530 | \r | |
531 | @return EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.\r | |
532 | @return EFI_SUCCESS Query successfully.\r | |
533 | @return EFI_UNSUPPORTED The attribute is not supported on this platform.\r | |
534 | \r | |
535 | **/\r | |
536 | EFI_STATUS\r | |
537 | EFIAPI\r | |
538 | VariableServiceQueryVariableInfo (\r | |
539 | IN UINT32 Attributes,\r | |
540 | OUT UINT64 *MaximumVariableStorageSize,\r | |
541 | OUT UINT64 *RemainingVariableStorageSize,\r | |
542 | OUT UINT64 *MaximumVariableSize\r | |
543 | ); \r | |
ff843847 RN |
544 | \r |
545 | /**\r | |
546 | Mark a variable that will become read-only after leaving the DXE phase of execution.\r | |
547 | \r | |
548 | @param[in] This The VARIABLE_LOCK_PROTOCOL instance.\r | |
549 | @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.\r | |
550 | @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.\r | |
551 | \r | |
552 | @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked\r | |
553 | as pending to be read-only.\r | |
554 | @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.\r | |
555 | Or VariableName is an empty string.\r | |
556 | @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has\r | |
557 | already been signaled.\r | |
558 | @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.\r | |
559 | **/\r | |
560 | EFI_STATUS\r | |
561 | EFIAPI\r | |
562 | VariableLockRequestToLock (\r | |
563 | IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,\r | |
564 | IN CHAR16 *VariableName,\r | |
565 | IN EFI_GUID *VendorGuid\r | |
566 | );\r | |
567 | \r | |
efb01a10 SZ |
568 | /**\r |
569 | Check if a Unicode character is a hexadecimal character.\r | |
570 | \r | |
571 | This function checks if a Unicode character is a\r | |
572 | hexadecimal character. The valid hexadecimal character is\r | |
573 | L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r | |
574 | \r | |
575 | \r | |
576 | @param Char The character to check against.\r | |
577 | \r | |
578 | @retval TRUE If the Char is a hexadecmial character.\r | |
579 | @retval FALSE If the Char is not a hexadecmial character.\r | |
580 | \r | |
581 | **/\r | |
582 | BOOLEAN\r | |
583 | EFIAPI\r | |
584 | IsHexaDecimalDigitCharacter (\r | |
585 | IN CHAR16 Char\r | |
586 | );\r | |
587 | \r | |
588 | /**\r | |
589 | Internal SetVariable check.\r | |
590 | \r | |
591 | @param[in] VariableName Name of Variable to set.\r | |
592 | @param[in] VendorGuid Variable vendor GUID.\r | |
593 | @param[in] Attributes Attribute value of the variable.\r | |
594 | @param[in] DataSize Size of Data to set.\r | |
595 | @param[in] Data Data pointer.\r | |
596 | \r | |
597 | @retval EFI_SUCCESS The SetVariable check result was success.\r | |
598 | @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID were supplied,\r | |
599 | or the DataSize exceeds the minimum or maximum allowed,\r | |
600 | or the Data value is not following UEFI spec for UEFI defined variables.\r | |
601 | @retval EFI_WRITE_PROTECTED The variable in question is read-only.\r | |
602 | @retval Others The return status from check handler.\r | |
603 | \r | |
604 | **/\r | |
605 | EFI_STATUS\r | |
606 | EFIAPI\r | |
607 | InternalVarCheckSetVariableCheck (\r | |
608 | IN CHAR16 *VariableName,\r | |
609 | IN EFI_GUID *VendorGuid,\r | |
610 | IN UINT32 Attributes,\r | |
611 | IN UINTN DataSize,\r | |
612 | IN VOID *Data\r | |
613 | );\r | |
614 | \r | |
615 | /**\r | |
616 | Register SetVariable check handler.\r | |
617 | \r | |
618 | @param[in] Handler Pointer to check handler.\r | |
619 | \r | |
620 | @retval EFI_SUCCESS The SetVariable check handler was registered successfully.\r | |
621 | @retval EFI_INVALID_PARAMETER Handler is NULL.\r | |
622 | @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has\r | |
623 | already been signaled.\r | |
624 | @retval EFI_OUT_OF_RESOURCES There is not enough resource for the SetVariable check handler register request.\r | |
625 | @retval EFI_UNSUPPORTED This interface is not implemented.\r | |
626 | For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.\r | |
627 | \r | |
628 | **/\r | |
629 | EFI_STATUS\r | |
630 | EFIAPI\r | |
631 | VarCheckRegisterSetVariableCheckHandler (\r | |
632 | IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler\r | |
633 | );\r | |
634 | \r | |
635 | /**\r | |
636 | Variable property set.\r | |
637 | \r | |
638 | @param[in] Name Pointer to the variable name.\r | |
639 | @param[in] Guid Pointer to the vendor GUID.\r | |
640 | @param[in] VariableProperty Pointer to the input variable property.\r | |
641 | \r | |
642 | @retval EFI_SUCCESS The property of variable specified by the Name and Guid was set successfully.\r | |
643 | @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,\r | |
644 | or the fields of VariableProperty are not valid.\r | |
645 | @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has\r | |
646 | already been signaled.\r | |
647 | @retval EFI_OUT_OF_RESOURCES There is not enough resource for the variable property set request.\r | |
648 | \r | |
649 | **/\r | |
650 | EFI_STATUS\r | |
651 | EFIAPI\r | |
652 | VarCheckVariablePropertySet (\r | |
653 | IN CHAR16 *Name,\r | |
654 | IN EFI_GUID *Guid,\r | |
655 | IN VAR_CHECK_VARIABLE_PROPERTY *VariableProperty\r | |
656 | );\r | |
657 | \r | |
4edb1866 SZ |
658 | /**\r |
659 | Internal variable property get.\r | |
660 | \r | |
661 | @param[in] Name Pointer to the variable name.\r | |
662 | @param[in] Guid Pointer to the vendor GUID.\r | |
663 | @param[out] VariableProperty Pointer to the output variable property.\r | |
664 | \r | |
665 | @retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.\r | |
666 | @retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.\r | |
667 | \r | |
668 | **/\r | |
669 | EFI_STATUS\r | |
670 | EFIAPI\r | |
671 | InternalVarCheckVariablePropertyGet (\r | |
672 | IN CHAR16 *Name,\r | |
673 | IN EFI_GUID *Guid,\r | |
674 | OUT VAR_CHECK_VARIABLE_PROPERTY *VariableProperty\r | |
675 | );\r | |
676 | \r | |
efb01a10 SZ |
677 | /**\r |
678 | Variable property get.\r | |
679 | \r | |
680 | @param[in] Name Pointer to the variable name.\r | |
681 | @param[in] Guid Pointer to the vendor GUID.\r | |
682 | @param[out] VariableProperty Pointer to the output variable property.\r | |
683 | \r | |
684 | @retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.\r | |
685 | @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.\r | |
686 | @retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.\r | |
687 | \r | |
688 | **/\r | |
689 | EFI_STATUS\r | |
690 | EFIAPI\r | |
691 | VarCheckVariablePropertyGet (\r | |
692 | IN CHAR16 *Name,\r | |
693 | IN EFI_GUID *Guid,\r | |
694 | OUT VAR_CHECK_VARIABLE_PROPERTY *VariableProperty\r | |
695 | );\r | |
696 | \r | |
4edb1866 SZ |
697 | /**\r |
698 | Initialize variable quota.\r | |
699 | \r | |
700 | **/\r | |
701 | VOID\r | |
702 | InitializeVariableQuota (\r | |
703 | VOID\r | |
704 | );\r | |
705 | \r | |
8a2d4996 | 706 | extern VARIABLE_MODULE_GLOBAL *mVariableModuleGlobal;\r |
707 | \r | |
8d3a5c82 | 708 | #endif\r |