Set value for an PCD entry @param TokenNumber Pcd token number autogenerated by build tools. @param Data Value want to be set for PCD entry @param Size Size of value. @param PtrType If TRUE, the type of PCD entry's value is Pointer. If False, the type of PCD entry's value is not Pointer. @retval EFI_INVALID_PARAMETER I
| 613 | @retval EFI_NOT_FOUND Can not find the PCD type according to token number. |
| 614 | **/ |
| 615 | EFI_STATUS |
| 616 | SetWorker ( |
| 617 | IN UINTN TokenNumber, |
| 618 | IN VOID *Data, |
| 619 | IN OUT UINTN *Size, |
| 620 | IN BOOLEAN PtrType |
| 621 | ) |
| 622 | { |
| 623 | UINT32 LocalTokenNumber; |
| 624 | UINTN PeiNexTokenNumber; |
| 625 | PEI_PCD_DATABASE *PeiPcdDb; |
| 626 | STRING_HEAD StringTableIdx; |
| 627 | UINTN Offset; |
| 628 | VOID *InternalData; |
| 629 | UINTN MaxSize; |
| 630 | UINT32 LocalTokenCount; |
| 631 | |
| 632 | if (!FeaturePcdGet(PcdPeiFullPcdDatabaseEnable)) { |
| 633 | return EFI_UNSUPPORTED; |
| 634 | } |
| 635 | |
| 636 | // |
| 637 | // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER. |
| 638 | // We have to decrement TokenNumber by 1 to make it usable |
| 639 | // as the array index. |
| 640 | // |
| 641 | TokenNumber--; |
| 642 | PeiPcdDb = GetPcdDatabase (); |
| 643 | LocalTokenCount = PeiPcdDb->LocalTokenCount; |
| 644 | |
| 645 | // EBC compiler is very choosy. It may report warning about comparison |
| 646 | // between UINTN and 0 . So we add 1 in each size of the |
| 647 | // comparison. |
| 648 | ASSERT (TokenNumber + 1 < (LocalTokenCount + 1)); |
| 649 | |
| 650 | if (PtrType) { |
| 651 | // |
| 652 | // Get MaxSize first, then check new size with max buffer size. |
| 653 | // |
| 654 | GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb); |
| 655 | if (*Size > MaxSize) { |
| 656 | *Size = MaxSize; |
| 657 | return EFI_INVALID_PARAMETER; |
| 658 | } |
| 659 | } else { |
| 660 | if (*Size != PeiPcdGetSize (TokenNumber + 1)) { |
| 661 | return EFI_INVALID_PARAMETER; |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | // |
| 666 | // We only invoke the callback function for Dynamic Type PCD Entry. |
| 667 | // For Dynamic EX PCD entry, we have invoked the callback function for Dynamic EX |
| 668 | // type PCD entry in ExSetWorker. |
| 669 | // |
| 670 | PeiNexTokenNumber = PeiPcdDb->LocalTokenCount - PeiPcdDb->ExTokenCount; |
| 671 | if (TokenNumber + 1 < PeiNexTokenNumber + 1) { |
| 672 | InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size); |
no test coverage detected