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