]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/VariableAuthenticated/Pei/Variable.c
f637675157791838f2eec9bdeca44bf0c255b5aa
[mirror_edk2.git] / SecurityPkg / VariableAuthenticated / Pei / Variable.c
1 /** @file
2 Implement ReadOnly Variable Services required by PEIM and install PEI
3 ReadOnly Varaiable2 PPI. These services operates the non-volatile
4 storage space.
5
6 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17
18 #include "Variable.h"
19
20 //
21 // Module globals
22 //
23 EFI_PEI_READ_ONLY_VARIABLE2_PPI mVariablePpi = {
24 PeiGetVariable,
25 PeiGetNextVariableName
26 };
27
28 EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {
29 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
30 &gEfiPeiReadOnlyVariable2PpiGuid,
31 &mVariablePpi
32 };
33
34
35 /**
36 Check if it runs in Recovery mode.
37
38 @param PeiServices General purpose services available to every PEIM.
39
40 @retval TRUE It's in Recovery mode.
41 @retval FALSE It's not in Recovery mode.
42
43 **/
44 BOOLEAN
45 IsInRecoveryMode (
46 IN CONST EFI_PEI_SERVICES **PeiServices
47 )
48 {
49 EFI_STATUS Status;
50 EFI_BOOT_MODE BootMode;
51
52 Status = (*PeiServices)->GetBootMode (PeiServices, &BootMode);
53 ASSERT_EFI_ERROR (Status);
54
55 if (BootMode == BOOT_IN_RECOVERY_MODE) {
56 return TRUE;
57 }
58 return FALSE;
59 }
60
61 /**
62 Provide the functionality of the variable services.
63
64 @param FileHandle Handle of the file being invoked.
65 Type EFI_PEI_FILE_HANDLE is defined in FfsFindNextFile().
66 @param PeiServices General purpose services available to every PEIM.
67
68 @retval EFI_SUCCESS If the interface could be successfully installed
69 @retval Others Returned from PeiServicesInstallPpi()
70
71 **/
72 EFI_STATUS
73 EFIAPI
74 PeimInitializeVariableServices (
75 IN EFI_PEI_FILE_HANDLE FileHandle,
76 IN CONST EFI_PEI_SERVICES **PeiServices
77 )
78 {
79 return PeiServicesInstallPpi (&mPpiListVariable);
80 }
81
82 /**
83
84 Gets the pointer to the first variable header in given variable store area.
85
86 @param VarStoreHeader Pointer to the Variable Store Header.
87
88 @return Pointer to the first variable header
89
90 **/
91 VARIABLE_HEADER *
92 GetStartPointer (
93 IN VARIABLE_STORE_HEADER *VarStoreHeader
94 )
95 {
96 //
97 // The end of variable store
98 //
99 return (VARIABLE_HEADER *) HEADER_ALIGN (VarStoreHeader + 1);
100 }
101
102
103 /**
104 This code gets the pointer to the last variable memory pointer byte.
105
106 @param VarStoreHeader Pointer to the Variable Store Header.
107
108 @return VARIABLE_HEADER* pointer to last unavailable Variable Header.
109
110 **/
111 VARIABLE_HEADER *
112 GetEndPointer (
113 IN VARIABLE_STORE_HEADER *VarStoreHeader
114 )
115 {
116 //
117 // The end of variable store
118 //
119 return (VARIABLE_HEADER *) HEADER_ALIGN ((UINTN) VarStoreHeader + VarStoreHeader->Size);
120 }
121
122
123 /**
124 This code checks if variable header is valid or not.
125
126 @param Variable Pointer to the Variable Header.
127
128 @retval TRUE Variable header is valid.
129 @retval FALSE Variable header is not valid.
130
131 **/
132 BOOLEAN
133 IsValidVariableHeader (
134 IN VARIABLE_HEADER *Variable
135 )
136 {
137 if (Variable == NULL || Variable->StartId != VARIABLE_DATA ) {
138 return FALSE;
139 }
140
141 return TRUE;
142 }
143
144
145 /**
146 This code gets the size of name of variable.
147
148 @param Variable Pointer to the Variable Header.
149
150 @return Size of variable in bytes in type UINTN.
151
152 **/
153 UINTN
154 NameSizeOfVariable (
155 IN VARIABLE_HEADER *Variable
156 )
157 {
158 if (Variable->State == (UINT8) (-1) ||
159 Variable->DataSize == (UINT32) (-1) ||
160 Variable->NameSize == (UINT32) (-1) ||
161 Variable->Attributes == (UINT32) (-1)) {
162 return 0;
163 }
164 return (UINTN) Variable->NameSize;
165 }
166
167
168 /**
169 This code gets the size of data of variable.
170
171 @param Variable Pointer to the Variable Header.
172
173 @return Size of variable in bytes in type UINTN.
174
175 **/
176 UINTN
177 DataSizeOfVariable (
178 IN VARIABLE_HEADER *Variable
179 )
180 {
181 if (Variable->State == (UINT8) (-1) ||
182 Variable->DataSize == (UINT32) (-1) ||
183 Variable->NameSize == (UINT32) (-1) ||
184 Variable->Attributes == (UINT32) (-1)) {
185 return 0;
186 }
187 return (UINTN) Variable->DataSize;
188 }
189
190 /**
191 This code gets the pointer to the variable name.
192
193 @param Variable Pointer to the Variable Header.
194
195 @return A CHAR16* pointer to Variable Name.
196
197 **/
198 CHAR16 *
199 GetVariableNamePtr (
200 IN VARIABLE_HEADER *Variable
201 )
202 {
203
204 return (CHAR16 *) (Variable + 1);
205 }
206
207
208 /**
209 This code gets the pointer to the variable data.
210
211 @param Variable Pointer to the Variable Header.
212
213 @return A UINT8* pointer to Variable Data.
214
215 **/
216 UINT8 *
217 GetVariableDataPtr (
218 IN VARIABLE_HEADER *Variable
219 )
220 {
221 UINTN Value;
222
223 //
224 // Be careful about pad size for alignment
225 //
226 Value = (UINTN) GetVariableNamePtr (Variable);
227 Value += NameSizeOfVariable (Variable);
228 Value += GET_PAD_SIZE (NameSizeOfVariable (Variable));
229
230 return (UINT8 *) Value;
231 }
232
233
234 /**
235 This code gets the pointer to the next variable header.
236
237 @param Variable Pointer to the Variable Header.
238
239 @return A VARIABLE_HEADER* pointer to next variable header.
240
241 **/
242 VARIABLE_HEADER *
243 GetNextVariablePtr (
244 IN VARIABLE_HEADER *Variable
245 )
246 {
247 UINTN Value;
248
249 if (!IsValidVariableHeader (Variable)) {
250 return NULL;
251 }
252
253 Value = (UINTN) GetVariableDataPtr (Variable);
254 Value += DataSizeOfVariable (Variable);
255 Value += GET_PAD_SIZE (DataSizeOfVariable (Variable));
256
257 //
258 // Be careful about pad size for alignment
259 //
260 return (VARIABLE_HEADER *) HEADER_ALIGN (Value);
261 }
262
263 /**
264 This code gets the pointer to the variable name.
265
266 @param VarStoreHeader Pointer to the Variable Store Header.
267
268 @retval EfiRaw Variable store is raw
269 @retval EfiValid Variable store is valid
270 @retval EfiInvalid Variable store is invalid
271
272 **/
273 VARIABLE_STORE_STATUS
274 GetVariableStoreStatus (
275 IN VARIABLE_STORE_HEADER *VarStoreHeader
276 )
277 {
278
279 if (CompareGuid (&VarStoreHeader->Signature, &gEfiAuthenticatedVariableGuid) &&
280 VarStoreHeader->Format == VARIABLE_STORE_FORMATTED &&
281 VarStoreHeader->State == VARIABLE_STORE_HEALTHY
282 ) {
283
284 return EfiValid;
285 }
286
287 if (((UINT32 *)(&VarStoreHeader->Signature))[0] == 0xffffffff &&
288 ((UINT32 *)(&VarStoreHeader->Signature))[1] == 0xffffffff &&
289 ((UINT32 *)(&VarStoreHeader->Signature))[2] == 0xffffffff &&
290 ((UINT32 *)(&VarStoreHeader->Signature))[3] == 0xffffffff &&
291 VarStoreHeader->Size == 0xffffffff &&
292 VarStoreHeader->Format == 0xff &&
293 VarStoreHeader->State == 0xff
294 ) {
295
296 return EfiRaw;
297 } else {
298 return EfiInvalid;
299 }
300 }
301
302
303 /**
304 This function compares a variable with variable entries in database.
305
306 @param Variable Pointer to the variable in our database
307 @param VariableName Name of the variable to compare to 'Variable'
308 @param VendorGuid GUID of the variable to compare to 'Variable'
309 @param PtrTrack Variable Track Pointer structure that contains Variable Information.
310
311 @retval EFI_SUCCESS Found match variable
312 @retval EFI_NOT_FOUND Variable not found
313
314 **/
315 EFI_STATUS
316 CompareWithValidVariable (
317 IN VARIABLE_HEADER *Variable,
318 IN CONST CHAR16 *VariableName,
319 IN CONST EFI_GUID *VendorGuid,
320 OUT VARIABLE_POINTER_TRACK *PtrTrack
321 )
322 {
323 VOID *Point;
324
325 if (VariableName[0] == 0) {
326 PtrTrack->CurrPtr = Variable;
327 return EFI_SUCCESS;
328 } else {
329 //
330 // Don't use CompareGuid function here for performance reasons.
331 // Instead we compare the GUID a UINT32 at a time and branch
332 // on the first failed comparison.
333 //
334 if ((((INT32 *) VendorGuid)[0] == ((INT32 *) &Variable->VendorGuid)[0]) &&
335 (((INT32 *) VendorGuid)[1] == ((INT32 *) &Variable->VendorGuid)[1]) &&
336 (((INT32 *) VendorGuid)[2] == ((INT32 *) &Variable->VendorGuid)[2]) &&
337 (((INT32 *) VendorGuid)[3] == ((INT32 *) &Variable->VendorGuid)[3])
338 ) {
339 ASSERT (NameSizeOfVariable (Variable) != 0);
340 Point = (VOID *) GetVariableNamePtr (Variable);
341 if (CompareMem (VariableName, Point, NameSizeOfVariable (Variable)) == 0) {
342 PtrTrack->CurrPtr = Variable;
343 return EFI_SUCCESS;
344 }
345 }
346 }
347
348 return EFI_NOT_FOUND;
349 }
350
351
352 /**
353 This code finds variable in storage blocks (Non-Volatile).
354
355 @param PeiServices General purpose services available to every PEIM.
356 @param VariableName Name of the variable to be found
357 @param VendorGuid Vendor GUID to be found.
358 @param PtrTrack Variable Track Pointer structure that contains Variable Information.
359
360 @retval EFI_SUCCESS Variable found successfully
361 @retval EFI_NOT_FOUND Variable not found
362 @retval EFI_INVALID_PARAMETER Invalid variable name
363
364 **/
365 EFI_STATUS
366 FindVariable (
367 IN CONST EFI_PEI_SERVICES **PeiServices,
368 IN CONST CHAR16 *VariableName,
369 IN CONST EFI_GUID *VendorGuid,
370 OUT VARIABLE_POINTER_TRACK *PtrTrack
371 )
372 {
373 EFI_HOB_GUID_TYPE *GuidHob;
374 VARIABLE_STORE_HEADER *VariableStoreHeader;
375 VARIABLE_HEADER *Variable;
376 VARIABLE_HEADER *LastVariable;
377 VARIABLE_HEADER *MaxIndex;
378 VARIABLE_INDEX_TABLE *IndexTable;
379 UINT32 Count;
380 UINT32 Offset;
381 UINT8 *VariableBase;
382 BOOLEAN StopRecord;
383
384 if (VariableName[0] != 0 && VendorGuid == NULL) {
385 return EFI_INVALID_PARAMETER;
386 }
387 //
388 // No Variable Address equals zero, so 0 as initial value is safe.
389 //
390 MaxIndex = 0;
391 StopRecord = FALSE;
392
393 GuidHob = GetFirstGuidHob (&gEfiVariableIndexTableGuid);
394 if (GuidHob == NULL) {
395 //
396 // If it's the first time to access variable region in flash, create a guid hob to record
397 // VAR_ADDED type variable info.
398 // Note that as the resource of PEI phase is limited, only store the number of
399 // VARIABLE_INDEX_TABLE_VOLUME of VAR_ADDED type variables to reduce access time.
400 //
401 IndexTable = BuildGuidHob (&gEfiVariableIndexTableGuid, sizeof (VARIABLE_INDEX_TABLE));
402 IndexTable->Length = 0;
403 IndexTable->StartPtr = NULL;
404 IndexTable->EndPtr = NULL;
405 IndexTable->GoneThrough = 0;
406 } else {
407 IndexTable = GET_GUID_HOB_DATA (GuidHob);
408 for (Offset = 0, Count = 0; Count < IndexTable->Length; Count++) {
409 //
410 // traverse the variable info list to look for varible.
411 // The IndexTable->Index[Count] records the distance of two neighbouring VAR_ADDED type variables.
412 //
413 ASSERT (Count < VARIABLE_INDEX_TABLE_VOLUME);
414 Offset += IndexTable->Index[Count];
415 MaxIndex = (VARIABLE_HEADER *)((CHAR8 *)(IndexTable->StartPtr) + Offset);
416 if (CompareWithValidVariable (MaxIndex, VariableName, VendorGuid, PtrTrack) == EFI_SUCCESS) {
417 PtrTrack->StartPtr = IndexTable->StartPtr;
418 PtrTrack->EndPtr = IndexTable->EndPtr;
419
420 return EFI_SUCCESS;
421 }
422 }
423
424 if (IndexTable->GoneThrough != 0) {
425 return EFI_NOT_FOUND;
426 }
427 }
428 //
429 // If not found in HOB, then let's start from the MaxIndex we've found.
430 //
431 if (MaxIndex != NULL) {
432 Variable = GetNextVariablePtr (MaxIndex);
433 LastVariable = MaxIndex;
434 } else {
435 if ((IndexTable->StartPtr != NULL) || (IndexTable->EndPtr != NULL)) {
436 Variable = IndexTable->StartPtr;
437 } else {
438 VariableBase = (UINT8 *) (UINTN) PcdGet64 (PcdFlashNvStorageVariableBase64);
439 if (VariableBase == NULL) {
440 VariableBase = (UINT8 *) (UINTN) PcdGet32 (PcdFlashNvStorageVariableBase);
441 }
442
443 VariableStoreHeader = (VARIABLE_STORE_HEADER *) (VariableBase + \
444 ((EFI_FIRMWARE_VOLUME_HEADER *) (VariableBase)) -> HeaderLength);
445
446 if (GetVariableStoreStatus (VariableStoreHeader) != EfiValid) {
447 return EFI_UNSUPPORTED;
448 }
449
450 if (~VariableStoreHeader->Size == 0) {
451 return EFI_NOT_FOUND;
452 }
453 //
454 // Find the variable by walk through non-volatile variable store
455 //
456 IndexTable->StartPtr = GetStartPointer (VariableStoreHeader);
457 IndexTable->EndPtr = GetEndPointer (VariableStoreHeader);
458
459 //
460 // Start Pointers for the variable.
461 // Actual Data Pointer where data can be written.
462 //
463 Variable = IndexTable->StartPtr;
464 }
465
466 LastVariable = IndexTable->StartPtr;
467 }
468 //
469 // Find the variable by walk through non-volatile variable store
470 //
471 PtrTrack->StartPtr = IndexTable->StartPtr;
472 PtrTrack->EndPtr = IndexTable->EndPtr;
473
474 while ((Variable < IndexTable->EndPtr) && IsValidVariableHeader (Variable)) {
475 if (Variable->State == VAR_ADDED) {
476 //
477 // Record Variable in VariableIndex HOB
478 //
479 if (IndexTable->Length < VARIABLE_INDEX_TABLE_VOLUME && !StopRecord) {
480 Offset = (UINT32)((UINTN)Variable - (UINTN)LastVariable);
481 //
482 // The distance of two neighbouring VAR_ADDED variable is larger than 2^16,
483 // which is beyond the allowable scope(UINT16) of record. In such case, need not to
484 // record the subsequent VAR_ADDED type variables again.
485 //
486 if ((Offset & 0xFFFF0000UL) != 0) {
487 StopRecord = TRUE;
488 }
489
490 if (!StopRecord) {
491 IndexTable->Index[IndexTable->Length++] = (UINT16) Offset;
492 }
493 LastVariable = Variable;
494 }
495
496 if (CompareWithValidVariable (Variable, VariableName, VendorGuid, PtrTrack) == EFI_SUCCESS) {
497 return EFI_SUCCESS;
498 }
499 }
500
501 Variable = GetNextVariablePtr (Variable);
502 }
503 //
504 // If gone through the VariableStore, that means we never find in Firmware any more.
505 //
506 if ((IndexTable->Length < VARIABLE_INDEX_TABLE_VOLUME) && (!StopRecord)) {
507 IndexTable->GoneThrough = 1;
508 }
509
510 PtrTrack->CurrPtr = NULL;
511
512 return EFI_NOT_FOUND;
513 }
514
515 /**
516 This service retrieves a variable's value using its name and GUID.
517
518 Read the specified variable from the UEFI variable store. If the Data
519 buffer is too small to hold the contents of the variable, the error
520 EFI_BUFFER_TOO_SMALL is returned and DataSize is set to the required buffer
521 size to obtain the data.
522
523 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.
524 @param VariableName A pointer to a null-terminated string that is the variable's name.
525 @param VariableGuid A pointer to an EFI_GUID that is the variable's GUID. The combination of
526 VariableGuid and VariableName must be unique.
527 @param Attributes If non-NULL, on return, points to the variable's attributes.
528 @param DataSize On entry, points to the size in bytes of the Data buffer.
529 On return, points to the size of the data returned in Data.
530 @param Data Points to the buffer which will hold the returned variable value.
531
532 @retval EFI_SUCCESS The variable was read successfully.
533 @retval EFI_NOT_FOUND The variable could not be found.
534 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the resulting data.
535 DataSize is updated with the size required for
536 the specified variable.
537 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid, DataSize or Data is NULL.
538 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.
539
540 **/
541 EFI_STATUS
542 EFIAPI
543 PeiGetVariable (
544 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
545 IN CONST CHAR16 *VariableName,
546 IN CONST EFI_GUID *VariableGuid,
547 OUT UINT32 *Attributes,
548 IN OUT UINTN *DataSize,
549 OUT VOID *Data
550 )
551 {
552 VARIABLE_POINTER_TRACK Variable;
553 UINTN VarDataSize;
554 EFI_STATUS Status;
555 CONST EFI_PEI_SERVICES **PeiServices;
556
557 PeiServices = GetPeiServicesTablePointer ();
558 if (VariableName == NULL || VariableGuid == NULL || DataSize == NULL) {
559 return EFI_INVALID_PARAMETER;
560 }
561
562 //
563 // Check if this is recovery boot path.
564 // If yes, the content of variable area is not reliable. Therefore we directly
565 // return EFI_NOT_FOUND.
566 //
567 if (IsInRecoveryMode(PeiServices)) {
568 return EFI_NOT_FOUND;
569 }
570
571 //
572 // Find existing variable
573 //
574 Status = FindVariable (PeiServices, VariableName, VariableGuid, &Variable);
575 if (Variable.CurrPtr == NULL || Status != EFI_SUCCESS) {
576 return Status;
577 }
578 //
579 // Get data size
580 //
581 VarDataSize = DataSizeOfVariable (Variable.CurrPtr);
582 if (*DataSize >= VarDataSize) {
583 if (Data == NULL) {
584 return EFI_INVALID_PARAMETER;
585 }
586
587 CopyMem (Data, GetVariableDataPtr (Variable.CurrPtr), VarDataSize);
588
589 if (Attributes != NULL) {
590 *Attributes = Variable.CurrPtr->Attributes;
591 }
592
593 *DataSize = VarDataSize;
594 return EFI_SUCCESS;
595 } else {
596 *DataSize = VarDataSize;
597 return EFI_BUFFER_TOO_SMALL;
598 }
599 }
600
601 /**
602 Return the next variable name and GUID.
603
604 This function is called multiple times to retrieve the VariableName
605 and VariableGuid of all variables currently available in the system.
606 On each call, the previous results are passed into the interface,
607 and, on return, the interface returns the data for the next
608 interface. When the entire variable list has been returned,
609 EFI_NOT_FOUND is returned.
610
611 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.
612
613 @param VariableNameSize On entry, points to the size of the buffer pointed to by VariableName.
614 On return, the size of the variable name buffer.
615 @param VariableName On entry, a pointer to a null-terminated string that is the variable's name.
616 On return, points to the next variable's null-terminated name string.
617 @param VariableGuid On entry, a pointer to an EFI_GUID that is the variable's GUID.
618 On return, a pointer to the next variable's GUID.
619
620 @retval EFI_SUCCESS The variable was read successfully.
621 @retval EFI_NOT_FOUND The variable could not be found.
622 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the resulting
623 data. VariableNameSize is updated with the size
624 required for the specified variable.
625 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid or
626 VariableNameSize is NULL.
627 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.
628
629 **/
630 EFI_STATUS
631 EFIAPI
632 PeiGetNextVariableName (
633 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
634 IN OUT UINTN *VariableNameSize,
635 IN OUT CHAR16 *VariableName,
636 IN OUT EFI_GUID *VariableGuid
637 )
638 {
639 VARIABLE_POINTER_TRACK Variable;
640 UINTN VarNameSize;
641 EFI_STATUS Status;
642 CONST EFI_PEI_SERVICES **PeiServices;
643
644 PeiServices = GetPeiServicesTablePointer ();
645 if (VariableName == NULL || VariableGuid == NULL || VariableNameSize == NULL) {
646 return EFI_INVALID_PARAMETER;
647 }
648
649 //
650 // Check if this is recovery boot path.
651 // If yes, the content of variable area is not reliable. Therefore we directly
652 // return EFI_NOT_FOUND.
653 //
654 if (IsInRecoveryMode(PeiServices)) {
655 return EFI_NOT_FOUND;
656 }
657
658 Status = FindVariable (PeiServices, VariableName, VariableGuid, &Variable);
659 if (Variable.CurrPtr == NULL || Status != EFI_SUCCESS) {
660 return Status;
661 }
662
663 if (VariableName[0] != 0) {
664 //
665 // If variable name is not NULL, get next variable
666 //
667 Variable.CurrPtr = GetNextVariablePtr (Variable.CurrPtr);
668 }
669
670 while (!(Variable.CurrPtr >= Variable.EndPtr || Variable.CurrPtr == NULL)) {
671 if (IsValidVariableHeader (Variable.CurrPtr)) {
672 if (Variable.CurrPtr->State == VAR_ADDED) {
673 ASSERT (NameSizeOfVariable (Variable.CurrPtr) != 0);
674
675 VarNameSize = (UINTN) NameSizeOfVariable (Variable.CurrPtr);
676 if (VarNameSize <= *VariableNameSize) {
677 CopyMem (VariableName, GetVariableNamePtr (Variable.CurrPtr), VarNameSize);
678
679 CopyMem (VariableGuid, &Variable.CurrPtr->VendorGuid, sizeof (EFI_GUID));
680
681 Status = EFI_SUCCESS;
682 } else {
683 Status = EFI_BUFFER_TOO_SMALL;
684 }
685
686 *VariableNameSize = VarNameSize;
687 return Status;
688 //
689 // Variable is found
690 //
691 } else {
692 Variable.CurrPtr = GetNextVariablePtr (Variable.CurrPtr);
693 }
694 } else {
695 break;
696 }
697 }
698
699 return EFI_NOT_FOUND;
700 }