1) If DebugAssertEnabled is TRUE, we still need to provide the GET size
[mirror_edk2.git] / EdkModulePkg / Universal / PCD / Pei / Pcd.c
CommitLineData
52e1905d 1/** @file PCD PEIM\r
878ddf1f 2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12\r
13Module Name: Pcd.c\r
14\r
15**/\r
16\r
878ddf1f 17#include "Service.h"\r
18\r
19\r
20PCD_PPI mPcdPpiInstance = {\r
21 PeiPcdSetSku,\r
22\r
23 PeiPcdGet8,\r
24 PeiPcdGet16, \r
25 PeiPcdGet32, \r
26 PeiPcdGet64, \r
27 PeiPcdGetPtr, \r
28 PeiPcdGetBool, \r
29 PeiPcdGetSize,\r
30\r
31 PeiPcdGet8Ex,\r
32 PeiPcdGet16Ex, \r
33 PeiPcdGet32Ex, \r
34 PeiPcdGet64Ex, \r
35 PeiPcdGetPtrEx, \r
36 PeiPcdGetBoolEx, \r
37 PeiPcdGetSizeEx,\r
38 \r
39 PeiPcdSet8,\r
40 PeiPcdSet16, \r
41 PeiPcdSet32, \r
42 PeiPcdSet64, \r
43 PeiPcdSetPtr, \r
44 PeiPcdSetBool, \r
45\r
46 PeiPcdSet8Ex,\r
47 PeiPcdSet16Ex, \r
48 PeiPcdSet32Ex, \r
49 PeiPcdSet64Ex, \r
50 PeiPcdSetPtrEx, \r
51 PeiPcdSetBoolEx,\r
52\r
4c114006 53 PeiRegisterCallBackOnSet,\r
878ddf1f 54 PcdUnRegisterCallBackOnSet,\r
4276d5da 55 PeiPcdGetNextToken,\r
56 PeiPcdGetNextTokenSpace\r
878ddf1f 57};\r
58\r
59\r
60\r
61STATIC EFI_PEI_PPI_DESCRIPTOR mPpiPCD = {\r
62 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
63 &gPcdPpiGuid,\r
64 &mPcdPpiInstance\r
65};\r
66\r
67\r
68\r
69EFI_STATUS\r
70EFIAPI\r
71PcdPeimInit (\r
72 IN EFI_FFS_FILE_HEADER *FfsHeader,\r
73 IN EFI_PEI_SERVICES **PeiServices\r
74 )\r
75{\r
76 EFI_STATUS Status;\r
878ddf1f 77\r
52e1905d 78 BuildPcdDatabase ();\r
79 \r
84a99d48 80 Status = PeiServicesInstallPpi (&mPpiPCD);\r
878ddf1f 81\r
82 ASSERT_EFI_ERROR (Status);\r
83 \r
84 return EFI_SUCCESS;\r
85}\r
86\r
00b7af13 87VOID\r
878ddf1f 88EFIAPI\r
89PeiPcdSetSku (\r
8a43e8dd 90 IN UINTN SkuId\r
878ddf1f 91 )\r
92{\r
878ddf1f 93\r
8a43e8dd 94 GetPcdDatabase()->Init.SystemSkuId = (SKU_ID) SkuId;\r
878ddf1f 95\r
00b7af13 96 return;\r
878ddf1f 97}\r
98\r
99\r
100\r
101UINT8\r
102EFIAPI\r
103PeiPcdGet8 (\r
5f5f28c9 104 IN UINTN TokenNumber\r
878ddf1f 105 )\r
106{\r
52e1905d 107 return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));\r
878ddf1f 108}\r
109\r
110\r
111\r
112UINT16\r
113EFIAPI\r
114PeiPcdGet16 (\r
5f5f28c9 115 IN UINTN TokenNumber\r
878ddf1f 116 )\r
117{\r
52e1905d 118 return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));\r
878ddf1f 119}\r
120\r
121\r
122\r
123UINT32\r
124EFIAPI\r
125PeiPcdGet32 (\r
5f5f28c9 126 IN UINTN TokenNumber\r
878ddf1f 127 )\r
128{\r
52e1905d 129 return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));\r
878ddf1f 130}\r
131\r
132\r
133\r
134UINT64\r
135EFIAPI\r
136PeiPcdGet64 (\r
5f5f28c9 137 IN UINTN TokenNumber\r
878ddf1f 138 )\r
139{\r
52e1905d 140 return ReadUnaligned64 (GetWorker (TokenNumber, sizeof (UINT64)));\r
878ddf1f 141}\r
142\r
143\r
144\r
145VOID *\r
146EFIAPI\r
147PeiPcdGetPtr (\r
5f5f28c9 148 IN UINTN TokenNumber\r
878ddf1f 149 )\r
150{\r
52e1905d 151 return GetWorker (TokenNumber, 0);\r
878ddf1f 152}\r
153\r
154\r
155\r
156BOOLEAN\r
157EFIAPI\r
158PeiPcdGetBool (\r
5f5f28c9 159 IN UINTN TokenNumber\r
878ddf1f 160 )\r
161{\r
52e1905d 162 return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));\r
878ddf1f 163}\r
164\r
165\r
166\r
167UINTN\r
168EFIAPI\r
169PeiPcdGetSize (\r
5f5f28c9 170 IN UINTN TokenNumber\r
878ddf1f 171 )\r
172{\r
1de04b4f 173 PEI_PCD_DATABASE *PeiPcdDb;\r
174 UINTN Size;\r
175 UINTN MaxSize;\r
176\r
5f5f28c9 177 //\r
178 // If DebugAssertEnabled is TRUE, we still need to provide the GET size\r
179 // function as GetWorker and SetWoker need this function to do ASSERT.\r
180 //\r
181 if ((!FeaturePcdGet(PcdPeiPcdDatabaseGetSizeEnabled)) &&\r
182 (!DebugAssertEnabled ())) {\r
183 return 0;\r
f89f5802 184 }\r
185\r
1de04b4f 186 PeiPcdDb = GetPcdDatabase ();\r
58f1099f 187 //\r
188 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
189 // We have to decrement TokenNumber by 1 to make it usable\r
190 // as the array index.\r
191 //\r
192 TokenNumber--;\r
193\r
4f914125 194 // EBC compiler is very choosy. It may report warning about comparison\r
195 // between UINTN and 0 . So we add 1 in each size of the \r
196 // comparison.\r
197 ASSERT (TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1);\r
52e1905d 198\r
1de04b4f 199 Size = (PeiPcdDb->Init.LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;\r
200\r
201 if (Size == 0) {\r
202 //\r
203 // For pointer type, we need to scan the SIZE_TABLE to get the current size.\r
204 //\r
205 return GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);\r
206 } else {\r
207 return Size;\r
208 }\r
209\r
878ddf1f 210}\r
211\r
212\r
213\r
214UINT8\r
215EFIAPI\r
216PeiPcdGet8Ex (\r
5f5f28c9 217 IN CONST EFI_GUID *Guid,\r
218 IN UINTN ExTokenNumber\r
878ddf1f 219 )\r
220{\r
52e1905d 221 return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof (UINT8)));\r
878ddf1f 222}\r
223\r
224\r
225\r
226UINT16\r
227EFIAPI\r
228PeiPcdGet16Ex (\r
5f5f28c9 229 IN CONST EFI_GUID *Guid,\r
230 IN UINTN ExTokenNumber\r
878ddf1f 231 )\r
232{\r
52e1905d 233 return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT16)));\r
878ddf1f 234}\r
235\r
236\r
237\r
238UINT32\r
239EFIAPI\r
240PeiPcdGet32Ex (\r
5f5f28c9 241 IN CONST EFI_GUID *Guid,\r
242 IN UINTN ExTokenNumber\r
878ddf1f 243 )\r
244{\r
52e1905d 245 return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT32)));\r
878ddf1f 246}\r
247\r
248\r
249\r
250UINT64\r
251EFIAPI\r
252PeiPcdGet64Ex (\r
5f5f28c9 253 IN CONST EFI_GUID *Guid,\r
254 IN UINTN ExTokenNumber\r
878ddf1f 255 )\r
256{\r
52e1905d 257 return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT64)));\r
878ddf1f 258}\r
259\r
260\r
261\r
262VOID *\r
263EFIAPI\r
264PeiPcdGetPtrEx (\r
5f5f28c9 265 IN CONST EFI_GUID *Guid,\r
266 IN UINTN ExTokenNumber\r
878ddf1f 267 )\r
268{\r
52e1905d 269 return ExGetWorker (Guid, ExTokenNumber, 0);\r
878ddf1f 270}\r
271\r
272\r
273\r
274BOOLEAN\r
275EFIAPI\r
276PeiPcdGetBoolEx (\r
5f5f28c9 277 IN CONST EFI_GUID *Guid,\r
278 IN UINTN ExTokenNumber\r
878ddf1f 279 )\r
280{\r
52e1905d 281 return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof (BOOLEAN)));\r
878ddf1f 282}\r
283\r
284\r
285\r
286UINTN\r
287EFIAPI\r
288PeiPcdGetSizeEx (\r
5f5f28c9 289 IN CONST EFI_GUID *Guid,\r
290 IN UINTN ExTokenNumber\r
878ddf1f 291 )\r
292{\r
f89f5802 293 if ((!FeaturePcdGet (PcdPeiPcdDatabaseGetSizeEnabled)) || !FeaturePcdGet (PcdPeiPcdDatabaseExEnabled)) {\r
5f5f28c9 294 return 0;\r
f89f5802 295 }\r
296\r
9d6d8b24 297 return PeiPcdGetSize (GetExPcdTokenNumber (Guid, ExTokenNumber));\r
878ddf1f 298}\r
299\r
300\r
301\r
302EFI_STATUS\r
303EFIAPI\r
304PeiPcdSet8 (\r
8a43e8dd 305 IN UINTN TokenNumber,\r
1de04b4f 306 IN UINT8 Value\r
878ddf1f 307 )\r
308{\r
1de04b4f 309 return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
878ddf1f 310}\r
311\r
312\r
313\r
314EFI_STATUS\r
315EFIAPI\r
316PeiPcdSet16 (\r
5f5f28c9 317 IN UINTN TokenNumber,\r
318 IN UINT16 Value\r
878ddf1f 319 )\r
320{\r
1de04b4f 321 return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
878ddf1f 322}\r
323\r
324\r
325\r
326EFI_STATUS\r
327EFIAPI\r
328PeiPcdSet32 (\r
5f5f28c9 329 IN UINTN TokenNumber,\r
330 IN UINT32 Value\r
878ddf1f 331 )\r
332{\r
1de04b4f 333 return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
878ddf1f 334}\r
335\r
336\r
337\r
338EFI_STATUS\r
339EFIAPI\r
340PeiPcdSet64 (\r
5f5f28c9 341 IN UINTN TokenNumber,\r
342 IN UINT64 Value\r
878ddf1f 343 )\r
344{\r
1de04b4f 345 return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
878ddf1f 346}\r
347\r
348\r
349EFI_STATUS\r
350EFIAPI\r
351PeiPcdSetPtr (\r
5f5f28c9 352 IN UINTN TokenNumber,\r
353 IN OUT UINTN *SizeOfBuffer,\r
354 IN VOID *Buffer\r
878ddf1f 355 )\r
356{\r
00b7af13 357 return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);\r
878ddf1f 358}\r
359\r
360\r
361\r
362EFI_STATUS\r
363EFIAPI\r
364PeiPcdSetBool (\r
5f5f28c9 365 IN UINTN TokenNumber,\r
366 IN BOOLEAN Value\r
878ddf1f 367 )\r
368{\r
1de04b4f 369 return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
878ddf1f 370}\r
371\r
372\r
373\r
374EFI_STATUS\r
375EFIAPI\r
376PeiPcdSet8Ex (\r
5f5f28c9 377 IN CONST EFI_GUID *Guid,\r
378 IN UINTN ExTokenNumber,\r
379 IN UINT8 Value\r
878ddf1f 380 )\r
381{\r
1de04b4f 382 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
878ddf1f 383}\r
384\r
385\r
386\r
387EFI_STATUS\r
388EFIAPI\r
389PeiPcdSet16Ex (\r
5f5f28c9 390 IN CONST EFI_GUID *Guid,\r
391 IN UINTN ExTokenNumber,\r
392 IN UINT16 Value\r
878ddf1f 393 )\r
394{\r
1de04b4f 395 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
878ddf1f 396}\r
397\r
398\r
399\r
400EFI_STATUS\r
401EFIAPI\r
402PeiPcdSet32Ex (\r
5f5f28c9 403 IN CONST EFI_GUID *Guid,\r
404 IN UINTN ExTokenNumber,\r
405 IN UINT32 Value\r
878ddf1f 406 )\r
407{\r
1de04b4f 408 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
878ddf1f 409}\r
410\r
411\r
412\r
413EFI_STATUS\r
414EFIAPI\r
415PeiPcdSet64Ex (\r
5f5f28c9 416 IN CONST EFI_GUID *Guid,\r
417 IN UINTN ExTokenNumber,\r
418 IN UINT64 Value\r
878ddf1f 419 )\r
420{\r
1de04b4f 421 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
878ddf1f 422}\r
423\r
424\r
425\r
426EFI_STATUS\r
427EFIAPI\r
428PeiPcdSetPtrEx (\r
5f5f28c9 429 IN CONST EFI_GUID *Guid,\r
430 IN UINTN ExTokenNumber,\r
431 IN UINTN *SizeOfBuffer,\r
432 IN VOID *Value\r
878ddf1f 433 )\r
434{\r
1de04b4f 435 return ExSetWorker (ExTokenNumber, Guid, Value, SizeOfBuffer, TRUE);\r
878ddf1f 436}\r
437\r
438\r
439\r
440EFI_STATUS\r
441EFIAPI\r
442PeiPcdSetBoolEx (\r
5f5f28c9 443 IN CONST EFI_GUID *Guid,\r
444 IN UINTN ExTokenNumber,\r
445 IN BOOLEAN Value\r
878ddf1f 446 )\r
447{\r
1de04b4f 448 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
878ddf1f 449}\r
450\r
451\r
452\r
453\r
454EFI_STATUS\r
455EFIAPI\r
4c114006 456PeiRegisterCallBackOnSet (\r
878ddf1f 457 IN CONST EFI_GUID *Guid, OPTIONAL\r
2a870f53 458 IN UINTN ExTokenNumber,\r
878ddf1f 459 IN PCD_PPI_CALLBACK CallBackFunction\r
460 )\r
461{\r
f89f5802 462 if (!FeaturePcdGet(PcdPeiPcdDatabaseCallbackOnSetEnabled)) {\r
463 return EFI_UNSUPPORTED;\r
464 }\r
465\r
4c114006 466 ASSERT (CallBackFunction != NULL);\r
467 \r
52e1905d 468 return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, TRUE);\r
878ddf1f 469}\r
470\r
471\r
472\r
473EFI_STATUS\r
474EFIAPI\r
475PcdUnRegisterCallBackOnSet (\r
878ddf1f 476 IN CONST EFI_GUID *Guid, OPTIONAL\r
2a870f53 477 IN UINTN ExTokenNumber,\r
878ddf1f 478 IN PCD_PPI_CALLBACK CallBackFunction\r
479 )\r
480{\r
f89f5802 481 if (!FeaturePcdGet(PcdPeiPcdDatabaseCallbackOnSetEnabled)) {\r
482 return EFI_UNSUPPORTED;\r
483 }\r
484\r
4c114006 485 ASSERT (CallBackFunction != NULL);\r
486 \r
52e1905d 487 return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, FALSE);\r
878ddf1f 488}\r
489\r
490\r
491\r
492EFI_STATUS\r
493EFIAPI\r
494PeiPcdGetNextToken (\r
495 IN CONST EFI_GUID *Guid, OPTIONAL\r
8a43e8dd 496 IN OUT UINTN *TokenNumber\r
878ddf1f 497 )\r
498{\r
00b7af13 499 UINTN GuidTableIdx;\r
500 PEI_PCD_DATABASE *PeiPcdDb;\r
501 EFI_GUID *MatchGuid;\r
502 DYNAMICEX_MAPPING *ExMapTable;\r
503 UINTN i;\r
504 BOOLEAN Found;\r
505 \r
4f914125 506 if (!FeaturePcdGet (PcdPeiPcdDatabaseTraverseEnabled)) {\r
507 return EFI_UNSUPPORTED;\r
508 }\r
509 \r
52e1905d 510 if (Guid == NULL) {\r
2b21a971 511 if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {\r
512 return EFI_NOT_FOUND;\r
513 }\r
b560bb65 514 (*TokenNumber)++;\r
c24ba2f6 515 if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {\r
0653eb89 516 *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
52e1905d 517 }\r
c24ba2f6 518 return EFI_SUCCESS;\r
00b7af13 519 } else {\r
00b7af13 520 if (PEI_EXMAP_TABLE_EMPTY) {\r
0653eb89 521 *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
c24ba2f6 522 return EFI_SUCCESS;\r
00b7af13 523 }\r
524 \r
525 //\r
526 // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order\r
527 // 1) ExGuid\r
528 // 2) ExTokenNumber\r
529 //\r
530 PeiPcdDb = GetPcdDatabase ();\r
531 \r
532 MatchGuid = ScanGuid (PeiPcdDb->Init.GuidTable, sizeof(PeiPcdDb->Init.GuidTable), Guid);\r
533\r
534 if (MatchGuid == NULL) {\r
c24ba2f6 535 *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
00b7af13 536 return EFI_NOT_FOUND;\r
537 }\r
538\r
539 GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;\r
540\r
541 ExMapTable = PeiPcdDb->Init.ExMapTable;\r
542\r
543 Found = FALSE;\r
c24ba2f6 544 //\r
545 // Locate the GUID in ExMapTable first.\r
546 //\r
00b7af13 547 for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {\r
548 if (ExMapTable[i].ExGuidIndex == GuidTableIdx) {\r
549 Found = TRUE;\r
550 break;\r
551 }\r
552 }\r
553\r
554 if (Found) {\r
555 if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r
556 *TokenNumber = ExMapTable[i].ExTokenNumber;\r
557 return EFI_SUCCESS;\r
558 }\r
c24ba2f6 559\r
560 for ( ; i < PEI_EXMAPPING_TABLE_SIZE; i++) {\r
00b7af13 561 if (ExMapTable[i].ExTokenNumber == *TokenNumber) {\r
562 i++;\r
c24ba2f6 563 if (i == PEI_EXMAPPING_TABLE_SIZE) {\r
564 //\r
565 // Exceed the length of ExMap Table\r
566 //\r
567 *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
568 return EFI_SUCCESS;\r
569 }\r
00b7af13 570 if (ExMapTable[i].ExGuidIndex == GuidTableIdx) {\r
571 *TokenNumber = ExMapTable[i].ExTokenNumber;\r
572 return EFI_SUCCESS;\r
573 } else {\r
c24ba2f6 574 *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
00b7af13 575 return EFI_SUCCESS;\r
576 }\r
577 }\r
578 }\r
00b7af13 579 return EFI_NOT_FOUND;\r
580 }\r
00b7af13 581 }\r
582\r
c24ba2f6 583 return EFI_NOT_FOUND;\r
00b7af13 584}\r
585\r
1de04b4f 586\r
587\r
58f1099f 588EFI_STATUS\r
00b7af13 589EFIAPI\r
4276d5da 590PeiPcdGetNextTokenSpace (\r
5f5f28c9 591 IN OUT CONST EFI_GUID **Guid\r
00b7af13 592 )\r
593{\r
594 UINTN GuidTableIdx;\r
595 EFI_GUID *MatchGuid;\r
596 PEI_PCD_DATABASE *PeiPcdDb;\r
597 DYNAMICEX_MAPPING *ExMapTable;\r
598 UINTN i;\r
599 BOOLEAN Found;\r
600\r
4f914125 601 if (!FeaturePcdGet (PcdPeiPcdDatabaseTraverseEnabled)) {\r
602 return EFI_UNSUPPORTED;\r
603 }\r
604\r
4276d5da 605 ASSERT (Guid != NULL);\r
606\r
607 if (PEI_EXMAP_TABLE_EMPTY) {\r
608 if (*Guid != NULL) {\r
609 return EFI_NOT_FOUND;\r
58f1099f 610 } else {\r
58f1099f 611 return EFI_SUCCESS;\r
612 }\r
4276d5da 613 }\r
52e1905d 614\r
615 //\r
00b7af13 616 // Assume PCD Database AutoGen tool is sorting the ExMap based on the following order\r
617 // 1) ExGuid\r
618 // 2) ExTokenNumber\r
52e1905d 619 //\r
00b7af13 620 PeiPcdDb = GetPcdDatabase ();\r
52e1905d 621\r
4276d5da 622 ExMapTable = PeiPcdDb->Init.ExMapTable;\r
623\r
624 if (*Guid == NULL) {\r
625 //\r
626 // return the first Token Space Guid.\r
627 //\r
628 *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[0].ExGuidIndex];\r
629 return EFI_SUCCESS;\r
630 }\r
631\r
58f1099f 632 MatchGuid = ScanGuid (PeiPcdDb->Init.GuidTable, sizeof(PeiPcdDb->Init.GuidTable), *Guid);\r
00b7af13 633\r
634 if (MatchGuid == NULL) {\r
58f1099f 635 return EFI_NOT_FOUND;\r
00b7af13 636 }\r
637 \r
638 GuidTableIdx = MatchGuid - PeiPcdDb->Init.GuidTable;\r
878ddf1f 639\r
00b7af13 640 Found = FALSE;\r
641 for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {\r
642 if (ExMapTable[i].ExGuidIndex == GuidTableIdx) {\r
643 Found = TRUE;\r
644 break;\r
645 }\r
646 }\r
647\r
648 if (Found) {\r
4276d5da 649 i++;\r
00b7af13 650 for ( ; i < PEI_EXMAPPING_TABLE_SIZE; i++ ) {\r
651 if (ExMapTable[i].ExGuidIndex != GuidTableIdx ) {\r
58f1099f 652 *Guid = &PeiPcdDb->Init.GuidTable[ExMapTable[i].ExGuidIndex];\r
653 return EFI_SUCCESS;\r
00b7af13 654 }\r
655 }\r
4276d5da 656 *Guid = NULL;\r
657 return EFI_SUCCESS;\r
00b7af13 658 }\r
659\r
58f1099f 660 return EFI_NOT_FOUND;\r
00b7af13 661\r
662}\r
878ddf1f 663\r