]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.h
Calculate enough space for 2 variables (public key and variable data) instead of...
[mirror_edk2.git] / SecurityPkg / VariableAuthenticated / RuntimeDxe / Variable.h
CommitLineData
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
b2bd493e 5Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
0c18794e 6This program and the accompanying materials \r
7are licensed and made available under the terms and conditions of the BSD License \r
8which accompanies this distribution. The full text of the license may be found at \r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
12WITHOUT 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
59typedef 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
69typedef enum {\r
70 VariableStoreTypeVolatile,\r
71 VariableStoreTypeHob,\r
72 VariableStoreTypeNv,\r
73 VariableStoreTypeMax\r
74} VARIABLE_STORE_TYPE;\r
75\r
0c18794e 76typedef 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
90typedef 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
98typedef 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
111typedef struct {\r
112 EFI_GUID *Guid;\r
113 CHAR16 *Name;\r
b2bd493e
SZ
114 UINTN VariableSize;\r
115} VARIABLE_ENTRY_CONSISTENCY;\r
0c18794e 116\r
6ab9f441
RN
117typedef struct {\r
118 EFI_GUID Guid;\r
119 CHAR16 *Name;\r
120 LIST_ENTRY Link;\r
121} VARIABLE_ENTRY;\r
122\r
335e2681
SZ
123/**\r
124 Flush the HOB variable to flash.\r
125\r
126 @param[in] VariableName Name of variable has been updated or deleted.\r
127 @param[in] VendorGuid Guid of variable has been updated or deleted.\r
128\r
129**/\r
130VOID\r
131FlushHobVariableToFlash (\r
132 IN CHAR16 *VariableName,\r
133 IN EFI_GUID *VendorGuid\r
134 );\r
135\r
0c18794e 136/**\r
137 Writes a buffer to variable storage space, in the working block.\r
138\r
139 This function writes a buffer to variable storage space into a firmware\r
140 volume block device. The destination is specified by the parameter\r
141 VariableBase. Fault Tolerant Write protocol is used for writing.\r
142\r
143 @param VariableBase Base address of the variable to write.\r
128ef095 144 @param VariableBuffer Point to the variable data buffer.\r
0c18794e 145\r
146 @retval EFI_SUCCESS The function completed successfully.\r
147 @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol.\r
148 @retval EFI_ABORTED The function could not complete successfully.\r
149\r
150**/\r
151EFI_STATUS\r
152FtwVariableSpace (\r
153 IN EFI_PHYSICAL_ADDRESS VariableBase,\r
128ef095 154 IN VARIABLE_STORE_HEADER *VariableBuffer\r
0c18794e 155 );\r
156\r
157/**\r
158 Finds variable in storage blocks of volatile and non-volatile storage areas.\r
159\r
160 This code finds variable in storage blocks of volatile and non-volatile storage areas.\r
161 If VariableName is an empty string, then we just return the first\r
162 qualified variable without comparing VariableName and VendorGuid.\r
9622df63
SZ
163 If IgnoreRtCheck is TRUE, then we ignore the EFI_VARIABLE_RUNTIME_ACCESS attribute check\r
164 at runtime when searching existing variable, only VariableName and VendorGuid are compared.\r
165 Otherwise, variables without EFI_VARIABLE_RUNTIME_ACCESS are not visible at runtime.\r
0c18794e 166\r
ecc722ad 167 @param[in] VariableName Name of the variable to be found.\r
168 @param[in] VendorGuid Vendor GUID to be found.\r
169 @param[out] PtrTrack VARIABLE_POINTER_TRACK structure for output,\r
0c18794e 170 including the range searched and the target position.\r
ecc722ad 171 @param[in] Global Pointer to VARIABLE_GLOBAL structure, including\r
0c18794e 172 base of volatile variable storage area, base of\r
173 NV variable storage area, and a lock.\r
9622df63
SZ
174 @param[in] IgnoreRtCheck Ignore EFI_VARIABLE_RUNTIME_ACCESS attribute\r
175 check at runtime when searching variable.\r
0c18794e 176\r
177 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while\r
178 VendorGuid is NULL.\r
179 @retval EFI_SUCCESS Variable successfully found.\r
ecc722ad 180 @retval EFI_NOT_FOUND Variable not found\r
0c18794e 181\r
182**/\r
183EFI_STATUS\r
184FindVariable (\r
185 IN CHAR16 *VariableName,\r
186 IN EFI_GUID *VendorGuid,\r
187 OUT VARIABLE_POINTER_TRACK *PtrTrack,\r
ecc722ad 188 IN VARIABLE_GLOBAL *Global,\r
9622df63 189 IN BOOLEAN IgnoreRtCheck\r
0c18794e 190 );\r
191\r
192/**\r
193\r
194 This code gets the pointer to the variable data.\r
195\r
196 @param Variable Pointer to the Variable Header.\r
197\r
198 @return Pointer to Variable Data.\r
199\r
200**/\r
201UINT8 *\r
202GetVariableDataPtr (\r
203 IN VARIABLE_HEADER *Variable\r
204 );\r
205\r
206/**\r
207\r
208 This code gets the size of variable data.\r
209\r
210 @param Variable Pointer to the Variable Header.\r
211\r
212 @return Size of variable in bytes.\r
213\r
214**/\r
215UINTN\r
216DataSizeOfVariable (\r
217 IN VARIABLE_HEADER *Variable\r
218 );\r
219\r
9a12e582
DG
220/**\r
221 This function is to check if the remaining variable space is enough to set\r
222 all Variables from argument list successfully. The purpose of the check\r
223 is to keep the consistency of the Variables to be in variable storage.\r
224\r
225 Note: Variables are assumed to be in same storage.\r
226 The set sequence of Variables will be same with the sequence of VariableEntry from argument list,\r
227 so follow the argument sequence to check the Variables.\r
228\r
229 @param[in] Attributes Variable attributes for Variable entries.\r
230 @param ... The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.\r
231 A NULL terminates the list. The VariableSize of \r
232 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.\r
233 It will be changed to variable total size as output.\r
234\r
235 @retval TRUE Have enough variable space to set the Variables successfully.\r
236 @retval FALSE No enough variable space to set the Variables successfully.\r
237\r
238**/\r
239BOOLEAN\r
240EFIAPI\r
241CheckRemainingSpaceForConsistency (\r
242 IN UINT32 Attributes,\r
243 ...\r
244 );\r
245 \r
0c18794e 246/**\r
247 Update the variable region with Variable information. If EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is set,\r
248 index of associated public key is needed.\r
249\r
250 @param[in] VariableName Name of variable.\r
251 @param[in] VendorGuid Guid of variable.\r
252 @param[in] Data Variable data.\r
253 @param[in] DataSize Size of data. 0 means delete.\r
254 @param[in] Attributes Attributes of the variable.\r
255 @param[in] KeyIndex Index of associated public key.\r
256 @param[in] MonotonicCount Value of associated monotonic count.\r
23b06935 257 @param[in, out] Variable The variable information that is used to keep track of variable usage.\r
0c18794e 258\r
259 @param[in] TimeStamp Value of associated TimeStamp.\r
260\r
261 @retval EFI_SUCCESS The update operation is success.\r
262 @retval EFI_OUT_OF_RESOURCES Variable region is full, cannot write other data into this region.\r
263\r
264**/\r
265EFI_STATUS\r
266UpdateVariable (\r
267 IN CHAR16 *VariableName,\r
268 IN EFI_GUID *VendorGuid,\r
269 IN VOID *Data,\r
270 IN UINTN DataSize,\r
271 IN UINT32 Attributes OPTIONAL,\r
272 IN UINT32 KeyIndex OPTIONAL,\r
273 IN UINT64 MonotonicCount OPTIONAL,\r
23b06935 274 IN OUT VARIABLE_POINTER_TRACK *Variable,\r
0c18794e 275 IN EFI_TIME *TimeStamp OPTIONAL \r
276 );\r
277\r
278\r
279/**\r
280 Return TRUE if ExitBootServices () has been called.\r
281 \r
282 @retval TRUE If ExitBootServices () has been called.\r
283**/\r
284BOOLEAN\r
285AtRuntime (\r
286 VOID\r
287 );\r
288\r
289/**\r
290 Initializes a basic mutual exclusion lock.\r
291\r
292 This function initializes a basic mutual exclusion lock to the released state \r
293 and returns the lock. Each lock provides mutual exclusion access at its task \r
294 priority level. Since there is no preemption or multiprocessor support in EFI,\r
295 acquiring the lock only consists of raising to the locks TPL.\r
296 If Lock is NULL, then ASSERT().\r
297 If Priority is not a valid TPL value, then ASSERT().\r
298\r
299 @param Lock A pointer to the lock data structure to initialize.\r
300 @param Priority EFI TPL is associated with the lock.\r
301\r
302 @return The lock.\r
303\r
304**/\r
305EFI_LOCK *\r
306InitializeLock (\r
307 IN OUT EFI_LOCK *Lock,\r
308 IN EFI_TPL Priority\r
309 );\r
310\r
311 \r
312/**\r
313 Acquires lock only at boot time. Simply returns at runtime.\r
314\r
315 This is a temperary function that will be removed when\r
316 EfiAcquireLock() in UefiLib can handle the call in UEFI\r
317 Runtimer driver in RT phase.\r
318 It calls EfiAcquireLock() at boot time, and simply returns\r
319 at runtime.\r
320\r
321 @param Lock A pointer to the lock to acquire.\r
322\r
323**/\r
324VOID\r
325AcquireLockOnlyAtBootTime (\r
326 IN EFI_LOCK *Lock\r
327 );\r
328\r
329\r
330/**\r
331 Releases lock only at boot time. Simply returns at runtime.\r
332\r
333 This is a temperary function which will be removed when\r
334 EfiReleaseLock() in UefiLib can handle the call in UEFI\r
335 Runtimer driver in RT phase.\r
336 It calls EfiReleaseLock() at boot time and simply returns\r
337 at runtime.\r
338\r
339 @param Lock A pointer to the lock to release.\r
340\r
341**/\r
342VOID\r
343ReleaseLockOnlyAtBootTime (\r
344 IN EFI_LOCK *Lock\r
345 ); \r
346\r
347/**\r
348 Retrive the FVB protocol interface by HANDLE.\r
349\r
350 @param[in] FvBlockHandle The handle of FVB protocol that provides services for\r
351 reading, writing, and erasing the target block.\r
352 @param[out] FvBlock The interface of FVB protocol\r
353\r
354 @retval EFI_SUCCESS The interface information for the specified protocol was returned.\r
355 @retval EFI_UNSUPPORTED The device does not support the FVB protocol.\r
356 @retval EFI_INVALID_PARAMETER FvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.\r
357 \r
358**/\r
359EFI_STATUS\r
360GetFvbByHandle (\r
361 IN EFI_HANDLE FvBlockHandle,\r
362 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r
363 );\r
364\r
365\r
366/**\r
367 Retrive the Swap Address Range protocol interface.\r
368\r
369 @param[out] SarProtocol The interface of SAR protocol\r
370\r
371 @retval EFI_SUCCESS The SAR protocol instance was found and returned in SarProtocol.\r
372 @retval EFI_NOT_FOUND The SAR protocol instance was not found.\r
373 @retval EFI_INVALID_PARAMETER SarProtocol is NULL.\r
374\r
375**/\r
376EFI_STATUS\r
377GetSarProtocol (\r
378 OUT VOID **SarProtocol\r
379 );\r
380\r
381/**\r
382 Function returns an array of handles that support the FVB protocol\r
383 in a buffer allocated from pool. \r
384\r
385 @param[out] NumberHandles The number of handles returned in Buffer.\r
386 @param[out] Buffer A pointer to the buffer to return the requested\r
387 array of handles that support FVB protocol.\r
388\r
389 @retval EFI_SUCCESS The array of handles was returned in Buffer, and the number of\r
390 handles in Buffer was returned in NumberHandles.\r
391 @retval EFI_NOT_FOUND No FVB handle was found.\r
392 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results.\r
393 @retval EFI_INVALID_PARAMETER NumberHandles is NULL or Buffer is NULL.\r
394 \r
395**/\r
396EFI_STATUS\r
397GetFvbCountAndBuffer (\r
398 OUT UINTN *NumberHandles,\r
399 OUT EFI_HANDLE **Buffer\r
400 );\r
401\r
402/**\r
403 Initializes variable store area for non-volatile and volatile variable.\r
404\r
405 @retval EFI_SUCCESS Function successfully executed.\r
406 @retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.\r
407\r
408**/\r
409EFI_STATUS\r
410VariableCommonInitialize (\r
411 VOID\r
412 );\r
413\r
83758cdc 414/**\r
415\r
416 Variable store garbage collection and reclaim operation.\r
417\r
418 If ReclaimPubKeyStore is FALSE, reclaim variable space by deleting the obsoleted varaibles.\r
419 If ReclaimPubKeyStore is TRUE, reclaim invalid key in public key database and update the PubKeyIndex\r
420 for all the count-based authenticate variable in NV storage.\r
421\r
ca5a7d87 422 @param[in] VariableBase Base address of variable store.\r
423 @param[out] LastVariableOffset Offset of last variable.\r
424 @param[in] IsVolatile The variable store is volatile or not;\r
425 if it is non-volatile, need FTW.\r
426 @param[in, out] UpdatingPtrTrack Pointer to updating variable pointer track structure.\r
7baf3c69
SZ
427 @param[in] NewVariable Pointer to new variable.\r
428 @param[in] NewVariableSize New variable size.\r
ca5a7d87 429 @param[in] ReclaimPubKeyStore Reclaim for public key database or not.\r
83758cdc 430 \r
83758cdc 431 @return EFI_SUCCESS Reclaim operation has finished successfully.\r
7baf3c69 432 @return EFI_OUT_OF_RESOURCES No enough memory resources or variable space.\r
ca5a7d87 433 @return EFI_DEVICE_ERROR The public key database doesn't exist.\r
83758cdc 434 @return Others Unexpect error happened during reclaim operation.\r
435\r
436**/\r
437EFI_STATUS\r
438Reclaim (\r
ca5a7d87 439 IN EFI_PHYSICAL_ADDRESS VariableBase,\r
440 OUT UINTN *LastVariableOffset,\r
441 IN BOOLEAN IsVolatile,\r
442 IN OUT VARIABLE_POINTER_TRACK *UpdatingPtrTrack,\r
7baf3c69
SZ
443 IN VARIABLE_HEADER *NewVariable,\r
444 IN UINTN NewVariableSize,\r
445 IN BOOLEAN ReclaimPubKeyStore\r
83758cdc 446 );\r
447\r
0c18794e 448/**\r
449 This function reclaims variable storage if free size is below the threshold.\r
450 \r
451**/\r
452VOID\r
453ReclaimForOS(\r
454 VOID\r
455 ); \r
456\r
457\r
458/**\r
459 Initializes variable write service after FVB was ready.\r
460\r
461 @retval EFI_SUCCESS Function successfully executed.\r
462 @retval Others Fail to initialize the variable service.\r
463\r
464**/\r
465EFI_STATUS\r
466VariableWriteServiceInitialize (\r
467 VOID\r
468 );\r
469 \r
470/**\r
471 Retrive the SMM Fault Tolerent Write protocol interface.\r
472\r
473 @param[out] FtwProtocol The interface of SMM Ftw protocol\r
474\r
475 @retval EFI_SUCCESS The SMM SAR protocol instance was found and returned in SarProtocol.\r
476 @retval EFI_NOT_FOUND The SMM SAR protocol instance was not found.\r
477 @retval EFI_INVALID_PARAMETER SarProtocol is NULL.\r
478\r
479**/\r
480EFI_STATUS\r
481GetFtwProtocol (\r
482 OUT VOID **FtwProtocol\r
483 );\r
484\r
485/**\r
486 Get the proper fvb handle and/or fvb protocol by the given Flash address.\r
487\r
488 @param[in] Address The Flash address.\r
489 @param[out] FvbHandle In output, if it is not NULL, it points to the proper FVB handle.\r
490 @param[out] FvbProtocol In output, if it is not NULL, it points to the proper FVB protocol.\r
491\r
492**/\r
493EFI_STATUS\r
494GetFvbInfoByAddress (\r
495 IN EFI_PHYSICAL_ADDRESS Address,\r
496 OUT EFI_HANDLE *FvbHandle OPTIONAL,\r
497 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvbProtocol OPTIONAL\r
498 );\r
499\r
500/**\r
501\r
502 This code finds variable in storage blocks (Volatile or Non-Volatile).\r
503\r
dc204d5a
JY
504 Caution: This function may receive untrusted input.\r
505 This function may be invoked in SMM mode, and datasize and data are external input.\r
506 This function will do basic validation, before parse the data.\r
507\r
0c18794e 508 @param VariableName Name of Variable to be found.\r
509 @param VendorGuid Variable vendor GUID.\r
510 @param Attributes Attribute value of the variable found.\r
511 @param DataSize Size of Data found. If size is less than the\r
512 data, this value contains the required size.\r
513 @param Data Data pointer.\r
514 \r
515 @return EFI_INVALID_PARAMETER Invalid parameter.\r
516 @return EFI_SUCCESS Find the specified variable.\r
517 @return EFI_NOT_FOUND Not found.\r
518 @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.\r
519\r
520**/\r
521EFI_STATUS\r
522EFIAPI\r
523VariableServiceGetVariable (\r
524 IN CHAR16 *VariableName,\r
525 IN EFI_GUID *VendorGuid,\r
526 OUT UINT32 *Attributes OPTIONAL,\r
527 IN OUT UINTN *DataSize,\r
528 OUT VOID *Data\r
529 );\r
530\r
531/**\r
532\r
533 This code Finds the Next available variable.\r
534\r
dc204d5a
JY
535 Caution: This function may receive untrusted input.\r
536 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r
537\r
0c18794e 538 @param VariableNameSize Size of the variable name.\r
539 @param VariableName Pointer to variable name.\r
540 @param VendorGuid Variable Vendor Guid.\r
541\r
542 @return EFI_INVALID_PARAMETER Invalid parameter.\r
543 @return EFI_SUCCESS Find the specified variable.\r
544 @return EFI_NOT_FOUND Not found.\r
545 @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.\r
546\r
547**/\r
548EFI_STATUS\r
549EFIAPI\r
550VariableServiceGetNextVariableName (\r
551 IN OUT UINTN *VariableNameSize,\r
552 IN OUT CHAR16 *VariableName,\r
553 IN OUT EFI_GUID *VendorGuid\r
554 );\r
555\r
556/**\r
557\r
558 This code sets variable in storage blocks (Volatile or Non-Volatile).\r
559\r
dc204d5a
JY
560 Caution: This function may receive untrusted input.\r
561 This function may be invoked in SMM mode, and datasize and data are external input.\r
562 This function will do basic validation, before parse the data.\r
563 This function will parse the authentication carefully to avoid security issues, like\r
564 buffer overflow, integer overflow.\r
565 This function will check attribute carefully to avoid authentication bypass.\r
566\r
0c18794e 567 @param VariableName Name of Variable to be found.\r
568 @param VendorGuid Variable vendor GUID.\r
569 @param Attributes Attribute value of the variable found\r
570 @param DataSize Size of Data found. If size is less than the\r
571 data, this value contains the required size.\r
572 @param Data Data pointer.\r
573\r
574 @return EFI_INVALID_PARAMETER Invalid parameter.\r
575 @return EFI_SUCCESS Set successfully.\r
576 @return EFI_OUT_OF_RESOURCES Resource not enough to set variable.\r
577 @return EFI_NOT_FOUND Not found.\r
578 @return EFI_WRITE_PROTECTED Variable is read-only.\r
579\r
580**/\r
581EFI_STATUS\r
582EFIAPI\r
583VariableServiceSetVariable (\r
584 IN CHAR16 *VariableName,\r
585 IN EFI_GUID *VendorGuid,\r
586 IN UINT32 Attributes,\r
587 IN UINTN DataSize,\r
588 IN VOID *Data\r
589 );\r
590\r
b2bd493e
SZ
591/**\r
592\r
593 This code returns information about the EFI variables.\r
594\r
595 Caution: This function may receive untrusted input.\r
596 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r
597\r
598 @param Attributes Attributes bitmask to specify the type of variables\r
599 on which to return information.\r
600 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available\r
601 for the EFI variables associated with the attributes specified.\r
602 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available\r
603 for EFI variables associated with the attributes specified.\r
604 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables\r
605 associated with the attributes specified.\r
606\r
607 @return EFI_SUCCESS Query successfully.\r
608\r
609**/\r
610EFI_STATUS\r
611EFIAPI\r
612VariableServiceQueryVariableInfoInternal (\r
613 IN UINT32 Attributes,\r
614 OUT UINT64 *MaximumVariableStorageSize,\r
615 OUT UINT64 *RemainingVariableStorageSize,\r
616 OUT UINT64 *MaximumVariableSize\r
617 );\r
618\r
0c18794e 619/**\r
620\r
621 This code returns information about the EFI variables.\r
622\r
dc204d5a
JY
623 Caution: This function may receive untrusted input.\r
624 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r
625\r
0c18794e 626 @param Attributes Attributes bitmask to specify the type of variables\r
627 on which to return information.\r
628 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available\r
629 for the EFI variables associated with the attributes specified.\r
630 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available\r
631 for EFI variables associated with the attributes specified.\r
632 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables\r
633 associated with the attributes specified.\r
634\r
635 @return EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.\r
636 @return EFI_SUCCESS Query successfully.\r
637 @return EFI_UNSUPPORTED The attribute is not supported on this platform.\r
638\r
639**/\r
640EFI_STATUS\r
641EFIAPI\r
642VariableServiceQueryVariableInfo (\r
643 IN UINT32 Attributes,\r
644 OUT UINT64 *MaximumVariableStorageSize,\r
645 OUT UINT64 *RemainingVariableStorageSize,\r
646 OUT UINT64 *MaximumVariableSize\r
647 ); \r
6ab9f441
RN
648\r
649/**\r
650 Mark a variable that will become read-only after leaving the DXE phase of execution.\r
651\r
652 @param[in] This The VARIABLE_LOCK_PROTOCOL instance.\r
653 @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.\r
654 @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.\r
655\r
656 @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked\r
657 as pending to be read-only.\r
658 @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.\r
659 Or VariableName is an empty string.\r
660 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has\r
661 already been signaled.\r
662 @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.\r
663**/\r
664EFI_STATUS\r
665EFIAPI\r
666VariableLockRequestToLock (\r
667 IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,\r
668 IN CHAR16 *VariableName,\r
669 IN EFI_GUID *VendorGuid\r
670 );\r
671\r
0c18794e 672extern VARIABLE_MODULE_GLOBAL *mVariableModuleGlobal;\r
673\r
674#endif\r