Retrieves the size of the value for a given PCD token. Retrieves the current size of a particular PCD token. If the TokenNumber is invalid, the results are unpredictable. @param[in] TokenNumber The PCD token number. @return The size of the value for the PCD token. **/
| 709 | |
| 710 | **/ |
| 711 | UINTN |
| 712 | EFIAPI |
| 713 | PeiPcdGetSize ( |
| 714 | IN UINTN TokenNumber |
| 715 | ) |
| 716 | { |
| 717 | PEI_PCD_DATABASE *PeiPcdDb; |
| 718 | UINTN Size; |
| 719 | UINTN MaxSize; |
| 720 | UINT32 LocalTokenCount; |
| 721 | |
| 722 | PeiPcdDb = GetPcdDatabase (); |
| 723 | LocalTokenCount = PeiPcdDb->LocalTokenCount; |
| 724 | // |
| 725 | // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER. |
| 726 | // We have to decrement TokenNumber by 1 to make it usable |
| 727 | // as the array index. |
| 728 | // |
| 729 | TokenNumber--; |
| 730 | |
| 731 | // EBC compiler is very choosy. It may report warning about comparison |
| 732 | // between UINTN and 0 . So we add 1 in each size of the |
| 733 | // comparison. |
| 734 | ASSERT (TokenNumber + 1 < (LocalTokenCount + 1)); |
| 735 | |
| 736 | Size = (*((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber) & PCD_DATUM_TYPE_ALL_SET) >> PCD_DATUM_TYPE_SHIFT; |
| 737 | |
| 738 | if (Size == 0) { |
| 739 | // |
| 740 | // For pointer type, we need to scan the SIZE_TABLE to get the current size. |
| 741 | // |
| 742 | return GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb); |
| 743 | } else { |
| 744 | return Size; |
| 745 | } |
| 746 | |
| 747 | } |
| 748 | |
| 749 | /** |
| 750 | Retrieves an 8-bit value for a given PCD token. |
no test coverage detected