Add in GetNextToken and Register Callback Function funtionality for DXE Driver.
[mirror_edk2.git] / EdkModulePkg / Universal / PCD / Dxe / Service.c
1 /** @file
2 Private functions used by PCD DXE driver.s
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13
14 Module Name: Service.c
15
16 **/
17 #include "Service.h"
18
19
20 //
21 // Build Tool will generate DXE_PCD_DB_INIT_VALUE in Autogen.h
22 // Compression Algorithm will take care of the size optimization.
23 //
24
25 PCD_DATABASE * mPcdDatabase;
26
27 LIST_ENTRY mCallbackFnTable[PCD_TOTAL_TOKEN_NUMBER];
28
29 VOID *
30 GetWorkerByLocalTokenNumber (
31 UINT32 LocalTokenNumber,
32 BOOLEAN IsPeiDb,
33 UINTN Size
34 )
35 {
36 UINT32 Offset;
37 EFI_GUID *GuidTable;
38 UINT16 *StringTable;
39 EFI_GUID *Guid;
40 UINT16 *Name;
41 VARIABLE_HEAD *VariableHead;
42 EFI_STATUS Status;
43 UINTN DataSize;
44 VOID *Data;
45 VPD_HEAD *VpdHead;
46 UINT8 *PcdDb;
47 UINT16 StringTableIdx;
48
49 if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
50 LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size, IsPeiDb);
51 }
52
53 PcdDb = IsPeiDb ? ((UINT8 *) &mPcdDatabase->PeiDb) : ((UINT8 *) &mPcdDatabase->DxeDb);
54 StringTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.StringTable :
55 mPcdDatabase->DxeDb.Init.StringTable;
56
57 Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
58
59 switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
60 case PCD_TYPE_VPD:
61 VpdHead = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset);
62 return (VOID *) (FixedPcdGet32(PcdVpdBaseAddress) + VpdHead->Offset);
63
64 case PCD_TYPE_HII:
65 GuidTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.GuidTable :
66 mPcdDatabase->DxeDb.Init.GuidTable;
67
68 VariableHead = (VARIABLE_HEAD *) (PcdDb + Offset);
69
70 Guid = &(GuidTable[VariableHead->GuidTableIndex]);
71 Name = &(StringTable[VariableHead->StringIndex]);
72
73 Status = GetHiiVariable (Guid, Name, &Data, &DataSize);
74 ASSERT_EFI_ERROR (Status);
75 ASSERT (DataSize >= (UINTN) (VariableHead->Offset + Size));
76
77 return (UINT8 *) Data + VariableHead->Offset;
78
79 case PCD_TYPE_STRING:
80 StringTableIdx = (UINT16) *((UINT8 *) PcdDb + Offset);
81 return (VOID *) &StringTable[StringTableIdx];
82
83 case PCD_TYPE_DATA:
84 return (VOID *) ((UINT8 *) PcdDb + Offset);
85 break;
86
87 default:
88 ASSERT (FALSE);
89 break;
90
91 }
92
93 ASSERT (FALSE);
94
95 return NULL;
96 }
97
98 VOID *
99 GetWorker (
100 UINTN TokenNumber
101 )
102 {
103 UINT32 *LocalTokenNumberTable;
104 UINT16 *SizeTable;
105 BOOLEAN IsPeiDb;
106
107 ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
108
109 IsPeiDb = (TokenNumber <= PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
110
111 LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
112 mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
113
114 SizeTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.SizeTable:
115 mPcdDatabase->DxeDb.Init.SizeTable;
116
117 TokenNumber = IsPeiDb ? TokenNumber :
118 TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
119 return GetWorkerByLocalTokenNumber (LocalTokenNumberTable[TokenNumber], IsPeiDb, SizeTable[TokenNumber]);
120 }
121
122
123
124 EFI_STATUS
125 DxeRegisterCallBackWorker (
126 IN UINTN TokenNumber,
127 IN CONST GUID *Guid, OPTIONAL
128 IN PCD_PROTOCOL_CALLBACK CallBackFunction
129 )
130 {
131 CALLBACK_FN_ENTRY *FnTableEntry;
132 EX_PCD_ENTRY_ATTRIBUTE ExAttr;
133 LIST_ENTRY *ListHead;
134 LIST_ENTRY *ListNode;
135
136 if (Guid != NULL) {
137 GetExPcdTokenAttributes (Guid, TokenNumber, &ExAttr);
138 TokenNumber = ExAttr.LocalTokenNumberAlias;
139 }
140
141 ListHead = &mCallbackFnTable[TokenNumber];
142 ListNode = GetFirstNode (ListHead);
143
144 while (ListNode != ListHead) {
145 FnTableEntry = CR_FNENTRY_FROM_LISTNODE(ListNode, CALLBACK_FN_ENTRY, Node);
146
147 if (FnTableEntry->CallbackFn == CallBackFunction) {
148 //
149 // We only allow a Callback function to be register once
150 // for a TokenNumber. So just return EFI_SUCCESS
151 //
152 return EFI_SUCCESS;
153 }
154 ListNode = GetNextNode (ListHead, ListNode);
155 }
156
157 FnTableEntry = AllocatePool (sizeof(CALLBACK_FN_ENTRY));
158 ASSERT (FnTableEntry != NULL);
159
160 FnTableEntry->CallbackFn = CallBackFunction;
161 InsertTailList (ListHead, &FnTableEntry->Node);
162
163 return EFI_SUCCESS;
164 }
165
166
167
168
169 EFI_STATUS
170 DxeUnRegisterCallBackWorker (
171 IN UINTN TokenNumber,
172 IN CONST GUID *Guid, OPTIONAL
173 IN PCD_PROTOCOL_CALLBACK CallBackFunction
174 )
175 {
176 CALLBACK_FN_ENTRY *FnTableEntry;
177 EX_PCD_ENTRY_ATTRIBUTE ExAttr;
178 LIST_ENTRY *ListHead;
179 LIST_ENTRY *ListNode;
180
181 if (Guid != NULL) {
182 GetExPcdTokenAttributes (Guid, TokenNumber, &ExAttr);
183 TokenNumber = ExAttr.LocalTokenNumberAlias;
184 }
185
186 ListHead = &mCallbackFnTable[TokenNumber];
187 ListNode = GetFirstNode (ListHead);
188
189 while (ListNode != ListHead) {
190 FnTableEntry = CR_FNENTRY_FROM_LISTNODE(ListNode, CALLBACK_FN_ENTRY, Node);
191
192 if (FnTableEntry->CallbackFn == CallBackFunction) {
193 //
194 // We only allow a Callback function to be register once
195 // for a TokenNumber. So we can safely remove the Node from
196 // the Link List and return EFI_SUCCESS.
197 //
198 RemoveEntryList (ListNode);
199 FreePool (FnTableEntry);
200
201 return EFI_SUCCESS;
202 }
203 ListNode = GetNextNode (ListHead, ListNode);
204 }
205
206 return EFI_INVALID_PARAMETER;
207 }
208
209
210
211 PCD_TOKEN_NUMBER
212 ExGetNextTokeNumber (
213 IN CONST EFI_GUID *Guid,
214 IN PCD_TOKEN_NUMBER TokenNumber,
215 IN EFI_GUID *GuidTable,
216 IN UINTN SizeOfGuidTable,
217 IN DYNAMICEX_MAPPING *ExMapTable,
218 IN UINTN SizeOfExMapTable
219 )
220 {
221 EFI_GUID *MatchGuid;
222 UINTN Idx;
223 UINTN GuidTableIdx;
224 BOOLEAN Found;
225
226 MatchGuid = ScanGuid (GuidTable, SizeOfGuidTable, Guid);
227 if (MatchGuid == NULL) {
228 return PCD_INVALID_TOKEN_NUMBER;
229 }
230
231 Found = FALSE;
232 GuidTableIdx = MatchGuid - GuidTable;
233 for (Idx = 0; Idx < SizeOfExMapTable; Idx++) {
234 if (ExMapTable[Idx].ExGuidIndex == GuidTableIdx) {
235 Found = TRUE;
236 break;
237 }
238 }
239
240 if (Found) {
241 if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
242 return ExMapTable[Idx].ExTokenNumber;
243 }
244
245 for ( ; Idx < SizeOfExMapTable; Idx++) {
246 if (ExMapTable[Idx].ExTokenNumber == TokenNumber) {
247 Idx++;
248 if (Idx == SizeOfExMapTable) {
249 //
250 // Exceed the length of ExMap Table
251 //
252 return PCD_INVALID_TOKEN_NUMBER;
253 } else if (ExMapTable[Idx].ExGuidIndex == GuidTableIdx) {
254 //
255 // Found the next match
256 //
257 return ExMapTable[Idx].ExTokenNumber;
258 } else {
259 //
260 // Guid has been changed. It is the next Token Space Guid.
261 // We should flag no more TokenNumber.
262 //
263 return PCD_INVALID_TOKEN_NUMBER;
264 }
265 }
266 }
267 }
268
269 return PCD_INVALID_TOKEN_NUMBER;
270 }
271
272
273
274
275 VOID
276 BuildPcdDxeDataBase (
277 VOID
278 )
279 {
280 PEI_PCD_DATABASE *PeiDatabase;
281 EFI_HOB_GUID_TYPE *GuidHob;
282 UINTN Idx;
283
284 mPcdDatabase = AllocateZeroPool (sizeof(PCD_DATABASE));
285 ASSERT (mPcdDatabase != NULL);
286
287 GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);
288 ASSERT (GuidHob != NULL);
289
290 PeiDatabase = (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
291 //
292 // Copy PCD Entries refereneced in PEI phase to PCD DATABASE
293 //
294 CopyMem (&mPcdDatabase->PeiDb, PeiDatabase, sizeof (PEI_PCD_DATABASE));
295
296 //
297 // Copy PCD Entries with default value to PCD DATABASE
298 //
299 CopyMem (&mPcdDatabase->DxeDb.Init, &gDXEPcdDbInit, sizeof(DXE_PCD_DATABASE_INIT));
300
301
302 //
303 // Initialized the Callback Function Table
304 //
305 for (Idx = 0; Idx < PCD_TOTAL_TOKEN_NUMBER; Idx++) {
306 InitializeListHead (&mCallbackFnTable[Idx]);
307 }
308
309 return;
310 }
311
312
313
314 EFI_STATUS
315 GetHiiVariable (
316 IN EFI_GUID *VariableGuid,
317 IN UINT16 *VariableName,
318 OUT VOID ** VariableData,
319 OUT UINTN *VariableSize
320 )
321 {
322 UINTN Size;
323 EFI_STATUS Status;
324 VOID *Buffer;
325
326 Status = EfiGetVariable (
327 (UINT16 *)VariableName,
328 VariableGuid,
329 NULL,
330 &Size,
331 NULL
332 );
333 ASSERT (Status == EFI_BUFFER_TOO_SMALL);
334
335 Buffer = AllocatePool (Size);
336
337 ASSERT (Buffer != NULL);
338
339 Status = EfiGetVariable (
340 VariableName,
341 VariableGuid,
342 NULL,
343 &Size,
344 Buffer
345 );
346
347 return Status;
348
349 }
350
351
352 UINT32
353 GetSkuEnabledTokenNumber (
354 UINT32 LocalTokenNumber,
355 UINTN Size,
356 BOOLEAN IsPeiDb
357 )
358 {
359 SKU_HEAD *SkuHead;
360 SKU_ID *SkuIdTable;
361 INTN i;
362 UINT8 *Value;
363 SKU_ID *PhaseSkuIdTable;
364 UINT8 *PcdDb;
365
366 ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0);
367
368 PcdDb = IsPeiDb ? (UINT8 *) &mPcdDatabase->PeiDb : (UINT8 *) &mPcdDatabase->DxeDb;
369
370 SkuHead = (SKU_HEAD *) (PcdDb + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));
371 Value = (UINT8 *) (PcdDb + SkuHead->SkuDataStartOffset);
372
373 PhaseSkuIdTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.SkuIdTable :
374 mPcdDatabase->DxeDb.Init.SkuIdTable;
375
376 SkuIdTable = &PhaseSkuIdTable[SkuHead->SkuIdTableOffset];
377
378 for (i = 0; i < SkuIdTable[0]; i++) {
379 if (mPcdDatabase->PeiDb.Init.SystemSkuId == SkuIdTable[i + 1]) {
380 break;
381 }
382 }
383 ASSERT (i < SkuIdTable[0]);
384
385 switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
386 case PCD_TYPE_VPD:
387 Value = (UINT8 *) &(((VPD_HEAD *) Value)[i]);
388 return ((Value - PcdDb) | PCD_TYPE_VPD);
389
390 case PCD_TYPE_HII:
391 Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[i]);
392 return ((Value - PcdDb) | PCD_TYPE_HII);
393
394 case PCD_TYPE_DATA:
395 Value += Size * i;
396 return (Value - PcdDb);
397
398 default:
399 ASSERT (FALSE);
400 }
401
402 ASSERT (FALSE);
403
404 return 0;
405
406 }
407
408
409
410
411
412 VOID
413 InvokeCallbackOnSet (
414 UINT32 ExTokenNumber,
415 CONST EFI_GUID *Guid, OPTIONAL
416 UINTN TokenNumber,
417 VOID *Data,
418 UINTN Size
419 )
420 {
421 CALLBACK_FN_ENTRY *FnTableEntry;
422 LIST_ENTRY *ListHead;
423 LIST_ENTRY *ListNode;
424
425 ListHead = &mCallbackFnTable[TokenNumber];
426 ListNode = GetFirstNode (ListHead);
427
428 while (ListNode != ListHead) {
429 FnTableEntry = CR_FNENTRY_FROM_LISTNODE(ListNode, CALLBACK_FN_ENTRY, Node);
430
431 FnTableEntry->CallbackFn(Guid,
432 (Guid == NULL) ? TokenNumber : ExTokenNumber,
433 Data,
434 Size);
435
436 ListNode = GetNextNode (ListHead, ListNode);
437 }
438
439 return;
440 }
441
442
443
444
445 EFI_STATUS
446 SetWorker (
447 UINTN TokenNumber,
448 VOID *Data,
449 UINTN Size,
450 BOOLEAN PtrType
451 )
452 {
453 UINT32 *LocalTokenNumberTable;
454 BOOLEAN IsPeiDb;
455
456
457 ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
458
459 if (PtrType) {
460 ASSERT (Size <= DxePcdGetSize (TokenNumber));
461 } else {
462 ASSERT (Size == DxePcdGetSize (TokenNumber));
463 }
464
465 IsPeiDb = (TokenNumber <= PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
466
467 LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
468 mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
469
470 TokenNumber = IsPeiDb ? TokenNumber
471 : TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
472
473 InvokeCallbackOnSet (0, NULL, TokenNumber, Data, Size);
474
475 return SetWorkerByLocalTokenNumber (LocalTokenNumberTable[TokenNumber], Data, Size, PtrType, IsPeiDb);
476
477 }
478
479
480
481
482
483 VOID *
484 ExGetWorker (
485 IN CONST EFI_GUID *Guid,
486 IN UINTN ExTokenNumber,
487 IN UINTN GetSize
488 )
489 {
490 EX_PCD_ENTRY_ATTRIBUTE Attr;
491
492 GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
493
494 ASSERT ((GetSize == Attr.Size) || (GetSize == 0));
495
496 return GetWorkerByLocalTokenNumber (Attr.LocalTokenNumberAlias,
497 Attr.IsPeiDb,
498 Attr.Size
499 );
500 }
501
502
503
504
505
506 EFI_STATUS
507 ExSetWorker (
508 IN UINT32 ExTokenNumber,
509 IN CONST EFI_GUID *Guid,
510 VOID *Data,
511 UINTN SetSize,
512 BOOLEAN PtrType
513 )
514 {
515 EX_PCD_ENTRY_ATTRIBUTE Attr;
516
517 GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
518
519 ASSERT (!PtrType && (SetSize == Attr.Size));
520
521 ASSERT (PtrType && (SetSize <= Attr.Size));
522
523 InvokeCallbackOnSet (ExTokenNumber, Guid, Attr.TokenNumber, Data, Attr.Size);
524
525 SetWorkerByLocalTokenNumber (Attr.LocalTokenNumberAlias, Data, Attr.Size, PtrType, Attr.IsPeiDb);
526
527 return EFI_SUCCESS;
528
529 }
530
531
532
533
534 EFI_STATUS
535 SetWorkerByLocalTokenNumber (
536 UINT32 LocalTokenNumber,
537 VOID *Data,
538 UINTN Size,
539 BOOLEAN PtrType,
540 BOOLEAN IsPeiDb
541 )
542 {
543 EFI_GUID *GuidTable;
544 UINT16 *StringTable;
545 EFI_GUID *Guid;
546 UINT16 *Name;
547 VOID *InternalData;
548 VARIABLE_HEAD *VariableHead;
549 UINTN Offset;
550 UINT8 *PcdDb;
551
552
553 if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
554 LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size, IsPeiDb);
555 }
556
557 Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
558
559 PcdDb = IsPeiDb ? ((UINT8 *) &mPcdDatabase->PeiDb) : ((UINT8 *) &mPcdDatabase->DxeDb);
560
561 StringTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.StringTable :
562 mPcdDatabase->DxeDb.Init.StringTable;
563
564 InternalData = PcdDb + Offset;
565
566 switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
567 case PCD_TYPE_VPD:
568 ASSERT (FALSE);
569 return EFI_INVALID_PARAMETER;
570
571 case PCD_TYPE_STRING:
572 CopyMem (&StringTable[*((UINT16 *)InternalData)], Data, Size);
573 break;
574
575 case PCD_TYPE_HII:
576 //
577 // Bug Bug: Please implement this
578 //
579 GuidTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.GuidTable :
580 mPcdDatabase->DxeDb.Init.GuidTable;
581
582 VariableHead = (VARIABLE_HEAD *) (PcdDb + Offset);
583
584 Guid = &(GuidTable[VariableHead->GuidTableIndex]);
585 Name = &(StringTable[VariableHead->StringIndex]);
586
587 return EFI_SUCCESS;
588
589 case PCD_TYPE_DATA:
590 if (PtrType) {
591 CopyMem (InternalData, Data, Size);
592 return EFI_SUCCESS;
593 }
594
595 switch (Size) {
596 case sizeof(UINT8):
597 *((UINT8 *) InternalData) = *((UINT8 *) Data);
598 return EFI_SUCCESS;
599
600 case sizeof(UINT16):
601 *((UINT16 *) InternalData) = *((UINT16 *) Data);
602 return EFI_SUCCESS;
603
604 case sizeof(UINT32):
605 *((UINT32 *) InternalData) = *((UINT32 *) Data);
606 return EFI_SUCCESS;
607
608 case sizeof(UINT64):
609 *((UINT64 *) InternalData) = *((UINT64 *) Data);
610 return EFI_SUCCESS;
611
612 default:
613 ASSERT (FALSE);
614 return EFI_NOT_FOUND;
615 }
616
617 default:
618 ASSERT (FALSE);
619 break;
620 }
621
622 ASSERT (FALSE);
623 return EFI_NOT_FOUND;
624 }
625
626
627
628 EFI_STATUS
629 SetHiiVariable (
630 IN EFI_GUID *VariableGuid,
631 IN UINT16 *VariableName,
632 IN CONST VOID *Data,
633 IN UINTN DataSize,
634 IN UINTN Offset
635 )
636 {
637 UINTN Size;
638 VOID *Buffer;
639 EFI_STATUS Status;
640 UINT32 Attribute;
641
642 Size = 0;
643
644 Status = EfiGetVariable (
645 (UINT16 *)VariableName,
646 VariableGuid,
647 &Attribute,
648 &Size,
649 NULL
650 );
651
652 ASSERT (Status == EFI_BUFFER_TOO_SMALL);
653
654 Buffer = AllocatePool (Size);
655
656 ASSERT (Buffer != NULL);
657
658 Status = EfiGetVariable (
659 VariableName,
660 VariableGuid,
661 &Attribute,
662 &Size,
663 Buffer
664 );
665
666
667 CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
668
669 return EfiSetVariable (
670 VariableName,
671 VariableGuid,
672 Attribute,
673 Size,
674 Buffer
675 );
676
677 }
678
679
680
681
682
683 VOID
684 GetExPcdTokenAttributes (
685 IN CONST EFI_GUID *Guid,
686 IN UINT32 ExTokenNumber,
687 OUT EX_PCD_ENTRY_ATTRIBUTE *ExAttr
688 )
689 {
690 UINT32 i;
691 DYNAMICEX_MAPPING *ExMap;
692 EFI_GUID *GuidTable;
693 UINT16 *SizeTable;
694
695 ExMap = mPcdDatabase->PeiDb.Init.ExMapTable;
696 GuidTable = mPcdDatabase->PeiDb.Init.GuidTable;
697 SizeTable = mPcdDatabase->PeiDb.Init.SizeTable;
698
699 for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {
700 if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
701 CompareGuid (Guid, (CONST EFI_GUID *) &GuidTable[ExMap[i].ExGuidIndex])
702 ) {
703
704 ExAttr->IsPeiDb = TRUE;
705 ExAttr->Size = SizeTable[i + PEI_NEX_TOKEN_NUMBER];
706 ExAttr->TokenNumber = i + PEI_NEX_TOKEN_NUMBER;
707 ExAttr->LocalTokenNumberAlias = ExMap[i].LocalTokenNumber;
708 return;
709
710 }
711 }
712
713 ExMap = mPcdDatabase->DxeDb.Init.ExMapTable;
714 GuidTable = mPcdDatabase->DxeDb.Init.GuidTable;
715 SizeTable = mPcdDatabase->DxeDb.Init.SizeTable;
716
717 for (i = 0; i < DXE_EXMAPPING_TABLE_SIZE; i++) {
718 if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
719 CompareGuid (Guid, (CONST EFI_GUID *) &GuidTable[ExMap[i].ExGuidIndex])
720 ) {
721
722 ExAttr->IsPeiDb = FALSE;
723 ExAttr->Size = SizeTable[i + DXE_NEX_TOKEN_NUMBER];
724 ExAttr->TokenNumber = i + DXE_NEX_TOKEN_NUMBER;
725 ExAttr->LocalTokenNumberAlias = ExMap[i].LocalTokenNumber;
726 return;
727
728 }
729 }
730
731 ASSERT (FALSE);
732
733 return;
734 }
735