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