Bug fixing for FPD ModuleSA editor.
[mirror_edk2.git] / EdkModulePkg / Universal / PCD / Dxe / Pcd.c
CommitLineData
878ddf1f 1/** @file\r
2PCD DXE driver\r
3\r
4Copyright (c) 2006, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13\r
14Module Name: Pcd.c\r
15\r
16**/\r
17\r
878ddf1f 18#include "Service.h"\r
19\r
20\r
21PCD_PROTOCOL mPcdInstance = {\r
22 DxePcdSetSku,\r
23\r
24 DxePcdGet8,\r
25 DxePcdGet16,\r
26 DxePcdGet32,\r
27 DxePcdGet64,\r
28 DxePcdGetPtr,\r
29 DxePcdGetBool,\r
30 DxePcdGetSize,\r
31\r
32 DxePcdGet8Ex,\r
33 DxePcdGet16Ex,\r
34 DxePcdGet32Ex,\r
35 DxePcdGet64Ex,\r
36 DxePcdGetPtrEx,\r
37 DxePcdGetBoolEx,\r
38 DxePcdGetSizeEx,\r
39\r
40 DxePcdSet8,\r
41 DxePcdSet16,\r
42 DxePcdSet32,\r
43 DxePcdSet64,\r
44 DxePcdSetPtr,\r
45 DxePcdSetBool,\r
46\r
47 DxePcdSet8Ex,\r
48 DxePcdSet16Ex,\r
49 DxePcdSet32Ex,\r
50 DxePcdSet64Ex,\r
51 DxePcdSetPtrEx,\r
52 DxePcdSetBoolEx,\r
53\r
4c114006 54 DxeRegisterCallBackOnSet,\r
55 DxeUnRegisterCallBackOnSet,\r
878ddf1f 56 DxePcdGetNextToken\r
57};\r
58\r
59\r
60//\r
61// Static global to reduce the code size\r
62//\r
63static EFI_HANDLE NewHandle = NULL;\r
64\r
65EFI_STATUS\r
66EFIAPI\r
67PcdDxeInit (\r
68 IN EFI_HANDLE ImageHandle,\r
69 IN EFI_SYSTEM_TABLE *SystemTable\r
70 )\r
71{\r
52e1905d 72 EFI_STATUS Status;\r
73\r
74 //\r
75 // Make sure the Pcd Protocol is not already installed in the system\r
76 //\r
4f242357 77\r
52e1905d 78 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid);\r
2a505eac 79\r
52e1905d 80 BuildPcdDxeDataBase ();\r
81\r
82 //\r
83 // BugBug Check if PcdDatabase is already installed.\r
84 //\r
878ddf1f 85 \r
86 Status = gBS->InstallProtocolInterface (\r
87 &NewHandle,\r
88 &gPcdProtocolGuid,\r
89 EFI_NATIVE_INTERFACE,\r
90 &mPcdInstance\r
91 );\r
92\r
93 ASSERT_EFI_ERROR (Status);\r
94\r
95 return EFI_SUCCESS;\r
96\r
97}\r
98\r
99\r
00b7af13 100VOID\r
878ddf1f 101EFIAPI\r
102DxePcdSetSku (\r
8a43e8dd 103 IN UINTN SkuId\r
878ddf1f 104 )\r
105{\r
8a43e8dd 106 mPcdDatabase->PeiDb.Init.SystemSkuId = (SKU_ID) SkuId;\r
00b7af13 107 \r
108 return;\r
878ddf1f 109}\r
110\r
111\r
112\r
113UINT8\r
114EFIAPI\r
115DxePcdGet8 (\r
8a43e8dd 116 IN UINTN TokenNumber\r
878ddf1f 117 )\r
118{\r
9d6d8b24 119 return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));\r
878ddf1f 120}\r
121\r
122\r
123\r
124UINT16\r
125EFIAPI\r
126DxePcdGet16 (\r
8a43e8dd 127 IN UINTN TokenNumber\r
878ddf1f 128 )\r
129{\r
9d6d8b24 130 return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));\r
878ddf1f 131}\r
132\r
133\r
134\r
135UINT32\r
136EFIAPI\r
137DxePcdGet32 (\r
8a43e8dd 138 IN UINTN TokenNumber\r
878ddf1f 139 )\r
140{\r
9d6d8b24 141 return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));\r
878ddf1f 142}\r
143\r
144\r
145\r
146UINT64\r
147EFIAPI\r
148DxePcdGet64 (\r
8a43e8dd 149 IN UINTN TokenNumber\r
878ddf1f 150 )\r
151{\r
9d6d8b24 152 return ReadUnaligned64(GetWorker (TokenNumber, sizeof (UINT64)));\r
878ddf1f 153}\r
154\r
155\r
156\r
157VOID *\r
158EFIAPI\r
159DxePcdGetPtr (\r
8a43e8dd 160 IN UINTN TokenNumber\r
878ddf1f 161 )\r
162{\r
9d6d8b24 163 return GetWorker (TokenNumber, 0);\r
878ddf1f 164}\r
165\r
166\r
167\r
168BOOLEAN\r
169EFIAPI\r
170DxePcdGetBool (\r
8a43e8dd 171 IN UINTN TokenNumber\r
878ddf1f 172 )\r
173{\r
9d6d8b24 174 return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));\r
878ddf1f 175}\r
176\r
177\r
178\r
179UINTN\r
180EFIAPI\r
181DxePcdGetSize (\r
8a43e8dd 182 IN UINTN TokenNumber\r
878ddf1f 183 )\r
184{\r
52e1905d 185 UINT16 * SizeTable;\r
58f1099f 186 //\r
187 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
188 // We have to decrement TokenNumber by 1 to make it usable\r
189 // as the array index.\r
190 //\r
191 TokenNumber--;\r
192 \r
4c114006 193 SizeTable = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? mPcdDatabase->PeiDb.Init.SizeTable :\r
194 mPcdDatabase->DxeDb.Init.SizeTable;\r
52e1905d 195\r
196\r
197 TokenNumber = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? TokenNumber : (TokenNumber - PEI_LOCAL_TOKEN_NUMBER);\r
198\r
199 return SizeTable[TokenNumber];\r
878ddf1f 200}\r
201\r
202\r
203\r
204UINT8\r
205EFIAPI\r
206DxePcdGet8Ex (\r
52e1905d 207 IN CONST EFI_GUID *Guid,\r
8a43e8dd 208 IN UINTN ExTokenNumber\r
878ddf1f 209 )\r
210{\r
52e1905d 211 return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT8)));\r
878ddf1f 212}\r
213\r
214\r
215\r
216UINT16\r
217EFIAPI\r
218DxePcdGet16Ex (\r
219 IN CONST EFI_GUID *Guid,\r
8a43e8dd 220 IN UINTN ExTokenNumber\r
878ddf1f 221 )\r
222{\r
9d6d8b24 223 return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT16)));\r
878ddf1f 224}\r
225\r
226\r
227\r
228UINT32\r
229EFIAPI\r
230DxePcdGet32Ex (\r
231 IN CONST EFI_GUID *Guid,\r
8a43e8dd 232 IN UINTN ExTokenNumber\r
878ddf1f 233 )\r
234{\r
9d6d8b24 235 return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT32)));\r
878ddf1f 236}\r
237\r
238\r
239\r
240UINT64\r
241EFIAPI\r
242DxePcdGet64Ex (\r
243 IN CONST EFI_GUID *Guid,\r
8a43e8dd 244 IN UINTN ExTokenNumber\r
878ddf1f 245 )\r
246{\r
9d6d8b24 247 return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT64)));\r
878ddf1f 248}\r
249\r
250\r
251\r
252VOID *\r
253EFIAPI\r
254DxePcdGetPtrEx (\r
255 IN CONST EFI_GUID *Guid,\r
8a43e8dd 256 IN UINTN ExTokenNumber\r
878ddf1f 257 )\r
258{\r
52e1905d 259 return ExGetWorker (Guid, ExTokenNumber, 0);\r
878ddf1f 260}\r
261\r
262\r
263\r
264BOOLEAN\r
265EFIAPI\r
266DxePcdGetBoolEx (\r
267 IN CONST EFI_GUID *Guid,\r
8a43e8dd 268 IN UINTN ExTokenNumber\r
878ddf1f 269 )\r
270{\r
52e1905d 271 return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof(BOOLEAN)));\r
878ddf1f 272}\r
273\r
274\r
275\r
276UINTN\r
277EFIAPI\r
278DxePcdGetSizeEx (\r
279 IN CONST EFI_GUID *Guid,\r
8a43e8dd 280 IN UINTN ExTokenNumber\r
878ddf1f 281 )\r
282{\r
4f242357 283 return DxePcdGetSize(GetExPcdTokenNumber (Guid, (UINT32) ExTokenNumber));\r
878ddf1f 284}\r
285\r
286\r
287\r
288EFI_STATUS\r
289EFIAPI\r
290DxePcdSet8 (\r
8a43e8dd 291 IN UINTN TokenNumber,\r
52e1905d 292 IN UINT8 Value\r
878ddf1f 293 )\r
294{\r
52e1905d 295 return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);\r
878ddf1f 296}\r
297\r
298\r
299\r
300EFI_STATUS\r
301EFIAPI\r
302DxePcdSet16 (\r
8a43e8dd 303 IN UINTN TokenNumber,\r
878ddf1f 304 IN UINT16 Value\r
305 )\r
306{\r
52e1905d 307 return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);\r
878ddf1f 308}\r
309\r
310\r
311\r
312EFI_STATUS\r
313EFIAPI\r
314DxePcdSet32 (\r
8a43e8dd 315 IN UINTN TokenNumber,\r
878ddf1f 316 IN UINT32 Value\r
317 )\r
318{\r
52e1905d 319 return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);\r
878ddf1f 320}\r
321\r
322\r
323\r
324EFI_STATUS\r
325EFIAPI\r
326DxePcdSet64 (\r
8a43e8dd 327 IN UINTN TokenNumber,\r
52e1905d 328 IN UINT64 Value\r
878ddf1f 329 )\r
330{\r
52e1905d 331 return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);\r
878ddf1f 332}\r
333\r
334\r
335\r
336EFI_STATUS\r
337EFIAPI\r
338DxePcdSetPtr (\r
8a43e8dd 339 IN UINTN TokenNumber,\r
00b7af13 340 IN UINTN SizeOfBuffer,\r
341 IN VOID *Buffer\r
878ddf1f 342 )\r
343{\r
00b7af13 344 return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);\r
878ddf1f 345}\r
346\r
347\r
348\r
349EFI_STATUS\r
350EFIAPI\r
351DxePcdSetBool (\r
8a43e8dd 352 IN UINTN TokenNumber,\r
52e1905d 353 IN BOOLEAN Value\r
878ddf1f 354 )\r
355{\r
52e1905d 356 return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);\r
878ddf1f 357}\r
358\r
359\r
360\r
361EFI_STATUS\r
362EFIAPI\r
363DxePcdSet8Ex (\r
4c114006 364 IN CONST EFI_GUID *Guid,\r
8a43e8dd 365 IN UINTN ExTokenNumber,\r
52e1905d 366 IN UINT8 Value\r
878ddf1f 367 )\r
368{\r
52e1905d 369 return ExSetWorker(\r
370 ExTokenNumber, \r
371 Guid,\r
372 &Value, \r
373 sizeof (Value), \r
374 FALSE\r
375 );\r
878ddf1f 376}\r
377\r
378\r
379\r
380EFI_STATUS\r
381EFIAPI\r
382DxePcdSet16Ex (\r
4c114006 383 IN CONST EFI_GUID *Guid,\r
8a43e8dd 384 IN UINTN ExTokenNumber,\r
878ddf1f 385 IN UINT16 Value\r
386 )\r
387{\r
52e1905d 388 return ExSetWorker(\r
389 ExTokenNumber, \r
390 Guid,\r
391 &Value, \r
392 sizeof (Value), \r
393 FALSE\r
394 );\r
878ddf1f 395}\r
396\r
397\r
398\r
399EFI_STATUS\r
400EFIAPI\r
401DxePcdSet32Ex (\r
4c114006 402 IN CONST EFI_GUID *Guid,\r
8a43e8dd 403 IN UINTN ExTokenNumber,\r
878ddf1f 404 IN UINT32 Value\r
405 )\r
406{\r
52e1905d 407 return ExSetWorker(\r
408 ExTokenNumber, \r
409 Guid,\r
410 &Value, \r
411 sizeof (Value), \r
412 FALSE\r
413 );\r
878ddf1f 414}\r
415\r
416\r
417\r
418EFI_STATUS\r
419EFIAPI\r
420DxePcdSet64Ex (\r
4c114006 421 IN CONST EFI_GUID *Guid,\r
8a43e8dd 422 IN UINTN ExTokenNumber,\r
878ddf1f 423 IN UINT64 Value\r
424 )\r
425{\r
52e1905d 426 return ExSetWorker(\r
427 ExTokenNumber, \r
428 Guid,\r
429 &Value, \r
430 sizeof (Value), \r
431 FALSE\r
432 );\r
878ddf1f 433}\r
434\r
435\r
436\r
437EFI_STATUS\r
438EFIAPI\r
439DxePcdSetPtrEx (\r
00b7af13 440 IN CONST EFI_GUID *Guid,\r
8a43e8dd 441 IN UINTN ExTokenNumber,\r
00b7af13 442 IN UINTN SizeOfBuffer,\r
443 IN VOID *Buffer\r
878ddf1f 444 )\r
445{\r
52e1905d 446 return ExSetWorker(\r
447 ExTokenNumber, \r
448 Guid,\r
00b7af13 449 Buffer, \r
450 SizeOfBuffer, \r
52e1905d 451 TRUE\r
452 );\r
878ddf1f 453}\r
454\r
455\r
456\r
457EFI_STATUS\r
458EFIAPI\r
459DxePcdSetBoolEx (\r
4c114006 460 IN CONST EFI_GUID *Guid,\r
8a43e8dd 461 IN UINTN ExTokenNumber,\r
878ddf1f 462 IN BOOLEAN Value\r
463 )\r
464{\r
52e1905d 465 return ExSetWorker(\r
466 ExTokenNumber, \r
467 Guid,\r
468 &Value, \r
469 sizeof (Value), \r
470 TRUE\r
471 );\r
878ddf1f 472}\r
473\r
474\r
475\r
476\r
477EFI_STATUS\r
478EFIAPI\r
4c114006 479DxeRegisterCallBackOnSet (\r
8a43e8dd 480 IN UINTN TokenNumber,\r
4c114006 481 IN CONST EFI_GUID *Guid, OPTIONAL\r
878ddf1f 482 IN PCD_PROTOCOL_CALLBACK CallBackFunction\r
483 )\r
484{\r
4c114006 485 ASSERT (CallBackFunction != NULL);\r
486 \r
487 return DxeRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction);\r
878ddf1f 488}\r
489\r
490\r
491\r
492EFI_STATUS\r
493EFIAPI\r
4c114006 494DxeUnRegisterCallBackOnSet (\r
8a43e8dd 495 IN UINTN TokenNumber,\r
4c114006 496 IN CONST EFI_GUID *Guid, OPTIONAL\r
878ddf1f 497 IN PCD_PROTOCOL_CALLBACK CallBackFunction\r
498 )\r
499{\r
4c114006 500 ASSERT (CallBackFunction != NULL);\r
501 \r
58f1099f 502 return DxeUnRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction);\r
878ddf1f 503}\r
504\r
505\r
506\r
507EFI_STATUS\r
508EFIAPI\r
509DxePcdGetNextToken (\r
4c114006 510 IN CONST EFI_GUID *Guid, OPTIONAL\r
8a43e8dd 511 IN OUT UINTN *TokenNumber\r
878ddf1f 512 )\r
513{\r
8a43e8dd 514 UINTN ExTokenNumber;\r
4c114006 515 \r
516 //\r
517 // Scan the local token space\r
518 //\r
519 if (Guid == NULL) {\r
dcec7651 520 (*TokenNumber)++;\r
4c114006 521 if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r
522 return EFI_SUCCESS;\r
523 } else {\r
524 if (*TokenNumber >= PEI_NEX_TOKEN_NUMBER &&\r
525 *TokenNumber < PEI_LOCAL_TOKEN_NUMBER) {\r
526 //\r
527 // The first Non-Ex type Token Number for DXE PCD \r
528 // database is PEI_LOCAL_TOKEN_NUMBER\r
529 //\r
530 *TokenNumber = PEI_LOCAL_TOKEN_NUMBER;\r
531 return EFI_SUCCESS;\r
532 } else if (*TokenNumber >= DXE_NEX_TOKEN_NUMBER + PEI_LOCAL_TOKEN_NUMBER) {\r
533 *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
534 return EFI_SUCCESS;\r
535 }\r
536 }\r
537 }\r
538\r
539 if (PEI_EXMAP_TABLE_EMPTY && PEI_EXMAP_TABLE_EMPTY) {\r
540 *TokenNumber = (UINTN) PCD_INVALID_TOKEN_NUMBER;\r
541 return EFI_NOT_FOUND;\r
542 }\r
543\r
544 ExTokenNumber = *TokenNumber;\r
545 if (!PEI_EXMAP_TABLE_EMPTY) {\r
546 ExTokenNumber = ExGetNextTokeNumber (\r
547 Guid,\r
548 ExTokenNumber,\r
549 mPcdDatabase->PeiDb.Init.GuidTable,\r
550 sizeof(mPcdDatabase->PeiDb.Init.GuidTable),\r
551 mPcdDatabase->PeiDb.Init.ExMapTable,\r
552 sizeof(mPcdDatabase->PeiDb.Init.ExMapTable)\r
553 );\r
554 }\r
555\r
4276d5da 556 if ((ExTokenNumber == PCD_INVALID_TOKEN_NUMBER) &&\r
557 !DXE_EXMAP_TABLE_EMPTY\r
558 ) {\r
4c114006 559 ExTokenNumber = ExGetNextTokeNumber (\r
560 Guid,\r
561 ExTokenNumber,\r
562 mPcdDatabase->PeiDb.Init.GuidTable,\r
563 sizeof(mPcdDatabase->PeiDb.Init.GuidTable),\r
564 mPcdDatabase->PeiDb.Init.ExMapTable,\r
565 sizeof(mPcdDatabase->PeiDb.Init.ExMapTable)\r
566 );\r
567 }\r
568\r
569 *TokenNumber = ExTokenNumber;\r
570\r
571 return EFI_SUCCESS;\r
878ddf1f 572}\r
573\r
4276d5da 574\r
575EFI_GUID **\r
576GetDistinctTokenSpace (\r
577 IN OUT UINTN *ExMapTableSize,\r
578 IN DYNAMICEX_MAPPING *ExMapTable,\r
579 IN EFI_GUID *GuidTable\r
580 )\r
581{\r
582 EFI_GUID **DistinctTokenSpace;\r
583 UINTN OldGuidIndex;\r
584 UINTN TsIdx;\r
585 UINTN Idx;\r
586\r
587\r
588 DistinctTokenSpace = AllocateZeroPool (*ExMapTableSize * sizeof (EFI_GUID *));\r
589 ASSERT (DistinctTokenSpace != NULL);\r
590\r
591 TsIdx = 0;\r
592 OldGuidIndex = ExMapTable[0].ExGuidIndex;\r
593 DistinctTokenSpace[TsIdx] = &GuidTable[OldGuidIndex];\r
594 for (Idx = 1; Idx < PEI_EXMAPPING_TABLE_SIZE; Idx++) {\r
595 if (ExMapTable[Idx].ExGuidIndex != OldGuidIndex) {\r
596 OldGuidIndex = ExMapTable[Idx].ExGuidIndex;\r
597 DistinctTokenSpace[++TsIdx] = &GuidTable[OldGuidIndex];\r
598 }\r
599 }\r
600\r
601 *ExMapTableSize = TsIdx;\r
602 return DistinctTokenSpace;\r
603 \r
604}\r
605 \r
606\r
607STATIC EFI_GUID *TmpTokenSpaceBuffer[PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE] = { 0 };\r
608\r
609EFI_STATUS\r
610EFIAPI\r
611DxePcdGetNextTokenSpace (\r
612 IN OUT CONST EFI_GUID **Guid\r
613 )\r
614{\r
615 UINTN Idx;\r
616 UINTN Idx2;\r
617 UINTN Idx3;\r
618 UINTN PeiTokenSpaceTableSize;\r
619 UINTN DxeTokenSpaceTableSize;\r
620 EFI_GUID **PeiTokenSpaceTable;\r
621 EFI_GUID **DxeTokenSpaceTable;\r
622 BOOLEAN Match;\r
623\r
624 ASSERT (Guid != NULL);\r
625 \r
626 if (PEI_EXMAP_TABLE_EMPTY && DXE_EXMAP_TABLE_EMPTY) {\r
627 if (*Guid != NULL) {\r
628 return EFI_NOT_FOUND;\r
629 } else {\r
630 return EFI_SUCCESS;\r
631 }\r
632 }\r
633 \r
634 \r
635 if (TmpTokenSpaceBuffer[0] != NULL) {\r
636 PeiTokenSpaceTableSize = 0;\r
637\r
638 if (!PEI_EXMAP_TABLE_EMPTY) {\r
639 PeiTokenSpaceTableSize = PEI_EXMAPPING_TABLE_SIZE;\r
640 PeiTokenSpaceTable = GetDistinctTokenSpace (&PeiTokenSpaceTableSize,\r
641 mPcdDatabase->PeiDb.Init.ExMapTable,\r
642 mPcdDatabase->PeiDb.Init.GuidTable\r
643 );\r
644 CopyMem (TmpTokenSpaceBuffer, PeiTokenSpaceTable, sizeof (EFI_GUID*) * PeiTokenSpaceTableSize);\r
645 }\r
646\r
647 if (!DXE_EXMAP_TABLE_EMPTY) {\r
648 DxeTokenSpaceTableSize = DXE_EXMAPPING_TABLE_SIZE;\r
649 DxeTokenSpaceTable = GetDistinctTokenSpace (&DxeTokenSpaceTableSize,\r
650 mPcdDatabase->DxeDb.Init.ExMapTable,\r
651 mPcdDatabase->DxeDb.Init.GuidTable\r
652 );\r
653\r
654 //\r
655 // Make sure EFI_GUID in DxeTokenSpaceTable does not exist in PeiTokenSpaceTable\r
656 //\r
657 for (Idx2 = 0, Idx3 = PeiTokenSpaceTableSize; Idx2 < DxeTokenSpaceTableSize; Idx2++) {\r
658 Match = FALSE;\r
659 for (Idx = 0; Idx < PeiTokenSpaceTableSize; Idx++) {\r
660 if (CompareGuid (TmpTokenSpaceBuffer[Idx], DxeTokenSpaceTable[Idx2])) {\r
661 Match = TRUE;\r
662 break;\r
663 }\r
664 }\r
665 if (!Match) {\r
666 TmpTokenSpaceBuffer[Idx3++] = DxeTokenSpaceTable[Idx2];\r
667 }\r
668 }\r
669 }\r
670 }\r
671\r
672 if (*Guid == NULL) {\r
673 *Guid = TmpTokenSpaceBuffer[0];\r
674 return EFI_SUCCESS;\r
675 }\r
676 \r
677 for (Idx = 0; Idx < (PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE); Idx++) {\r
678 if(CompareGuid (*Guid, TmpTokenSpaceBuffer[Idx])) {\r
679 Idx++;\r
680 *Guid = TmpTokenSpaceBuffer[Idx];\r
681 return EFI_SUCCESS;\r
682 }\r
683 }\r
684\r
685 return EFI_NOT_FOUND;\r
686\r
687}\r
688\r
689\r