]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Variable/Pei/Variable.c
Patch to remove STATIC modifier. This is on longer recommended by EFI Framework codin...
[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
24static EFI_PEI_READ_ONLY_VARIABLE2_PPI mVariablePpi = {\r
25 PeiGetVariable,\r
26 PeiGetNextVariableName\r
27};\r
28\r
29static EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {\r
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
8d3a5c82 120STATIC\r
130e2569 121BOOLEAN\r
122EFIAPI\r
123IsValidVariableHeader (\r
124 IN VARIABLE_HEADER *Variable\r
8d3a5c82 125 )\r
126/*++\r
127\r
128Routine Description:\r
129\r
130 This code checks if variable header is valid or not.\r
131\r
132Arguments:\r
130e2569 133 Variable Pointer to the Variable Header.\r
8d3a5c82 134\r
135Returns:\r
136 TRUE Variable header is valid.\r
137 FALSE Variable header is not valid.\r
138\r
139--*/\r
140{\r
130e2569 141 if (Variable == NULL || Variable->StartId != VARIABLE_DATA ) {\r
142 return FALSE;\r
143 }\r
144\r
145 return TRUE;\r
8d3a5c82 146}\r
147\r
130e2569 148\r
149UINTN\r
150NameSizeOfVariable (\r
8d3a5c82 151 IN VARIABLE_HEADER *Variable\r
152 )\r
153/*++\r
154\r
155Routine Description:\r
156\r
130e2569 157 This code gets the size of name of variable.\r
158\r
159Arguments:\r
160\r
161 Variable Pointer to the Variable Header.\r
162\r
163Returns:\r
164\r
165 UINTN Size of variable in bytes\r
166\r
167--*/\r
168{\r
169 if (Variable->State == (UINT8) (-1) ||\r
170 Variable->DataSize == (UINT32) -1 ||\r
171 Variable->NameSize == (UINT32) -1 ||\r
172 Variable->Attributes == (UINT32) -1) {\r
173 return 0;\r
174 }\r
175 return (UINTN) Variable->NameSize;\r
176}\r
177\r
178UINTN\r
179DataSizeOfVariable (\r
180 IN VARIABLE_HEADER *Variable\r
181 )\r
182/*++\r
183\r
184Routine Description:\r
185\r
186 This code gets the size of name of variable.\r
187\r
188Arguments:\r
189\r
190 Variable Pointer to the Variable Header.\r
191\r
192Returns:\r
193\r
194 UINTN Size of variable in bytes\r
195\r
196--*/\r
197{\r
198 if (Variable->State == (UINT8) -1 ||\r
199 Variable->DataSize == (UINT32) -1 ||\r
200 Variable->NameSize == (UINT32) -1 ||\r
201 Variable->Attributes == (UINT32) -1) {\r
202 return 0;\r
203 }\r
204 return (UINTN) Variable->DataSize;\r
205}\r
206\r
207CHAR16 *\r
208GetVariableNamePtr (\r
209 IN VARIABLE_HEADER *Variable\r
210 )\r
211/*++\r
212\r
213Routine Description:\r
214\r
215 This code gets the pointer to the variable name.\r
8d3a5c82 216\r
217Arguments:\r
130e2569 218\r
219 Variable Pointer to the Variable Header.\r
220\r
221Returns:\r
222\r
223 CHAR16* Pointer to Variable Name\r
224\r
225--*/\r
226{\r
227\r
228 return (CHAR16 *) (Variable + 1);\r
229}\r
230\r
231\r
232UINT8 *\r
233GetVariableDataPtr (\r
234 IN VARIABLE_HEADER *Variable\r
235 )\r
236/*++\r
237\r
238Routine Description:\r
239\r
240 This code gets the pointer to the variable data.\r
241\r
242Arguments:\r
243\r
244 Variable Pointer to the Variable Header.\r
245\r
246Returns:\r
247\r
248 UINT8* Pointer to Variable Data\r
249\r
250--*/\r
251{\r
252 UINTN Value;\r
253 \r
254 //\r
255 // Be careful about pad size for alignment\r
256 //\r
257 Value = (UINTN) GetVariableNamePtr (Variable);\r
258 Value += NameSizeOfVariable (Variable);\r
259 Value += GET_PAD_SIZE (NameSizeOfVariable (Variable));\r
260\r
261 return (UINT8 *) Value;\r
262}\r
263\r
264VARIABLE_HEADER *\r
265GetNextVariablePtr (\r
266 IN VARIABLE_HEADER *Variable\r
267 )\r
268/*++\r
269\r
270Routine Description:\r
271\r
272 This code gets the pointer to the next variable header.\r
273\r
274Arguments:\r
275\r
8d3a5c82 276 Variable Pointer to the Variable Header.\r
277\r
278Returns:\r
130e2569 279\r
280 VARIABLE_HEADER* Pointer to next variable header.\r
8d3a5c82 281\r
282--*/\r
283{\r
130e2569 284 UINTN Value;\r
285\r
286 if (!IsValidVariableHeader (Variable)) {\r
287 return NULL;\r
8d3a5c82 288 }\r
289\r
130e2569 290 Value = (UINTN) GetVariableDataPtr (Variable);\r
291 Value += DataSizeOfVariable (Variable);\r
292 Value += GET_PAD_SIZE (DataSizeOfVariable (Variable));\r
293\r
294 //\r
295 // Be careful about pad size for alignment\r
296 //\r
297 return (VARIABLE_HEADER *) HEADER_ALIGN (Value);\r
8d3a5c82 298}\r
299\r
130e2569 300\r
8d3a5c82 301STATIC\r
302VARIABLE_STORE_STATUS\r
303EFIAPI\r
304GetVariableStoreStatus (\r
305 IN VARIABLE_STORE_HEADER *VarStoreHeader\r
306 )\r
307/*++\r
308\r
309Routine Description:\r
310\r
311 This code gets the pointer to the variable name.\r
312\r
313Arguments:\r
314\r
315 VarStoreHeader Pointer to the Variable Store Header.\r
316\r
317Returns:\r
318\r
319 EfiRaw Variable store is raw\r
320 EfiValid Variable store is valid\r
321 EfiInvalid Variable store is invalid\r
322\r
323--*/\r
324{\r
325 if (VarStoreHeader->Signature == VARIABLE_STORE_SIGNATURE &&\r
326 VarStoreHeader->Format == VARIABLE_STORE_FORMATTED &&\r
327 VarStoreHeader->State == VARIABLE_STORE_HEALTHY\r
328 ) {\r
329\r
330 return EfiValid;\r
331 }\r
332\r
333 if (VarStoreHeader->Signature == 0xffffffff &&\r
334 VarStoreHeader->Size == 0xffffffff &&\r
335 VarStoreHeader->Format == 0xff &&\r
336 VarStoreHeader->State == 0xff\r
337 ) {\r
338\r
339 return EfiRaw;\r
340 } else {\r
341 return EfiInvalid;\r
342 }\r
343}\r
344\r
345STATIC\r
346EFI_STATUS\r
347CompareWithValidVariable (\r
348 IN VARIABLE_HEADER *Variable,\r
349 IN CONST CHAR16 *VariableName,\r
350 IN CONST EFI_GUID *VendorGuid,\r
351 OUT VARIABLE_POINTER_TRACK *PtrTrack\r
352 )\r
353/*++\r
354\r
355Routine Description:\r
356\r
357 This function compares a variable with variable entries in database\r
358\r
359Arguments:\r
360\r
361 Variable - Pointer to the variable in our database\r
362 VariableName - Name of the variable to compare to 'Variable'\r
363 VendorGuid - GUID of the variable to compare to 'Variable'\r
364 PtrTrack - Variable Track Pointer structure that contains\r
365 Variable Information.\r
366\r
367Returns:\r
368\r
369 EFI_SUCCESS - Found match variable\r
370 EFI_NOT_FOUND - Variable not found\r
371\r
372--*/\r
373{\r
130e2569 374 VOID *Point;\r
375\r
8d3a5c82 376 if (VariableName[0] == 0) {\r
377 PtrTrack->CurrPtr = Variable;\r
378 return EFI_SUCCESS;\r
379 } else {\r
380 //\r
381 // Don't use CompareGuid function here for performance reasons.\r
382 // Instead we compare the GUID a UINT32 at a time and branch\r
383 // on the first failed comparison.\r
384 //\r
385 if ((((INT32 *) VendorGuid)[0] == ((INT32 *) &Variable->VendorGuid)[0]) &&\r
386 (((INT32 *) VendorGuid)[1] == ((INT32 *) &Variable->VendorGuid)[1]) &&\r
387 (((INT32 *) VendorGuid)[2] == ((INT32 *) &Variable->VendorGuid)[2]) &&\r
388 (((INT32 *) VendorGuid)[3] == ((INT32 *) &Variable->VendorGuid)[3])\r
389 ) {\r
130e2569 390 ASSERT (NameSizeOfVariable (Variable) != 0);\r
391 Point = (VOID *) GetVariableNamePtr (Variable);\r
392 if (!CompareMem (VariableName, Point, NameSizeOfVariable (Variable))) {\r
8d3a5c82 393 PtrTrack->CurrPtr = Variable;\r
394 return EFI_SUCCESS;\r
395 }\r
396 }\r
397 }\r
398\r
399 return EFI_NOT_FOUND;\r
400}\r
401\r
402STATIC\r
403EFI_STATUS\r
404EFIAPI\r
405FindVariable (\r
284c8400 406 IN CONST EFI_PEI_SERVICES **PeiServices,\r
8d3a5c82 407 IN CONST CHAR16 *VariableName,\r
408 IN CONST EFI_GUID *VendorGuid,\r
409 OUT VARIABLE_POINTER_TRACK *PtrTrack\r
410 )\r
411/*++\r
412\r
413Routine Description:\r
414\r
415 This code finds variable in storage blocks (Non-Volatile)\r
416\r
417Arguments:\r
418\r
419 PeiServices - General purpose services available to every PEIM.\r
420 VariableName - Name of the variable to be found\r
421 VendorGuid - Vendor GUID to be found.\r
422 PtrTrack - Variable Track Pointer structure that contains\r
423 Variable Information.\r
424\r
425Returns:\r
426\r
427 EFI_SUCCESS - Variable found successfully\r
428 EFI_NOT_FOUND - Variable not found\r
429 EFI_INVALID_PARAMETER - Invalid variable name\r
430\r
431--*/\r
432{\r
433 EFI_HOB_GUID_TYPE *GuidHob;\r
434 VARIABLE_STORE_HEADER *VariableStoreHeader;\r
435 VARIABLE_HEADER *Variable;\r
436 VARIABLE_HEADER *MaxIndex;\r
437 VARIABLE_INDEX_TABLE *IndexTable;\r
438 UINT32 Count;\r
439 UINT8 *VariableBase;\r
440\r
441 if (VariableName != 0 && VendorGuid == NULL) {\r
442 return EFI_INVALID_PARAMETER;\r
443 }\r
444 //\r
445 // No Variable Address equals zero, so 0 as initial value is safe.\r
446 //\r
447 MaxIndex = 0;\r
448\r
449 GuidHob = GetFirstGuidHob (&mEfiVariableIndexTableGuid);\r
450 if (GuidHob == NULL) {\r
451 IndexTable = BuildGuidHob (&mEfiVariableIndexTableGuid, sizeof (VARIABLE_INDEX_TABLE));\r
452 IndexTable->Length = 0;\r
453 IndexTable->StartPtr = NULL;\r
454 IndexTable->EndPtr = NULL;\r
455 IndexTable->GoneThrough = 0;\r
456 } else {\r
457 IndexTable = GET_GUID_HOB_DATA (GuidHob);\r
458 for (Count = 0; Count < IndexTable->Length; Count++)\r
459 {\r
460 MaxIndex = GetVariableByIndex (IndexTable, Count);\r
461\r
462 if (CompareWithValidVariable (MaxIndex, VariableName, VendorGuid, PtrTrack) == EFI_SUCCESS) {\r
463 PtrTrack->StartPtr = IndexTable->StartPtr;\r
464 PtrTrack->EndPtr = IndexTable->EndPtr;\r
465\r
466 return EFI_SUCCESS;\r
467 }\r
468 }\r
469\r
470 if (IndexTable->GoneThrough) {\r
471 return EFI_NOT_FOUND;\r
472 }\r
473 }\r
474 //\r
475 // If not found in HOB, then let's start from the MaxIndex we've found.\r
476 //\r
477 if (MaxIndex != NULL) {\r
478 Variable = GetNextVariablePtr (MaxIndex);\r
479 } else {\r
480 if (IndexTable->StartPtr || IndexTable->EndPtr) {\r
481 Variable = IndexTable->StartPtr;\r
482 } else {\r
483 VariableBase = (UINT8 *) (UINTN) PcdGet32 (PcdFlashNvStorageVariableBase);\r
484 VariableStoreHeader = (VARIABLE_STORE_HEADER *) (VariableBase + \\r
485 ((EFI_FIRMWARE_VOLUME_HEADER *) (VariableBase)) -> HeaderLength);\r
486\r
487 if (GetVariableStoreStatus (VariableStoreHeader) != EfiValid) {\r
488 return EFI_UNSUPPORTED;\r
489 }\r
490\r
491 if (~VariableStoreHeader->Size == 0) {\r
492 return EFI_NOT_FOUND;\r
493 }\r
494 //\r
495 // Find the variable by walk through non-volatile variable store\r
496 //\r
9cad030b 497 IndexTable->StartPtr = GetStartPointer (VariableStoreHeader);\r
498 IndexTable->EndPtr = GetEndPointer (VariableStoreHeader);\r
8d3a5c82 499\r
500 //\r
501 // Start Pointers for the variable.\r
502 // Actual Data Pointer where data can be written.\r
503 //\r
504 Variable = IndexTable->StartPtr;\r
505 }\r
506 }\r
507 //\r
508 // Find the variable by walk through non-volatile variable store\r
509 //\r
510 PtrTrack->StartPtr = IndexTable->StartPtr;\r
511 PtrTrack->EndPtr = IndexTable->EndPtr;\r
512\r
513 while (IsValidVariableHeader (Variable) && (Variable <= IndexTable->EndPtr)) {\r
514 if (Variable->State == VAR_ADDED) {\r
515 //\r
516 // Record Variable in VariableIndex HOB\r
517 //\r
518 if (IndexTable->Length < VARIABLE_INDEX_TABLE_VOLUME)\r
519 {\r
520 VariableIndexTableUpdate (IndexTable, Variable);\r
521 }\r
522\r
523 if (CompareWithValidVariable (Variable, VariableName, VendorGuid, PtrTrack) == EFI_SUCCESS) {\r
524 return EFI_SUCCESS;\r
525 }\r
526 }\r
527\r
528 Variable = GetNextVariablePtr (Variable);\r
529 }\r
530 //\r
531 // If gone through the VariableStore, that means we never find in Firmware any more.\r
532 //\r
533 if (IndexTable->Length < VARIABLE_INDEX_TABLE_VOLUME) {\r
534 IndexTable->GoneThrough = 1;\r
535 }\r
536\r
537 PtrTrack->CurrPtr = NULL;\r
538\r
539 return EFI_NOT_FOUND;\r
540}\r
541\r
542EFI_STATUS\r
543EFIAPI\r
544PeiGetVariable (\r
545 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
546 IN CONST CHAR16 *VariableName,\r
547 IN CONST EFI_GUID *VariableGuid,\r
548 OUT UINT32 *Attributes,\r
549 IN OUT UINTN *DataSize,\r
550 OUT VOID *Data\r
551 )\r
552/*++\r
553\r
554Routine Description:\r
555\r
556 Provide the read variable functionality of the variable services.\r
557\r
558Arguments:\r
559\r
560 PeiServices - General purpose services available to every PEIM.\r
561\r
562 VariableName - The variable name\r
563\r
564 VendorGuid - The vendor's GUID\r
565\r
566 Attributes - Pointer to the attribute\r
567\r
568 DataSize - Size of data\r
569\r
570 Data - Pointer to data\r
571\r
572Returns:\r
573\r
574 EFI_SUCCESS - The interface could be successfully installed\r
575\r
576 EFI_NOT_FOUND - The variable could not be discovered\r
577\r
578 EFI_BUFFER_TOO_SMALL - The caller buffer is not large enough\r
579\r
580--*/\r
581{\r
582 VARIABLE_POINTER_TRACK Variable;\r
583 UINTN VarDataSize;\r
584 EFI_STATUS Status;\r
284c8400 585 CONST EFI_PEI_SERVICES **PeiServices;\r
8d3a5c82 586\r
587 PeiServices = GetPeiServicesTablePointer ();\r
01f352a7 588 if (VariableName == NULL || VariableGuid == NULL || DataSize == NULL) {\r
8d3a5c82 589 return EFI_INVALID_PARAMETER;\r
590 }\r
591 //\r
592 // Find existing variable\r
593 //\r
594 Status = FindVariable (PeiServices, VariableName, VariableGuid, &Variable);\r
595 if (Variable.CurrPtr == NULL || Status != EFI_SUCCESS) {\r
596 return Status;\r
597 }\r
598 //\r
599 // Get data size\r
600 //\r
130e2569 601 VarDataSize = DataSizeOfVariable (Variable.CurrPtr);\r
8d3a5c82 602 if (*DataSize >= VarDataSize) {\r
39aea48d 603 //\r
604 // PO-TKW: Address one checking in this place\r
605 //\r
606 if (Data == NULL) {\r
607 return EFI_INVALID_PARAMETER;\r
608 }\r
609\r
130e2569 610 (*PeiServices)->CopyMem (Data, GetVariableDataPtr (Variable.CurrPtr), VarDataSize);\r
8d3a5c82 611\r
612 if (Attributes != NULL) {\r
613 *Attributes = Variable.CurrPtr->Attributes;\r
614 }\r
615\r
616 *DataSize = VarDataSize;\r
617 return EFI_SUCCESS;\r
618 } else {\r
619 *DataSize = VarDataSize;\r
620 return EFI_BUFFER_TOO_SMALL;\r
621 }\r
622}\r
623\r
624EFI_STATUS\r
625EFIAPI\r
626PeiGetNextVariableName (\r
627 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
628 IN OUT UINTN *VariableNameSize,\r
629 IN OUT CHAR16 *VariableName,\r
630 IN OUT EFI_GUID *VariableGuid\r
631 )\r
632/*++\r
633\r
634Routine Description:\r
635\r
636 Provide the get next variable functionality of the variable services.\r
637\r
638Arguments:\r
639\r
640 PeiServices - General purpose services available to every PEIM.\r
641 VariabvleNameSize - The variable name's size.\r
642 VariableName - A pointer to the variable's name.\r
643 VariableGuid - A pointer to the EFI_GUID structure.\r
644\r
645 VariableNameSize - Size of the variable name\r
646\r
647 VariableName - The variable name\r
648\r
649 VendorGuid - The vendor's GUID\r
650\r
651Returns:\r
652\r
653 EFI_SUCCESS - The interface could be successfully installed\r
654\r
655 EFI_NOT_FOUND - The variable could not be discovered\r
656\r
657--*/\r
658{\r
659 VARIABLE_POINTER_TRACK Variable;\r
660 UINTN VarNameSize;\r
661 EFI_STATUS Status;\r
284c8400 662 CONST EFI_PEI_SERVICES **PeiServices;\r
8d3a5c82 663\r
664 PeiServices = GetPeiServicesTablePointer ();\r
01f352a7 665 if (VariableName == NULL || VariableGuid == NULL || VariableNameSize == NULL) {\r
8d3a5c82 666 return EFI_INVALID_PARAMETER;\r
667 }\r
668\r
669 Status = FindVariable (PeiServices, VariableName, VariableGuid, &Variable);\r
670 if (Variable.CurrPtr == NULL || Status != EFI_SUCCESS) {\r
671 return Status;\r
672 }\r
673\r
674 if (VariableName[0] != 0) {\r
675 //\r
676 // If variable name is not NULL, get next variable\r
677 //\r
678 Variable.CurrPtr = GetNextVariablePtr (Variable.CurrPtr);\r
679 }\r
680\r
681 while (!(Variable.CurrPtr >= Variable.EndPtr || Variable.CurrPtr == NULL)) {\r
682 if (IsValidVariableHeader (Variable.CurrPtr)) {\r
683 if (Variable.CurrPtr->State == VAR_ADDED) {\r
130e2569 684 ASSERT (NameSizeOfVariable (Variable.CurrPtr) != 0);\r
9cad030b 685\r
130e2569 686 VarNameSize = (UINTN) NameSizeOfVariable (Variable.CurrPtr);\r
8d3a5c82 687 if (VarNameSize <= *VariableNameSize) {\r
130e2569 688 (*PeiServices)->CopyMem (VariableName, GetVariableNamePtr (Variable.CurrPtr), VarNameSize);\r
8d3a5c82 689\r
690 (*PeiServices)->CopyMem (VariableGuid, &Variable.CurrPtr->VendorGuid, sizeof (EFI_GUID));\r
691\r
692 Status = EFI_SUCCESS;\r
693 } else {\r
694 Status = EFI_BUFFER_TOO_SMALL;\r
695 }\r
696\r
697 *VariableNameSize = VarNameSize;\r
698 return Status;\r
699 //\r
700 // Variable is found\r
701 //\r
702 } else {\r
703 Variable.CurrPtr = GetNextVariablePtr (Variable.CurrPtr);\r
704 }\r
705 } else {\r
706 break;\r
707 }\r
708 }\r
709\r
710 return EFI_NOT_FOUND;\r
711}\r