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