]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/PCD/Pei/Pcd.c
MdeModulePkg and Nt32Pkg Pcd: Add the new EFI_GET_PCD_INFO_PROTOCOL and EFI_GET_PCD_I...
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Pei / Pcd.c
1 /** @file
2 All Pcd Ppi services are implemented here.
3
4 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
5 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
15 #include "Service.h"
16
17 ///
18 /// Instance of PCD_PPI protocol is EDKII native implementation.
19 /// This protocol instance support dynamic and dynamicEx type PCDs.
20 ///
21 PCD_PPI mPcdPpiInstance = {
22 PeiPcdSetSku,
23
24 PeiPcdGet8,
25 PeiPcdGet16,
26 PeiPcdGet32,
27 PeiPcdGet64,
28 PeiPcdGetPtr,
29 PeiPcdGetBool,
30 PeiPcdGetSize,
31
32 PeiPcdGet8Ex,
33 PeiPcdGet16Ex,
34 PeiPcdGet32Ex,
35 PeiPcdGet64Ex,
36 PeiPcdGetPtrEx,
37 PeiPcdGetBoolEx,
38 PeiPcdGetSizeEx,
39
40 PeiPcdSet8,
41 PeiPcdSet16,
42 PeiPcdSet32,
43 PeiPcdSet64,
44 PeiPcdSetPtr,
45 PeiPcdSetBool,
46
47 PeiPcdSet8Ex,
48 PeiPcdSet16Ex,
49 PeiPcdSet32Ex,
50 PeiPcdSet64Ex,
51 PeiPcdSetPtrEx,
52 PeiPcdSetBoolEx,
53
54 PeiRegisterCallBackOnSet,
55 PcdUnRegisterCallBackOnSet,
56 PeiPcdGetNextToken,
57 PeiPcdGetNextTokenSpace
58 };
59
60 ///
61 /// Instance of EFI_PEI_PCD_PPI which is defined in PI 1.2 Vol 3.
62 /// This PPI instance only support dyanmicEx type PCD.
63 ///
64 EFI_PEI_PCD_PPI mEfiPcdPpiInstance = {
65 PeiPcdSetSku,
66
67 PeiPcdGet8Ex,
68 PeiPcdGet16Ex,
69 PeiPcdGet32Ex,
70 PeiPcdGet64Ex,
71 PeiPcdGetPtrEx,
72 PeiPcdGetBoolEx,
73 PeiPcdGetSizeEx,
74 PeiPcdSet8Ex,
75 PeiPcdSet16Ex,
76 PeiPcdSet32Ex,
77 PeiPcdSet64Ex,
78 PeiPcdSetPtrEx,
79 PeiPcdSetBoolEx,
80 (EFI_PEI_PCD_PPI_CALLBACK_ON_SET) PeiRegisterCallBackOnSet,
81 (EFI_PEI_PCD_PPI_CANCEL_CALLBACK) PcdUnRegisterCallBackOnSet,
82 PeiPcdGetNextToken,
83 PeiPcdGetNextTokenSpace
84 };
85
86 ///
87 /// Instance of GET_PCD_INFO_PPI protocol is EDKII native implementation.
88 /// This protocol instance support dynamic and dynamicEx type PCDs.
89 ///
90 GET_PCD_INFO_PPI mGetPcdInfoInstance = {
91 PeiGetPcdInfoGetInfo,
92 PeiGetPcdInfoGetInfoEx,
93 PeiGetPcdInfoGetSku
94 };
95
96 ///
97 /// Instance of EFI_GET_PCD_INFO_PPI which is defined in PI 1.2.1 Vol 3.
98 /// This PPI instance only support dyanmicEx type PCD.
99 ///
100 EFI_GET_PCD_INFO_PPI mEfiGetPcdInfoInstance = {
101 PeiGetPcdInfoGetInfoEx,
102 PeiGetPcdInfoGetSku
103 };
104
105 EFI_PEI_PPI_DESCRIPTOR mPpiList[] = {
106 {
107 EFI_PEI_PPI_DESCRIPTOR_PPI,
108 &gPcdPpiGuid,
109 &mPcdPpiInstance
110 },
111 {
112 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
113 &gEfiPeiPcdPpiGuid,
114 &mEfiPcdPpiInstance
115 }
116 };
117
118 EFI_PEI_PPI_DESCRIPTOR mPpiList2[] = {
119 {
120 EFI_PEI_PPI_DESCRIPTOR_PPI,
121 &gGetPcdInfoPpiGuid,
122 &mGetPcdInfoInstance
123 },
124 {
125 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
126 &gEfiGetPcdInfoPpiGuid,
127 &mEfiGetPcdInfoInstance
128 }
129 };
130
131 /**
132 Main entry for PCD PEIM driver.
133
134 This routine initialize the PCD database for PEI phase and install PCD_PPI/EFI_PEI_PCD_PPI.
135
136 @param FileHandle Handle of the file being invoked.
137 @param PeiServices Describes the list of possible PEI Services.
138
139 @return Status of install PCD_PPI
140
141 **/
142 EFI_STATUS
143 EFIAPI
144 PcdPeimInit (
145 IN EFI_PEI_FILE_HANDLE FileHandle,
146 IN CONST EFI_PEI_SERVICES **PeiServices
147 )
148 {
149 EFI_STATUS Status;
150 PEI_PCD_DATABASE *DataBase;
151
152 DataBase = BuildPcdDatabase (FileHandle);
153
154 //
155 // Install PCD_PPI and EFI_PEI_PCD_PPI.
156 //
157 Status = PeiServicesInstallPpi (&mPpiList[0]);
158 ASSERT_EFI_ERROR (Status);
159
160 //
161 // Only install PcdInfo PPI when PCD info content is present.
162 //
163 if (DataBase->PcdNameTableOffset != 0) {
164 //
165 // Install GET_PCD_INFO_PPI and EFI_GET_PCD_INFO_PPI.
166 //
167 Status = PeiServicesInstallPpi (&mPpiList2[0]);
168 ASSERT_EFI_ERROR (Status);
169 }
170
171 return Status;
172 }
173
174 /**
175 Retrieve additional information associated with a PCD token in the default token space.
176
177 This includes information such as the type of value the TokenNumber is associated with as well as possible
178 human readable name that is associated with the token.
179
180 @param[in] TokenNumber The PCD token number.
181 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
182 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
183
184 @retval EFI_SUCCESS The PCD information was returned successfully.
185 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
186 **/
187 EFI_STATUS
188 EFIAPI
189 PeiGetPcdInfoGetInfo (
190 IN UINTN TokenNumber,
191 OUT EFI_PCD_INFO *PcdInfo
192 )
193 {
194 return PeiGetPcdInfo (NULL, TokenNumber, PcdInfo);
195 }
196
197 /**
198 Retrieve additional information associated with a PCD token.
199
200 This includes information such as the type of value the TokenNumber is associated with as well as possible
201 human readable name that is associated with the token.
202
203 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
204 @param[in] TokenNumber The PCD token number.
205 @param[out] PcdInfo The returned information associated with the requested TokenNumber.
206 The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName.
207
208 @retval EFI_SUCCESS The PCD information was returned successfully.
209 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
210 **/
211 EFI_STATUS
212 EFIAPI
213 PeiGetPcdInfoGetInfoEx (
214 IN CONST EFI_GUID *Guid,
215 IN UINTN TokenNumber,
216 OUT EFI_PCD_INFO *PcdInfo
217 )
218 {
219 return PeiGetPcdInfo (Guid, TokenNumber, PcdInfo);
220 }
221
222 /**
223 Retrieve the currently set SKU Id.
224
225 @return The currently set SKU Id. If the platform has not set at a SKU Id, then the
226 default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU
227 Id is returned.
228 **/
229 UINTN
230 EFIAPI
231 PeiGetPcdInfoGetSku (
232 VOID
233 )
234 {
235 return GetPcdDatabase()->SystemSkuId;
236 }
237
238 /**
239 Sets the SKU value for subsequent calls to set or get PCD token values.
240
241 SetSku() sets the SKU Id to be used for subsequent calls to set or get PCD values.
242 SetSku() is normally called only once by the system.
243
244 For each item (token), the database can hold a single value that applies to all SKUs,
245 or multiple values, where each value is associated with a specific SKU Id. Items with multiple,
246 SKU-specific values are called SKU enabled.
247
248 The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.
249 For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the
250 single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the
251 last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token,
252 the system uses the default SKU Id. If the system attempts to use the default SKU Id and no value has been
253 set for that Id, the results are unpredictable.
254
255 @param[in] SkuId The SKU value that will be used when the PCD service will retrieve and
256 set values associated with a PCD token.
257
258 **/
259 VOID
260 EFIAPI
261 PeiPcdSetSku (
262 IN UINTN SkuId
263 )
264 {
265
266 GetPcdDatabase()->SystemSkuId = (SKU_ID) SkuId;
267
268 return;
269 }
270
271 /**
272 Retrieves an 8-bit value for a given PCD token.
273
274 Retrieves the current byte-sized value for a PCD token number.
275 If the TokenNumber is invalid, the results are unpredictable.
276
277 @param[in] TokenNumber The PCD token number.
278
279 @return The UINT8 value.
280
281 **/
282 UINT8
283 EFIAPI
284 PeiPcdGet8 (
285 IN UINTN TokenNumber
286 )
287 {
288 return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));
289 }
290
291 /**
292 Retrieves an 16-bit value for a given PCD token.
293
294 Retrieves the current 16-bits value for a PCD token number.
295 If the TokenNumber is invalid, the results are unpredictable.
296
297 @param[in] TokenNumber The PCD token number.
298
299 @return The UINT16 value.
300
301 **/
302 UINT16
303 EFIAPI
304 PeiPcdGet16 (
305 IN UINTN TokenNumber
306 )
307 {
308 return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));
309 }
310
311 /**
312 Retrieves an 32-bit value for a given PCD token.
313
314 Retrieves the current 32-bits value for a PCD token number.
315 If the TokenNumber is invalid, the results are unpredictable.
316
317 @param[in] TokenNumber The PCD token number.
318
319 @return The UINT32 value.
320
321 **/
322 UINT32
323 EFIAPI
324 PeiPcdGet32 (
325 IN UINTN TokenNumber
326 )
327 {
328 return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));
329 }
330
331 /**
332 Retrieves an 64-bit value for a given PCD token.
333
334 Retrieves the current 64-bits value for a PCD token number.
335 If the TokenNumber is invalid, the results are unpredictable.
336
337 @param[in] TokenNumber The PCD token number.
338
339 @return The UINT64 value.
340
341 **/
342 UINT64
343 EFIAPI
344 PeiPcdGet64 (
345 IN UINTN TokenNumber
346 )
347 {
348 return ReadUnaligned64 (GetWorker (TokenNumber, sizeof (UINT64)));
349 }
350
351 /**
352 Retrieves a pointer to a value for a given PCD token.
353
354 Retrieves the current pointer to the buffer for a PCD token number.
355 Do not make any assumptions about the alignment of the pointer that
356 is returned by this function call. If the TokenNumber is invalid,
357 the results are unpredictable.
358
359 @param[in] TokenNumber The PCD token number.
360
361 @return The pointer to the buffer to be retrieved.
362
363 **/
364 VOID *
365 EFIAPI
366 PeiPcdGetPtr (
367 IN UINTN TokenNumber
368 )
369 {
370 return GetWorker (TokenNumber, 0);
371 }
372
373 /**
374 Retrieves a Boolean value for a given PCD token.
375
376 Retrieves the current boolean value for a PCD token number.
377 Do not make any assumptions about the alignment of the pointer that
378 is returned by this function call. If the TokenNumber is invalid,
379 the results are unpredictable.
380
381 @param[in] TokenNumber The PCD token number.
382
383 @return The Boolean value.
384
385 **/
386 BOOLEAN
387 EFIAPI
388 PeiPcdGetBool (
389 IN UINTN TokenNumber
390 )
391 {
392 return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));
393 }
394
395 /**
396 Retrieves the size of the value for a given PCD token.
397
398 Retrieves the current size of a particular PCD token.
399 If the TokenNumber is invalid, the results are unpredictable.
400
401 @param[in] TokenNumber The PCD token number.
402
403 @return The size of the value for the PCD token.
404
405 **/
406 UINTN
407 EFIAPI
408 PeiPcdGetSize (
409 IN UINTN TokenNumber
410 )
411 {
412 PEI_PCD_DATABASE *PeiPcdDb;
413 UINTN Size;
414 UINTN MaxSize;
415 UINT32 LocalTokenCount;
416
417 PeiPcdDb = GetPcdDatabase ();
418 LocalTokenCount = PeiPcdDb->LocalTokenCount;
419 //
420 // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
421 // We have to decrement TokenNumber by 1 to make it usable
422 // as the array index.
423 //
424 TokenNumber--;
425
426 // EBC compiler is very choosy. It may report warning about comparison
427 // between UINTN and 0 . So we add 1 in each size of the
428 // comparison.
429 ASSERT (TokenNumber + 1 < (LocalTokenCount + 1));
430
431 Size = (*((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber) & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT;
432
433 if (Size == 0) {
434 //
435 // For pointer type, we need to scan the SIZE_TABLE to get the current size.
436 //
437 return GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb);
438 } else {
439 return Size;
440 }
441
442 }
443
444 /**
445 Retrieves an 8-bit value for a given PCD token.
446
447 Retrieves the 8-bit value of a particular PCD token.
448 If the TokenNumber is invalid or the token space
449 specified by Guid does not exist, the results are
450 unpredictable.
451
452 @param[in] Guid The token space for the token number.
453 @param[in] ExTokenNumber The PCD token number.
454
455 @return The size 8-bit value for the PCD token.
456
457 **/
458 UINT8
459 EFIAPI
460 PeiPcdGet8Ex (
461 IN CONST EFI_GUID *Guid,
462 IN UINTN ExTokenNumber
463 )
464 {
465 return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof (UINT8)));
466 }
467
468 /**
469 Retrieves an 16-bit value for a given PCD token.
470
471 Retrieves the 16-bit value of a particular PCD token.
472 If the TokenNumber is invalid or the token space
473 specified by Guid does not exist, the results are
474 unpredictable.
475
476 @param[in] Guid The token space for the token number.
477 @param[in] ExTokenNumber The PCD token number.
478
479 @return The size 16-bit value for the PCD token.
480
481 **/
482 UINT16
483 EFIAPI
484 PeiPcdGet16Ex (
485 IN CONST EFI_GUID *Guid,
486 IN UINTN ExTokenNumber
487 )
488 {
489 return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT16)));
490 }
491
492 /**
493 Retrieves an 32-bit value for a given PCD token.
494
495 Retrieves the 32-bit value of a particular PCD token.
496 If the TokenNumber is invalid or the token space
497 specified by Guid does not exist, the results are
498 unpredictable.
499
500 @param[in] Guid The token space for the token number.
501 @param[in] ExTokenNumber The PCD token number.
502
503 @return The size 32-bit value for the PCD token.
504
505 **/
506 UINT32
507 EFIAPI
508 PeiPcdGet32Ex (
509 IN CONST EFI_GUID *Guid,
510 IN UINTN ExTokenNumber
511 )
512 {
513 return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT32)));
514 }
515
516 /**
517 Retrieves an 64-bit value for a given PCD token.
518
519 Retrieves the 64-bit value of a particular PCD token.
520 If the TokenNumber is invalid or the token space
521 specified by Guid does not exist, the results are
522 unpredictable.
523
524 @param[in] Guid The token space for the token number.
525 @param[in] ExTokenNumber The PCD token number.
526
527 @return The size 64-bit value for the PCD token.
528
529 **/
530 UINT64
531 EFIAPI
532 PeiPcdGet64Ex (
533 IN CONST EFI_GUID *Guid,
534 IN UINTN ExTokenNumber
535 )
536 {
537 return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT64)));
538 }
539
540 /**
541 Retrieves a pointer to a value for a given PCD token.
542
543 Retrieves the current pointer to the buffer for a PCD token number.
544 Do not make any assumptions about the alignment of the pointer that
545 is returned by this function call. If the TokenNumber is invalid,
546 the results are unpredictable.
547
548 @param[in] Guid The token space for the token number.
549 @param[in] ExTokenNumber The PCD token number.
550
551 @return The pointer to the buffer to be retrieved.
552
553 **/
554 VOID *
555 EFIAPI
556 PeiPcdGetPtrEx (
557 IN CONST EFI_GUID *Guid,
558 IN UINTN ExTokenNumber
559 )
560 {
561 return ExGetWorker (Guid, ExTokenNumber, 0);
562 }
563
564 /**
565 Retrieves an Boolean value for a given PCD token.
566
567 Retrieves the Boolean value of a particular PCD token.
568 If the TokenNumber is invalid or the token space
569 specified by Guid does not exist, the results are
570 unpredictable.
571
572 @param[in] Guid The token space for the token number.
573 @param[in] ExTokenNumber The PCD token number.
574
575 @return The size Boolean value for the PCD token.
576
577 **/
578 BOOLEAN
579 EFIAPI
580 PeiPcdGetBoolEx (
581 IN CONST EFI_GUID *Guid,
582 IN UINTN ExTokenNumber
583 )
584 {
585 return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof (BOOLEAN)));
586 }
587
588 /**
589 Retrieves the size of the value for a given PCD token.
590
591 Retrieves the current size of a particular PCD token.
592 If the TokenNumber is invalid, the results are unpredictable.
593
594 @param[in] Guid The token space for the token number.
595 @param[in] ExTokenNumber The PCD token number.
596
597 @return The size of the value for the PCD token.
598
599 **/
600 UINTN
601 EFIAPI
602 PeiPcdGetSizeEx (
603 IN CONST EFI_GUID *Guid,
604 IN UINTN ExTokenNumber
605 )
606 {
607 return PeiPcdGetSize (GetExPcdTokenNumber (Guid, ExTokenNumber));
608 }
609
610 /**
611 Sets an 8-bit value for a given PCD token.
612
613 When the PCD service sets a value, it will check to ensure that the
614 size of the value being set is compatible with the Token's existing definition.
615 If it is not, an error will be returned.
616
617 @param[in] TokenNumber The PCD token number.
618 @param[in] Value The value to set for the PCD token.
619
620 @retval EFI_SUCCESS Procedure returned successfully.
621 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
622 being set was incompatible with a call to this function.
623 Use GetSize() to retrieve the size of the target data.
624 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
625
626 **/
627 EFI_STATUS
628 EFIAPI
629 PeiPcdSet8 (
630 IN UINTN TokenNumber,
631 IN UINT8 Value
632 )
633 {
634 return SetValueWorker (TokenNumber, &Value, sizeof (Value));
635 }
636
637 /**
638 Sets an 16-bit value for a given PCD token.
639
640 When the PCD service sets a value, it will check to ensure that the
641 size of the value being set is compatible with the Token's existing definition.
642 If it is not, an error will be returned.
643
644 @param[in] TokenNumber The PCD token number.
645 @param[in] Value The value to set for the PCD token.
646
647 @retval EFI_SUCCESS Procedure returned successfully.
648 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
649 being set was incompatible with a call to this function.
650 Use GetSize() to retrieve the size of the target data.
651 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
652
653 **/
654 EFI_STATUS
655 EFIAPI
656 PeiPcdSet16 (
657 IN UINTN TokenNumber,
658 IN UINT16 Value
659 )
660 {
661 return SetValueWorker (TokenNumber, &Value, sizeof (Value));
662 }
663
664 /**
665 Sets an 32-bit value for a given PCD token.
666
667 When the PCD service sets a value, it will check to ensure that the
668 size of the value being set is compatible with the Token's existing definition.
669 If it is not, an error will be returned.
670
671 @param[in] TokenNumber The PCD token number.
672 @param[in] Value The value to set for the PCD token.
673
674 @retval EFI_SUCCESS Procedure returned successfully.
675 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
676 being set was incompatible with a call to this function.
677 Use GetSize() to retrieve the size of the target data.
678 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
679
680 **/
681 EFI_STATUS
682 EFIAPI
683 PeiPcdSet32 (
684 IN UINTN TokenNumber,
685 IN UINT32 Value
686 )
687 {
688 return SetValueWorker (TokenNumber, &Value, sizeof (Value));
689 }
690
691 /**
692 Sets an 64-bit value for a given PCD token.
693
694 When the PCD service sets a value, it will check to ensure that the
695 size of the value being set is compatible with the Token's existing definition.
696 If it is not, an error will be returned.
697
698 @param[in] TokenNumber The PCD token number.
699 @param[in] Value The value to set for the PCD token.
700
701 @retval EFI_SUCCESS Procedure returned successfully.
702 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
703 being set was incompatible with a call to this function.
704 Use GetSize() to retrieve the size of the target data.
705 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
706
707 **/
708 EFI_STATUS
709 EFIAPI
710 PeiPcdSet64 (
711 IN UINTN TokenNumber,
712 IN UINT64 Value
713 )
714 {
715 return SetValueWorker (TokenNumber, &Value, sizeof (Value));
716 }
717
718 /**
719 Sets a value of a specified size for a given PCD token.
720
721 When the PCD service sets a value, it will check to ensure that the
722 size of the value being set is compatible with the Token's existing definition.
723 If it is not, an error will be returned.
724
725 @param[in] TokenNumber The PCD token number.
726 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
727 On input, if the SizeOfValue is greater than the maximum size supported
728 for this TokenNumber then the output value of SizeOfValue will reflect
729 the maximum size supported for this TokenNumber.
730 @param[in] Buffer The buffer to set for the PCD token.
731
732 @retval EFI_SUCCESS Procedure returned successfully.
733 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
734 being set was incompatible with a call to this function.
735 Use GetSize() to retrieve the size of the target data.
736 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
737
738 **/
739 EFI_STATUS
740 EFIAPI
741 PeiPcdSetPtr (
742 IN UINTN TokenNumber,
743 IN OUT UINTN *SizeOfBuffer,
744 IN VOID *Buffer
745 )
746 {
747 return SetWorker (TokenNumber, Buffer, SizeOfBuffer, TRUE);
748 }
749
750 /**
751 Sets an Boolean value for a given PCD token.
752
753 When the PCD service sets a value, it will check to ensure that the
754 size of the value being set is compatible with the Token's existing definition.
755 If it is not, an error will be returned.
756
757 @param[in] TokenNumber The PCD token number.
758 @param[in] Value The value to set for the PCD token.
759
760 @retval EFI_SUCCESS Procedure returned successfully.
761 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
762 being set was incompatible with a call to this function.
763 Use GetSize() to retrieve the size of the target data.
764 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
765
766 **/
767 EFI_STATUS
768 EFIAPI
769 PeiPcdSetBool (
770 IN UINTN TokenNumber,
771 IN BOOLEAN Value
772 )
773 {
774 return SetValueWorker (TokenNumber, &Value, sizeof (Value));
775 }
776
777 /**
778 Sets an 8-bit value for a given PCD token.
779
780 When the PCD service sets a value, it will check to ensure that the
781 size of the value being set is compatible with the Token's existing definition.
782 If it is not, an error will be returned.
783
784 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
785 @param[in] ExTokenNumber The PCD token number.
786 @param[in] Value The value to set for the PCD token.
787
788 @retval EFI_SUCCESS Procedure returned successfully.
789 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
790 being set was incompatible with a call to this function.
791 Use GetSize() to retrieve the size of the target data.
792 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
793
794 **/
795 EFI_STATUS
796 EFIAPI
797 PeiPcdSet8Ex (
798 IN CONST EFI_GUID *Guid,
799 IN UINTN ExTokenNumber,
800 IN UINT8 Value
801 )
802 {
803 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
804 }
805
806 /**
807 Sets an 16-bit value for a given PCD token.
808
809 When the PCD service sets a value, it will check to ensure that the
810 size of the value being set is compatible with the Token's existing definition.
811 If it is not, an error will be returned.
812
813 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
814 @param[in] ExTokenNumber The PCD token number.
815 @param[in] Value The value to set for the PCD token.
816
817 @retval EFI_SUCCESS Procedure returned successfully.
818 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
819 being set was incompatible with a call to this function.
820 Use GetSize() to retrieve the size of the target data.
821 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
822
823 **/
824 EFI_STATUS
825 EFIAPI
826 PeiPcdSet16Ex (
827 IN CONST EFI_GUID *Guid,
828 IN UINTN ExTokenNumber,
829 IN UINT16 Value
830 )
831 {
832 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
833 }
834
835 /**
836 Sets an 32-bit value for a given PCD token.
837
838 When the PCD service sets a value, it will check to ensure that the
839 size of the value being set is compatible with the Token's existing definition.
840 If it is not, an error will be returned.
841
842 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
843 @param[in] ExTokenNumber The PCD token number.
844 @param[in] Value The value to set for the PCD token.
845
846 @retval EFI_SUCCESS Procedure returned successfully.
847 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
848 being set was incompatible with a call to this function.
849 Use GetSize() to retrieve the size of the target data.
850 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
851
852 **/
853 EFI_STATUS
854 EFIAPI
855 PeiPcdSet32Ex (
856 IN CONST EFI_GUID *Guid,
857 IN UINTN ExTokenNumber,
858 IN UINT32 Value
859 )
860 {
861 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
862 }
863
864 /**
865 Sets an 64-bit value for a given PCD token.
866
867 When the PCD service sets a value, it will check to ensure that the
868 size of the value being set is compatible with the Token's existing definition.
869 If it is not, an error will be returned.
870
871 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
872 @param[in] ExTokenNumber The PCD token number.
873 @param[in] Value The value to set for the PCD token.
874
875 @retval EFI_SUCCESS Procedure returned successfully.
876 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
877 being set was incompatible with a call to this function.
878 Use GetSize() to retrieve the size of the target data.
879 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
880
881 **/
882 EFI_STATUS
883 EFIAPI
884 PeiPcdSet64Ex (
885 IN CONST EFI_GUID *Guid,
886 IN UINTN ExTokenNumber,
887 IN UINT64 Value
888 )
889 {
890 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
891 }
892
893 /**
894 Sets a value of a specified size for a given PCD token.
895
896 When the PCD service sets a value, it will check to ensure that the
897 size of the value being set is compatible with the Token's existing definition.
898 If it is not, an error will be returned.
899
900 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
901 @param[in] ExTokenNumber The PCD token number.
902 @param[in, out] SizeOfBuffer A pointer to the length of the value being set for the PCD token.
903 On input, if the SizeOfValue is greater than the maximum size supported
904 for this TokenNumber then the output value of SizeOfValue will reflect
905 the maximum size supported for this TokenNumber.
906 @param[in] Value The buffer to set for the PCD token.
907
908 @retval EFI_SUCCESS Procedure returned successfully.
909 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
910 being set was incompatible with a call to this function.
911 Use GetSize() to retrieve the size of the target data.
912 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
913
914 **/
915 EFI_STATUS
916 EFIAPI
917 PeiPcdSetPtrEx (
918 IN CONST EFI_GUID *Guid,
919 IN UINTN ExTokenNumber,
920 IN OUT UINTN *SizeOfBuffer,
921 IN VOID *Value
922 )
923 {
924 return ExSetWorker (ExTokenNumber, Guid, Value, SizeOfBuffer, TRUE);
925 }
926
927 /**
928 Sets an Boolean value for a given PCD token.
929
930 When the PCD service sets a value, it will check to ensure that the
931 size of the value being set is compatible with the Token's existing definition.
932 If it is not, an error will be returned.
933
934 @param [in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
935 @param [in] ExTokenNumber The PCD token number.
936 @param [in] Value The value to set for the PCD token.
937
938 @retval EFI_SUCCESS Procedure returned successfully.
939 @retval EFI_INVALID_PARAMETER The PCD service determined that the size of the data
940 being set was incompatible with a call to this function.
941 Use GetSize() to retrieve the size of the target data.
942 @retval EFI_NOT_FOUND The PCD service could not find the requested token number.
943
944 **/
945 EFI_STATUS
946 EFIAPI
947 PeiPcdSetBoolEx (
948 IN CONST EFI_GUID *Guid,
949 IN UINTN ExTokenNumber,
950 IN BOOLEAN Value
951 )
952 {
953 return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value));
954 }
955
956 /**
957 Specifies a function to be called anytime the value of a designated token is changed.
958
959 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
960 @param[in] ExTokenNumber The PCD token number.
961 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
962
963 @retval EFI_SUCCESS The PCD service has successfully established a call event
964 for the CallBackToken requested.
965 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
966
967 **/
968 EFI_STATUS
969 EFIAPI
970 PeiRegisterCallBackOnSet (
971 IN CONST EFI_GUID *Guid, OPTIONAL
972 IN UINTN ExTokenNumber,
973 IN PCD_PPI_CALLBACK CallBackFunction
974 )
975 {
976 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable)) {
977 return EFI_UNSUPPORTED;
978 }
979
980 if (CallBackFunction == NULL) {
981 return EFI_INVALID_PARAMETER;
982 }
983
984 return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, TRUE);
985 }
986
987 /**
988 Cancels a previously set callback function for a particular PCD token number.
989
990 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
991 @param[in] ExTokenNumber The PCD token number.
992 @param[in] CallBackFunction The function prototype called when the value associated with the CallBackToken is set.
993
994 @retval EFI_SUCCESS The PCD service has successfully established a call event
995 for the CallBackToken requested.
996 @retval EFI_NOT_FOUND The PCD service could not find the referenced token number.
997
998 **/
999 EFI_STATUS
1000 EFIAPI
1001 PcdUnRegisterCallBackOnSet (
1002 IN CONST EFI_GUID *Guid, OPTIONAL
1003 IN UINTN ExTokenNumber,
1004 IN PCD_PPI_CALLBACK CallBackFunction
1005 )
1006 {
1007 if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable)) {
1008 return EFI_UNSUPPORTED;
1009 }
1010
1011 if (CallBackFunction == NULL) {
1012 return EFI_INVALID_PARAMETER;
1013 }
1014
1015 return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, FALSE);
1016 }
1017
1018 /**
1019 Retrieves the next valid token number in a given namespace.
1020
1021 This is useful since the PCD infrastructure contains a sparse list of token numbers,
1022 and one cannot a priori know what token numbers are valid in the database.
1023
1024 If TokenNumber is 0 and Guid is not NULL, then the first token from the token space specified by Guid is returned.
1025 If TokenNumber is not 0 and Guid is not NULL, then the next token in the token space specified by Guid is returned.
1026 If TokenNumber is 0 and Guid is NULL, then the first token in the default token space is returned.
1027 If TokenNumber is not 0 and Guid is NULL, then the next token in the default token space is returned.
1028 The token numbers in the default token space may not be related to token numbers in token spaces that are named by Guid.
1029 If the next token number can be retrieved, then it is returned in TokenNumber, and EFI_SUCCESS is returned.
1030 If TokenNumber represents the last token number in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1031 If TokenNumber is not present in the token space specified by Guid, then EFI_NOT_FOUND is returned.
1032
1033
1034 @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value.
1035 This is an optional parameter that may be NULL. If this parameter is NULL, then a request
1036 is being made to retrieve tokens from the default token space.
1037 @param[in, out] TokenNumber A pointer to the PCD token number to use to find the subsequent token number.
1038
1039 @retval EFI_SUCCESS The PCD service has retrieved the next valid token number.
1040 @retval EFI_NOT_FOUND The PCD service could not find data from the requested token number.
1041
1042 **/
1043 EFI_STATUS
1044 EFIAPI
1045 PeiPcdGetNextToken (
1046 IN CONST EFI_GUID *Guid, OPTIONAL
1047 IN OUT UINTN *TokenNumber
1048 )
1049 {
1050 UINTN GuidTableIdx;
1051 PEI_PCD_DATABASE *PeiPcdDb;
1052 EFI_GUID *MatchGuid;
1053 EFI_GUID *GuidTable;
1054 DYNAMICEX_MAPPING *ExMapTable;
1055 UINTN Index;
1056 BOOLEAN Found;
1057 BOOLEAN PeiExMapTableEmpty;
1058 UINTN PeiNexTokenNumber;
1059
1060 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable)) {
1061 return EFI_UNSUPPORTED;
1062 }
1063
1064 PeiPcdDb = GetPcdDatabase ();
1065 PeiNexTokenNumber = PeiPcdDb->LocalTokenCount - PeiPcdDb->ExTokenCount;
1066 GuidTable = (EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset);
1067
1068 if (PeiPcdDb->ExTokenCount == 0) {
1069 PeiExMapTableEmpty = TRUE;
1070 } else {
1071 PeiExMapTableEmpty = FALSE;
1072 }
1073 if (Guid == NULL) {
1074 if (*TokenNumber > PeiNexTokenNumber) {
1075 return EFI_NOT_FOUND;
1076 }
1077 (*TokenNumber)++;
1078 if (*TokenNumber > PeiNexTokenNumber) {
1079 *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
1080 return EFI_NOT_FOUND;
1081 }
1082 return EFI_SUCCESS;
1083 } else {
1084 if (PeiExMapTableEmpty) {
1085 return EFI_NOT_FOUND;
1086 }
1087
1088 MatchGuid = ScanGuid (GuidTable, PeiPcdDb->GuidTableCount * sizeof(EFI_GUID), Guid);
1089
1090 if (MatchGuid == NULL) {
1091 return EFI_NOT_FOUND;
1092 }
1093
1094 GuidTableIdx = MatchGuid - GuidTable;
1095
1096 ExMapTable = (DYNAMICEX_MAPPING *)((UINT8 *)PeiPcdDb + PeiPcdDb->ExMapTableOffset);
1097
1098 Found = FALSE;
1099 //
1100 // Locate the GUID in ExMapTable first.
1101 //
1102 for (Index = 0; Index < PeiPcdDb->ExTokenCount; Index++) {
1103 if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
1104 Found = TRUE;
1105 break;
1106 }
1107 }
1108
1109 if (Found) {
1110 if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
1111 *TokenNumber = ExMapTable[Index].ExTokenNumber;
1112 return EFI_SUCCESS;
1113 }
1114
1115 for ( ; Index < PeiPcdDb->ExTokenCount; Index++) {
1116 if (ExMapTable[Index].ExTokenNumber == *TokenNumber) {
1117 break;
1118 }
1119 }
1120
1121 while (Index < PeiPcdDb->ExTokenCount) {
1122 Index++;
1123 if (Index == PeiPcdDb->ExTokenCount) {
1124 //
1125 // Exceed the length of ExMap Table
1126 //
1127 *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
1128 return EFI_NOT_FOUND;
1129 } else if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
1130 //
1131 // Found the next match
1132 //
1133 *TokenNumber = ExMapTable[Index].ExTokenNumber;
1134 return EFI_SUCCESS;
1135 }
1136 }
1137 }
1138 }
1139
1140 return EFI_NOT_FOUND;
1141 }
1142
1143 /**
1144 Retrieves the next valid PCD token namespace for a given namespace.
1145
1146 Gets the next valid token namespace for a given namespace. This is useful to traverse the valid
1147 token namespaces on a platform.
1148
1149 @param[in, out] Guid An indirect pointer to EFI_GUID. On input it designates a known token
1150 namespace from which the search will start. On output, it designates the next valid
1151 token namespace on the platform. If *Guid is NULL, then the GUID of the first token
1152 space of the current platform is returned. If the search cannot locate the next valid
1153 token namespace, an error is returned and the value of *Guid is undefined.
1154
1155 @retval EFI_SUCCESS The PCD service retrieved the value requested.
1156 @retval EFI_NOT_FOUND The PCD service could not find the next valid token namespace.
1157
1158 **/
1159 EFI_STATUS
1160 EFIAPI
1161 PeiPcdGetNextTokenSpace (
1162 IN OUT CONST EFI_GUID **Guid
1163 )
1164 {
1165 UINTN GuidTableIdx;
1166 EFI_GUID *MatchGuid;
1167 PEI_PCD_DATABASE *PeiPcdDb;
1168 DYNAMICEX_MAPPING *ExMapTable;
1169 UINTN Index;
1170 UINTN Index2;
1171 BOOLEAN Found;
1172 BOOLEAN PeiExMapTableEmpty;
1173 EFI_GUID *GuidTable;
1174
1175 if (!FeaturePcdGet (PcdPeiFullPcdDatabaseEnable)) {
1176 return EFI_UNSUPPORTED;
1177 }
1178
1179 ASSERT (Guid != NULL);
1180
1181 PeiPcdDb = GetPcdDatabase ();
1182
1183 if (PeiPcdDb->ExTokenCount == 0) {
1184 PeiExMapTableEmpty = TRUE;
1185 } else {
1186 PeiExMapTableEmpty = FALSE;
1187 }
1188
1189 if (PeiExMapTableEmpty) {
1190 return EFI_NOT_FOUND;
1191 }
1192
1193 ExMapTable = (DYNAMICEX_MAPPING *)((UINT8 *)PeiPcdDb + PeiPcdDb->ExMapTableOffset);
1194 GuidTable = (EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset);
1195
1196 if (*Guid == NULL) {
1197 //
1198 // return the first Token Space Guid.
1199 //
1200 *Guid = GuidTable + ExMapTable[0].ExGuidIndex;
1201 return EFI_SUCCESS;
1202 }
1203
1204 MatchGuid = ScanGuid (GuidTable, PeiPcdDb->GuidTableCount * sizeof(GuidTable[0]), *Guid);
1205
1206 if (MatchGuid == NULL) {
1207 return EFI_NOT_FOUND;
1208 }
1209
1210 GuidTableIdx = MatchGuid - GuidTable;
1211
1212 Found = FALSE;
1213 for (Index = 0; Index < PeiPcdDb->ExTokenCount; Index++) {
1214 if (ExMapTable[Index].ExGuidIndex == GuidTableIdx) {
1215 Found = TRUE;
1216 break;
1217 }
1218 }
1219
1220 if (Found) {
1221 Index++;
1222 for ( ; Index < PeiPcdDb->ExTokenCount; Index++ ) {
1223 if (ExMapTable[Index].ExGuidIndex != GuidTableIdx) {
1224 Found = FALSE;
1225 for (Index2 = 0 ; Index2 < Index; Index2++) {
1226 if (ExMapTable[Index2].ExGuidIndex == ExMapTable[Index].ExGuidIndex) {
1227 //
1228 // This token namespace should have been found and output at preceding getting.
1229 //
1230 Found = TRUE;
1231 break;
1232 }
1233 }
1234 if (!Found) {
1235 *Guid = (EFI_GUID *)((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset) + ExMapTable[Index].ExGuidIndex;
1236 return EFI_SUCCESS;
1237 }
1238 }
1239 }
1240 *Guid = NULL;
1241 }
1242
1243 return EFI_NOT_FOUND;
1244
1245 }
1246
1247 /**
1248 Get PCD value's size for POINTER type PCD.
1249
1250 The POINTER type PCD's value will be stored into a buffer in specified size.
1251 The max size of this PCD's value is described in PCD's definition in DEC file.
1252
1253 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1254 @param MaxSize Maximum size of PCD's value
1255 @param Database Pcd database in PEI phase.
1256
1257 @return PCD value's size for POINTER type PCD.
1258
1259 **/
1260 UINTN
1261 GetPtrTypeSize (
1262 IN UINTN LocalTokenNumberTableIdx,
1263 OUT UINTN *MaxSize,
1264 IN PEI_PCD_DATABASE *Database
1265 )
1266 {
1267 INTN SizeTableIdx;
1268 UINTN LocalTokenNumber;
1269 SKU_ID *SkuIdTable;
1270 SIZE_INFO *SizeTable;
1271 UINTN Index;
1272
1273 SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);
1274
1275 LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);
1276
1277 ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);
1278
1279 SizeTable = (SIZE_INFO *)((UINT8 *)Database + Database->SizeTableOffset);
1280
1281 *MaxSize = SizeTable[SizeTableIdx];
1282 //
1283 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1284 // PCD entry.
1285 //
1286 if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {
1287 //
1288 // We have only two entry for VPD enabled PCD entry:
1289 // 1) MAX Size.
1290 // 2) Current Size
1291 // We consider current size is equal to MAX size.
1292 //
1293 return *MaxSize;
1294 } else {
1295 if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
1296 //
1297 // We have only two entry for Non-Sku enabled PCD entry:
1298 // 1) MAX SIZE
1299 // 2) Current Size
1300 //
1301 return SizeTable[SizeTableIdx + 1];
1302 } else {
1303 //
1304 // We have these entry for SKU enabled PCD entry
1305 // 1) MAX SIZE
1306 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1307 //
1308 SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);
1309 for (Index = 0; Index < SkuIdTable[0]; Index++) {
1310 if (SkuIdTable[1 + Index] == Database->SystemSkuId) {
1311 return SizeTable[SizeTableIdx + 1 + Index];
1312 }
1313 }
1314 return SizeTable[SizeTableIdx + 1];
1315 }
1316 }
1317 }
1318
1319 /**
1320 Set PCD value's size for POINTER type PCD.
1321
1322 The POINTER type PCD's value will be stored into a buffer in specified size.
1323 The max size of this PCD's value is described in PCD's definition in DEC file.
1324
1325 @param LocalTokenNumberTableIdx Index of PCD token number in PCD token table
1326 @param CurrentSize Maximum size of PCD's value
1327 @param Database Pcd database in PEI phase.
1328
1329 @retval TRUE Success to set PCD's value size, which is not exceed maximum size
1330 @retval FALSE Fail to set PCD's value size, which maybe exceed maximum size
1331
1332 **/
1333 BOOLEAN
1334 SetPtrTypeSize (
1335 IN UINTN LocalTokenNumberTableIdx,
1336 IN OUT UINTN *CurrentSize,
1337 IN PEI_PCD_DATABASE *Database
1338 )
1339 {
1340 INTN SizeTableIdx;
1341 UINTN LocalTokenNumber;
1342 SKU_ID *SkuIdTable;
1343 SIZE_INFO *SizeTable;
1344 UINTN Index;
1345 UINTN MaxSize;
1346
1347 SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, Database);
1348
1349 LocalTokenNumber = *((UINT32 *)((UINT8 *)Database + Database->LocalTokenNumberTableOffset) + LocalTokenNumberTableIdx);
1350
1351 ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER);
1352
1353 SizeTable = (SIZE_INFO *)((UINT8 *)Database + Database->SizeTableOffset);
1354
1355 MaxSize = SizeTable[SizeTableIdx];
1356 //
1357 // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type
1358 // PCD entry.
1359 //
1360 if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) {
1361 //
1362 // We shouldn't come here as we don't support SET for VPD
1363 //
1364 ASSERT (FALSE);
1365 return FALSE;
1366 } else {
1367 if ((*CurrentSize > MaxSize) ||
1368 (*CurrentSize == MAX_ADDRESS)) {
1369 *CurrentSize = MaxSize;
1370 return FALSE;
1371 }
1372
1373 if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
1374 //
1375 // We have only two entry for Non-Sku enabled PCD entry:
1376 // 1) MAX SIZE
1377 // 2) Current Size
1378 //
1379 SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;
1380 return TRUE;
1381 } else {
1382 //
1383 // We have these entry for SKU enabled PCD entry
1384 // 1) MAX SIZE
1385 // 2) Current Size for each SKU_ID (It is equal to MaxSku).
1386 //
1387 SkuIdTable = GetSkuIdArray (LocalTokenNumberTableIdx, Database);
1388 for (Index = 0; Index < SkuIdTable[0]; Index++) {
1389 if (SkuIdTable[1 + Index] == Database->SystemSkuId) {
1390 SizeTable[SizeTableIdx + 1 + Index] = (SIZE_INFO) *CurrentSize;
1391 return TRUE;
1392 }
1393 }
1394 SizeTable[SizeTableIdx + 1] = (SIZE_INFO) *CurrentSize;
1395 return TRUE;
1396 }
1397 }
1398
1399 }