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