Corrected a typo error.
[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
1de04b4f 185 UINTN Size;\r
186 UINT32 *LocalTokenNumberTable;\r
187 BOOLEAN IsPeiDb;\r
188 UINTN MaxSize;\r
189 UINTN TmpTokenNumber;\r
58f1099f 190 //\r
191 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.\r
192 // We have to decrement TokenNumber by 1 to make it usable\r
193 // as the array index.\r
194 //\r
195 TokenNumber--;\r
1de04b4f 196\r
197 //\r
198 // Backup the TokenNumber passed in as GetPtrTypeSize need the original TokenNumber\r
199 // \r
200 TmpTokenNumber = TokenNumber;\r
201\r
202 ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);\r
203\r
204 IsPeiDb = (BOOLEAN) (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);\r
58f1099f 205 \r
1de04b4f 206 TokenNumber = IsPeiDb ? TokenNumber : \r
207 (TokenNumber - PEI_LOCAL_TOKEN_NUMBER);\r
52e1905d 208\r
1de04b4f 209 LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable \r
210 : mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;\r
52e1905d 211\r
1de04b4f 212 Size = (LocalTokenNumberTable[TokenNumber] & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;\r
213\r
214 if (Size == 0) {\r
215 //\r
216 // For pointer type, we need to scan the SIZE_TABLE to get the current size.\r
217 //\r
218 return GetPtrTypeSize (TmpTokenNumber, &MaxSize);\r
219 } else {\r
220 return Size;\r
221 }\r
52e1905d 222\r
878ddf1f 223}\r
224\r
225\r
226\r
227UINT8\r
228EFIAPI\r
229DxePcdGet8Ex (\r
52e1905d 230 IN CONST EFI_GUID *Guid,\r
8a43e8dd 231 IN UINTN ExTokenNumber\r
878ddf1f 232 )\r
233{\r
52e1905d 234 return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT8)));\r
878ddf1f 235}\r
236\r
237\r
238\r
239UINT16\r
240EFIAPI\r
241DxePcdGet16Ex (\r
242 IN CONST EFI_GUID *Guid,\r
8a43e8dd 243 IN UINTN ExTokenNumber\r
878ddf1f 244 )\r
245{\r
9d6d8b24 246 return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT16)));\r
878ddf1f 247}\r
248\r
249\r
250\r
251UINT32\r
252EFIAPI\r
253DxePcdGet32Ex (\r
254 IN CONST EFI_GUID *Guid,\r
8a43e8dd 255 IN UINTN ExTokenNumber\r
878ddf1f 256 )\r
257{\r
9d6d8b24 258 return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT32)));\r
878ddf1f 259}\r
260\r
261\r
262\r
263UINT64\r
264EFIAPI\r
265DxePcdGet64Ex (\r
266 IN CONST EFI_GUID *Guid,\r
8a43e8dd 267 IN UINTN ExTokenNumber\r
878ddf1f 268 )\r
269{\r
9d6d8b24 270 return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof(UINT64)));\r
878ddf1f 271}\r
272\r
273\r
274\r
275VOID *\r
276EFIAPI\r
277DxePcdGetPtrEx (\r
278 IN CONST EFI_GUID *Guid,\r
8a43e8dd 279 IN UINTN ExTokenNumber\r
878ddf1f 280 )\r
281{\r
1de04b4f 282 return ExGetWorker (Guid, ExTokenNumber, 0);\r
878ddf1f 283}\r
284\r
285\r
286\r
287BOOLEAN\r
288EFIAPI\r
289DxePcdGetBoolEx (\r
290 IN CONST EFI_GUID *Guid,\r
8a43e8dd 291 IN UINTN ExTokenNumber\r
878ddf1f 292 )\r
293{\r
52e1905d 294 return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof(BOOLEAN)));\r
878ddf1f 295}\r
296\r
297\r
298\r
299UINTN\r
300EFIAPI\r
301DxePcdGetSizeEx (\r
302 IN CONST EFI_GUID *Guid,\r
8a43e8dd 303 IN UINTN ExTokenNumber\r
878ddf1f 304 )\r
305{\r
4f242357 306 return DxePcdGetSize(GetExPcdTokenNumber (Guid, (UINT32) ExTokenNumber));\r
878ddf1f 307}\r
308\r
309\r
310\r
311EFI_STATUS\r
312EFIAPI\r
313DxePcdSet8 (\r
8a43e8dd 314 IN UINTN TokenNumber,\r
52e1905d 315 IN UINT8 Value\r
878ddf1f 316 )\r
317{\r
1de04b4f 318 return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
878ddf1f 319}\r
320\r
321\r
322\r
323EFI_STATUS\r
324EFIAPI\r
325DxePcdSet16 (\r
8a43e8dd 326 IN UINTN TokenNumber,\r
878ddf1f 327 IN UINT16 Value\r
328 )\r
329{\r
1de04b4f 330 return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
878ddf1f 331}\r
332\r
333\r
334\r
335EFI_STATUS\r
336EFIAPI\r
337DxePcdSet32 (\r
8a43e8dd 338 IN UINTN TokenNumber,\r
878ddf1f 339 IN UINT32 Value\r
340 )\r
341{\r
1de04b4f 342 return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
878ddf1f 343}\r
344\r
345\r
346\r
347EFI_STATUS\r
348EFIAPI\r
349DxePcdSet64 (\r
8a43e8dd 350 IN UINTN TokenNumber,\r
52e1905d 351 IN UINT64 Value\r
878ddf1f 352 )\r
353{\r
1de04b4f 354 return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
878ddf1f 355}\r
356\r
357\r
358\r
359EFI_STATUS\r
360EFIAPI\r
361DxePcdSetPtr (\r
1de04b4f 362 IN UINTN TokenNumber,\r
363 IN OUT UINTN *SizeOfBuffer,\r
364 IN VOID *Buffer\r
878ddf1f 365 )\r
366{\r
00b7af13 367 return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);\r
878ddf1f 368}\r
369\r
370\r
371\r
372EFI_STATUS\r
373EFIAPI\r
374DxePcdSetBool (\r
8a43e8dd 375 IN UINTN TokenNumber,\r
52e1905d 376 IN BOOLEAN Value\r
878ddf1f 377 )\r
378{\r
1de04b4f 379 return SetValueWorker (TokenNumber, &Value, sizeof (Value));\r
878ddf1f 380}\r
381\r
382\r
383\r
384EFI_STATUS\r
385EFIAPI\r
386DxePcdSet8Ex (\r
4c114006 387 IN CONST EFI_GUID *Guid,\r
8a43e8dd 388 IN UINTN ExTokenNumber,\r
52e1905d 389 IN UINT8 Value\r
878ddf1f 390 )\r
391{\r
1de04b4f 392 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
878ddf1f 393}\r
394\r
395\r
396\r
397EFI_STATUS\r
398EFIAPI\r
399DxePcdSet16Ex (\r
4c114006 400 IN CONST EFI_GUID *Guid,\r
8a43e8dd 401 IN UINTN ExTokenNumber,\r
878ddf1f 402 IN UINT16 Value\r
403 )\r
404{\r
1de04b4f 405 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
878ddf1f 406}\r
407\r
408\r
409\r
410EFI_STATUS\r
411EFIAPI\r
412DxePcdSet32Ex (\r
4c114006 413 IN CONST EFI_GUID *Guid,\r
8a43e8dd 414 IN UINTN ExTokenNumber,\r
878ddf1f 415 IN UINT32 Value\r
416 )\r
417{\r
1de04b4f 418 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
878ddf1f 419}\r
420\r
421\r
422\r
423EFI_STATUS\r
424EFIAPI\r
425DxePcdSet64Ex (\r
4c114006 426 IN CONST EFI_GUID *Guid,\r
8a43e8dd 427 IN UINTN ExTokenNumber,\r
878ddf1f 428 IN UINT64 Value\r
429 )\r
430{\r
1de04b4f 431 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
878ddf1f 432}\r
433\r
434\r
435\r
436EFI_STATUS\r
437EFIAPI\r
438DxePcdSetPtrEx (\r
1de04b4f 439 IN CONST EFI_GUID *Guid,\r
440 IN UINTN ExTokenNumber,\r
441 IN OUT UINTN *SizeOfBuffer,\r
442 IN VOID *Buffer\r
878ddf1f 443 )\r
444{\r
1de04b4f 445 return ExSetWorker(ExTokenNumber, Guid, Buffer, SizeOfBuffer, TRUE);\r
878ddf1f 446}\r
447\r
448\r
449\r
450EFI_STATUS\r
451EFIAPI\r
452DxePcdSetBoolEx (\r
4c114006 453 IN CONST EFI_GUID *Guid,\r
8a43e8dd 454 IN UINTN ExTokenNumber,\r
878ddf1f 455 IN BOOLEAN Value\r
456 )\r
457{\r
1de04b4f 458 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));\r
878ddf1f 459}\r
460\r
461\r
462\r
463\r
464EFI_STATUS\r
465EFIAPI\r
4c114006 466DxeRegisterCallBackOnSet (\r
8a43e8dd 467 IN UINTN TokenNumber,\r
4c114006 468 IN CONST EFI_GUID *Guid, OPTIONAL\r
878ddf1f 469 IN PCD_PROTOCOL_CALLBACK CallBackFunction\r
470 )\r
471{\r
4c114006 472 ASSERT (CallBackFunction != NULL);\r
473 \r
474 return DxeRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction);\r
878ddf1f 475}\r
476\r
477\r
478\r
479EFI_STATUS\r
480EFIAPI\r
4c114006 481DxeUnRegisterCallBackOnSet (\r
8a43e8dd 482 IN UINTN TokenNumber,\r
4c114006 483 IN CONST EFI_GUID *Guid, OPTIONAL\r
878ddf1f 484 IN PCD_PROTOCOL_CALLBACK CallBackFunction\r
485 )\r
486{\r
4c114006 487 ASSERT (CallBackFunction != NULL);\r
488 \r
58f1099f 489 return DxeUnRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction);\r
878ddf1f 490}\r
491\r
492\r
493\r
494EFI_STATUS\r
495EFIAPI\r
496DxePcdGetNextToken (\r
4c114006 497 IN CONST EFI_GUID *Guid, OPTIONAL\r
8a43e8dd 498 IN OUT UINTN *TokenNumber\r
878ddf1f 499 )\r
500{\r
8a43e8dd 501 UINTN ExTokenNumber;\r
4c114006 502 \r
503 //\r
504 // Scan the local token space\r
505 //\r
506 if (Guid == NULL) {\r
dcec7651 507 (*TokenNumber)++;\r
4c114006 508 if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) {\r
509 return EFI_SUCCESS;\r
510 } else {\r
511 if (*TokenNumber >= PEI_NEX_TOKEN_NUMBER &&\r
512 *TokenNumber < PEI_LOCAL_TOKEN_NUMBER) {\r
513 //\r
514 // The first Non-Ex type Token Number for DXE PCD \r
515 // database is PEI_LOCAL_TOKEN_NUMBER\r
516 //\r
517 *TokenNumber = PEI_LOCAL_TOKEN_NUMBER;\r
518 return EFI_SUCCESS;\r
519 } else if (*TokenNumber >= DXE_NEX_TOKEN_NUMBER + PEI_LOCAL_TOKEN_NUMBER) {\r
520 *TokenNumber = PCD_INVALID_TOKEN_NUMBER;\r
521 return EFI_SUCCESS;\r
522 }\r
523 }\r
524 }\r
525\r
526 if (PEI_EXMAP_TABLE_EMPTY && PEI_EXMAP_TABLE_EMPTY) {\r
527 *TokenNumber = (UINTN) PCD_INVALID_TOKEN_NUMBER;\r
528 return EFI_NOT_FOUND;\r
529 }\r
530\r
531 ExTokenNumber = *TokenNumber;\r
532 if (!PEI_EXMAP_TABLE_EMPTY) {\r
533 ExTokenNumber = ExGetNextTokeNumber (\r
534 Guid,\r
535 ExTokenNumber,\r
536 mPcdDatabase->PeiDb.Init.GuidTable,\r
537 sizeof(mPcdDatabase->PeiDb.Init.GuidTable),\r
538 mPcdDatabase->PeiDb.Init.ExMapTable,\r
539 sizeof(mPcdDatabase->PeiDb.Init.ExMapTable)\r
540 );\r
541 }\r
542\r
4276d5da 543 if ((ExTokenNumber == PCD_INVALID_TOKEN_NUMBER) &&\r
544 !DXE_EXMAP_TABLE_EMPTY\r
545 ) {\r
4c114006 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
556 *TokenNumber = ExTokenNumber;\r
557\r
558 return EFI_SUCCESS;\r
878ddf1f 559}\r
560\r
4276d5da 561\r
562EFI_GUID **\r
563GetDistinctTokenSpace (\r
564 IN OUT UINTN *ExMapTableSize,\r
565 IN DYNAMICEX_MAPPING *ExMapTable,\r
566 IN EFI_GUID *GuidTable\r
567 )\r
568{\r
569 EFI_GUID **DistinctTokenSpace;\r
570 UINTN OldGuidIndex;\r
571 UINTN TsIdx;\r
572 UINTN Idx;\r
573\r
574\r
575 DistinctTokenSpace = AllocateZeroPool (*ExMapTableSize * sizeof (EFI_GUID *));\r
576 ASSERT (DistinctTokenSpace != NULL);\r
577\r
578 TsIdx = 0;\r
579 OldGuidIndex = ExMapTable[0].ExGuidIndex;\r
580 DistinctTokenSpace[TsIdx] = &GuidTable[OldGuidIndex];\r
581 for (Idx = 1; Idx < PEI_EXMAPPING_TABLE_SIZE; Idx++) {\r
582 if (ExMapTable[Idx].ExGuidIndex != OldGuidIndex) {\r
583 OldGuidIndex = ExMapTable[Idx].ExGuidIndex;\r
584 DistinctTokenSpace[++TsIdx] = &GuidTable[OldGuidIndex];\r
585 }\r
586 }\r
587\r
588 *ExMapTableSize = TsIdx;\r
589 return DistinctTokenSpace;\r
590 \r
591}\r
592 \r
593\r
594STATIC EFI_GUID *TmpTokenSpaceBuffer[PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE] = { 0 };\r
595\r
596EFI_STATUS\r
597EFIAPI\r
598DxePcdGetNextTokenSpace (\r
599 IN OUT CONST EFI_GUID **Guid\r
600 )\r
601{\r
602 UINTN Idx;\r
603 UINTN Idx2;\r
604 UINTN Idx3;\r
605 UINTN PeiTokenSpaceTableSize;\r
606 UINTN DxeTokenSpaceTableSize;\r
607 EFI_GUID **PeiTokenSpaceTable;\r
608 EFI_GUID **DxeTokenSpaceTable;\r
609 BOOLEAN Match;\r
610\r
611 ASSERT (Guid != NULL);\r
612 \r
613 if (PEI_EXMAP_TABLE_EMPTY && DXE_EXMAP_TABLE_EMPTY) {\r
614 if (*Guid != NULL) {\r
615 return EFI_NOT_FOUND;\r
616 } else {\r
617 return EFI_SUCCESS;\r
618 }\r
619 }\r
620 \r
621 \r
622 if (TmpTokenSpaceBuffer[0] != NULL) {\r
623 PeiTokenSpaceTableSize = 0;\r
624\r
625 if (!PEI_EXMAP_TABLE_EMPTY) {\r
626 PeiTokenSpaceTableSize = PEI_EXMAPPING_TABLE_SIZE;\r
627 PeiTokenSpaceTable = GetDistinctTokenSpace (&PeiTokenSpaceTableSize,\r
628 mPcdDatabase->PeiDb.Init.ExMapTable,\r
629 mPcdDatabase->PeiDb.Init.GuidTable\r
630 );\r
631 CopyMem (TmpTokenSpaceBuffer, PeiTokenSpaceTable, sizeof (EFI_GUID*) * PeiTokenSpaceTableSize);\r
632 }\r
633\r
634 if (!DXE_EXMAP_TABLE_EMPTY) {\r
635 DxeTokenSpaceTableSize = DXE_EXMAPPING_TABLE_SIZE;\r
636 DxeTokenSpaceTable = GetDistinctTokenSpace (&DxeTokenSpaceTableSize,\r
637 mPcdDatabase->DxeDb.Init.ExMapTable,\r
638 mPcdDatabase->DxeDb.Init.GuidTable\r
639 );\r
640\r
641 //\r
642 // Make sure EFI_GUID in DxeTokenSpaceTable does not exist in PeiTokenSpaceTable\r
643 //\r
644 for (Idx2 = 0, Idx3 = PeiTokenSpaceTableSize; Idx2 < DxeTokenSpaceTableSize; Idx2++) {\r
645 Match = FALSE;\r
646 for (Idx = 0; Idx < PeiTokenSpaceTableSize; Idx++) {\r
647 if (CompareGuid (TmpTokenSpaceBuffer[Idx], DxeTokenSpaceTable[Idx2])) {\r
648 Match = TRUE;\r
649 break;\r
650 }\r
651 }\r
652 if (!Match) {\r
653 TmpTokenSpaceBuffer[Idx3++] = DxeTokenSpaceTable[Idx2];\r
654 }\r
655 }\r
656 }\r
657 }\r
658\r
659 if (*Guid == NULL) {\r
660 *Guid = TmpTokenSpaceBuffer[0];\r
661 return EFI_SUCCESS;\r
662 }\r
663 \r
664 for (Idx = 0; Idx < (PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE); Idx++) {\r
665 if(CompareGuid (*Guid, TmpTokenSpaceBuffer[Idx])) {\r
666 Idx++;\r
667 *Guid = TmpTokenSpaceBuffer[Idx];\r
668 return EFI_SUCCESS;\r
669 }\r
670 }\r
671\r
672 return EFI_NOT_FOUND;\r
673\r
674}\r
675\r
676\r