X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdePkg%2FInclude%2FLibrary%2FPcdLib.h;h=038443b993c9dcbe0a30a92449fc2c80edc2c1ef;hb=5776c5c045abf935cbfd3e1e7b4c2ae0a2a419e2;hp=5a3cbfa46ad1475968f51f983ce2edacefddbbca;hpb=b16ef8055698bbbf96270f5787557c0c6a4b34e3;p=mirror_edk2.git diff --git a/MdePkg/Include/Library/PcdLib.h b/MdePkg/Include/Library/PcdLib.h index 5a3cbfa46a..038443b993 100644 --- a/MdePkg/Include/Library/PcdLib.h +++ b/MdePkg/Include/Library/PcdLib.h @@ -18,94 +18,96 @@ Module Name: PcdLib.h #ifndef __PCD_LIB_H__ #define __PCD_LIB_H__ -#include +#define PCD_INVALID_TOKEN_NUMBER ((UINTN) 0) - -#define PcdToken(TokenName) _PCD_TOKEN_##TokenName +#define PcdToken(TokenName) _PCD_TOKEN_##TokenName // // Feature Flag is in the form of a global constant // -#define FeaturePcdGet(TokenName) _gPcd_FixedAtBuild_##TokenName +#define FeaturePcdGet(TokenName) _PCD_GET_MODE_BOOL_##TokenName // // Fixed is fixed at build time // -#define FixedPcdGet8(TokenName) _gPcd_FixedAtBuild_##TokenName -#define FixedPcdGet16(TokenName) _gPcd_FixedAtBuild_##TokenName -#define FixedPcdGet32(TokenName) _gPcd_FixedAtBuild_##TokenName -#define FixedPcdGet64(TokenName) _gPcd_FixedAtBuild_##TokenName -#define FixedPcdGetBool(TokenName) _gPcd_FixedAtBuild_##TokenName +#define FixedPcdGet8(TokenName) _PCD_VALUE_##TokenName +#define FixedPcdGet16(TokenName) _PCD_VALUE_##TokenName +#define FixedPcdGet32(TokenName) _PCD_VALUE_##TokenName +#define FixedPcdGet64(TokenName) _PCD_VALUE_##TokenName +#define FixedPcdGetBool(TokenName) _PCD_VALUE_##TokenName -// -// BugBug: This works for strings, but not constants. -// -#define FixedPcdGetPtr(TokenName) ((VOID *)_gPcd_FixedAtBuild_##TokenName) +#define FixedPcdGetPtr(TokenName) ((VOID *)_PCD_VALUE_##TokenName) // // (Binary) Patch is in the form of a global variable // -#define PatchPcdGet8(TokenName) _gPcd_BinaryPatch_##TokenName -#define PatchPcdGet16(TokenName) _gPcd_BinaryPatch_##TokenName -#define PatchPcdGet32(TokenName) _gPcd_BinaryPatch_##TokenName -#define PatchPcdGet64(TokenName) _gPcd_BinaryPatch_##TokenName -#define PatchPcdGetBool(TokenName) _gPcd_BinaryPatch_##TokenName -#define PatchPcdGetPtr(TokenName) ((VOID *)_gPcd_BinaryPatch_##TokenName) - -#define PatchPcdSet8(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = Value) -#define PatchPcdSet16(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = Value) -#define PatchPcdSet32(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = Value) -#define PatchPcdSet64(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = Value) -#define PatchPcdSetBool(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = Value) -#define PatchPcdSetPtr(TokenName, Value, Size) CopyMem (_gPcd_BinaryPatch_##TokenName, Value, Size) +#define PatchPcdGet8(TokenName) _gPcd_BinaryPatch_##TokenName +#define PatchPcdGet16(TokenName) _gPcd_BinaryPatch_##TokenName +#define PatchPcdGet32(TokenName) _gPcd_BinaryPatch_##TokenName +#define PatchPcdGet64(TokenName) _gPcd_BinaryPatch_##TokenName +#define PatchPcdGetBool(TokenName) _gPcd_BinaryPatch_##TokenName +#define PatchPcdGetPtr(TokenName) ((VOID *)_gPcd_BinaryPatch_##TokenName) + +#define PatchPcdSet8(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value)) +#define PatchPcdSet16(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value)) +#define PatchPcdSet32(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value)) +#define PatchPcdSet64(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value)) +#define PatchPcdSetBool(TokenName, Value) (_gPcd_BinaryPatch_##TokenName = (Value)) +#define PatchPcdSetPtr(TokenName, Size, Buffer) \ + LibPatchPcdSetPtr ( \ + _gPcd_BinaryPatch_##TokenName, \ + (UINTN)_PCD_PATCHABLE_##TokenName##_SIZE, \ + (Size), \ + (Buffer) \ + ) // // Dynamic is via the protocol with only the TokenNumber as argument // It can also be Patch or Fixed type based on a build option // -#define PcdGet8(TokenName) _PCD_MODE_8_##TokenName -#define PcdGet16(TokenName) _PCD_MODE_16_##TokenName -#define PcdGet32(TokenName) _PCD_MODE_32_##TokenName -#define PcdGet64(TokenName) _PCD_MODE_64_##TokenName -#define PcdGetPtr(TokenName) _PCD_MODE_PTR_##TokenName -#define PcdGetBool(TokenName) _PCD_MODE_BOOL_##TokenName - +#define PcdGet8(TokenName) _PCD_GET_MODE_8_##TokenName +#define PcdGet16(TokenName) _PCD_GET_MODE_16_##TokenName +#define PcdGet32(TokenName) _PCD_GET_MODE_32_##TokenName +#define PcdGet64(TokenName) _PCD_GET_MODE_64_##TokenName +#define PcdGetPtr(TokenName) _PCD_GET_MODE_PTR_##TokenName +#define PcdGetBool(TokenName) _PCD_GET_MODE_BOOL_##TokenName // -// Dynamic Ex is to support binary distribution +// Dynamic Set // -#define PcdGetEx8(Guid, TokenName) LibPcdGetEx8 (Guid, _PCD_TOKEN_##TokenName) -#define PcdGetEx16(Guid, TokenName) LibPcdGetEx16 (Guid, _PCD_TOKEN_##TokenName) -#define PcdGetEx32(Guid, TokenName) LibPcdGetEx32 (Guid, _PCD_TOKEN_##TokenName) -#define PcdGetEx64(Guid, TokenName) LibPcdGetEx64 (Guid, _PCD_TOKEN_##TokenName) -#define PcdGetExPtr(Guid, TokenName) LibPcdGetExPtr (Guid, _PCD_TOKEN_##TokenName) -#define PcdGetExBool(Guid, TokenName) LibPcdGetExBool (Guid, _PCD_TOKEN_##TokenName) - +#define PcdSet8(TokenName, Value) _PCD_SET_MODE_8_##TokenName ((Value)) +#define PcdSet16(TokenName, Value) _PCD_SET_MODE_16_##TokenName ((Value)) +#define PcdSet32(TokenName, Value) _PCD_SET_MODE_32_##TokenName ((Value)) +#define PcdSet64(TokenName, Value) _PCD_SET_MODE_64_##TokenName ((Value)) +#define PcdSetPtr(TokenName, SizeOfBuffer, Buffer) \ + _PCD_SET_MODE_PTR_##TokenName ((SizeOfBuffer), (Buffer)) +#define PcdSetBool(TokenName, Value) _PCD_SET_MODE_BOOL_##TokenName ((Value)) // -// Dynamic Set +// Dynamic Ex is to support binary distribution // -#define PcdSet8(TokenName, Value) LibPcdSet8 (_PCD_TOKEN_##TokenName, Value) -#define PcdSet16(TokenName, Value) LibPcdSet16 (_PCD_TOKEN_##TokenName, Value) -#define PcdSet32(TokenName, Value) LibPcdSet32 (_PCD_TOKEN_##TokenName, Value) -#define PcdSet64(TokenName, Value) LibPcdSet64 (_PCD_TOKEN_##TokenName, Value) -#define PcdSetPtr(TokenName, Value) LibPcdSetPtr (_PCD_TOKEN_##TokenName, Value) -#define PcdSetBool(TokenName, Value) LibPcdSetBool(_PCD_TOKEN_##TokenName, Value) - +#define PcdGetEx8(Guid, TokenName) LibPcdGetEx8 ((Guid), _PCD_TOKEN_##TokenName) +#define PcdGetEx16(Guid, TokenName) LibPcdGetEx16 ((Guid), _PCD_TOKEN_##TokenName) +#define PcdGetEx32(Guid, TokenName) LibPcdGetEx32 ((Guid), _PCD_TOKEN_##TokenName) +#define PcdGetEx64(Guid, TokenName) LibPcdGetEx64 ((Guid), _PCD_TOKEN_##TokenName) +#define PcdGetExPtr(Guid, TokenName) LibPcdGetExPtr ((Guid), _PCD_TOKEN_##TokenName) +#define PcdGetExBool(Guid, TokenName) LibPcdGetExBool ((Guid), _PCD_TOKEN_##TokenName) // // Dynamic Set Ex // -#define PcdSetEx8(Guid, TokenName, Value) LibPcdSetEx8 (Guid, _PCD_TOKEN_##TokenName, Value) -#define PcdSetEx16(Guid, TokenName, Value) LibPcdSetEx16 (Guid, _PCD_TOKEN_##TokenName, Value) -#define PcdSetEx32(Guid, TokenName, Value) LibPcdSetEx32 (Guid, _PCD_TOKEN_##TokenName, Value) -#define PcdSetEx64(Guid, TokenName, Value) LibPcdSetEx64 (Guid, _PCD_TOKEN_##TokenName, Value) -#define PcdSetExPtr(Guid, TokenName, Value) LibPcdSetExPtr (Guid, _PCD_TOKEN_##TokenName, Value) -#define PcdSetExBool(Guid, TokenName, Value) LibPcdSetExBool(Guid, _PCD_TOKEN_##TokenName, Value) +#define PcdSetEx8(Guid, TokenName, Value) LibPcdSetEx8 ((Guid), _PCD_TOKEN_##TokenName, (Value)) +#define PcdSetEx16(Guid, TokenName, Value) LibPcdSetEx16 ((Guid), _PCD_TOKEN_##TokenName, (Value)) +#define PcdSetEx32(Guid, TokenName, Value) LibPcdSetEx32 ((Guid), _PCD_TOKEN_##TokenName, (Value)) +#define PcdSetEx64(Guid, TokenName, Value) LibPcdSetEx64 ((Guid), _PCD_TOKEN_##TokenName, (Value)) +#define PcdSetExPtr(Guid, TokenName, SizeOfBuffer, Buffer) \ + LibPcdSetExPtr ((Guid), _PCD_TOKEN_##TokenName, (SizeOfBuffer), (Buffer)) +#define PcdSetExBool(Guid, TokenName, Value) \ + LibPcdSetExBool((Guid), _PCD_TOKEN_##TokenName, (Value)) /** @@ -117,10 +119,10 @@ Module Name: PcdLib.h @retval SKU_ID Return the SKU ID that just be set. **/ -SKU_ID +UINTN EFIAPI LibPcdSetSku ( - IN SKU_ID SkuId + IN UINTN SkuId ); @@ -135,7 +137,7 @@ LibPcdSetSku ( UINT8 EFIAPI LibPcdGet8 ( - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -150,7 +152,7 @@ LibPcdGet8 ( UINT16 EFIAPI LibPcdGet16 ( - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -165,7 +167,7 @@ LibPcdGet16 ( UINT32 EFIAPI LibPcdGet32 ( - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -180,7 +182,7 @@ LibPcdGet32 ( UINT64 EFIAPI LibPcdGet64 ( - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -195,7 +197,7 @@ LibPcdGet64 ( VOID * EFIAPI LibPcdGetPtr ( - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -210,7 +212,7 @@ LibPcdGetPtr ( BOOLEAN EFIAPI LibPcdGetBool ( - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -225,7 +227,7 @@ LibPcdGetBool ( UINTN EFIAPI LibPcdGetSize ( - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -244,7 +246,7 @@ UINT8 EFIAPI LibPcdGetEx8 ( IN CONST GUID *Guid, - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -263,7 +265,7 @@ UINT16 EFIAPI LibPcdGetEx16 ( IN CONST GUID *Guid, - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -282,7 +284,7 @@ UINT32 EFIAPI LibPcdGetEx32 ( IN CONST GUID *Guid, - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -301,7 +303,7 @@ UINT64 EFIAPI LibPcdGetEx64 ( IN CONST GUID *Guid, - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -320,7 +322,7 @@ VOID * EFIAPI LibPcdGetExPtr ( IN CONST GUID *Guid, - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -339,7 +341,7 @@ BOOLEAN EFIAPI LibPcdGetExBool ( IN CONST GUID *Guid, - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -358,7 +360,7 @@ UINTN EFIAPI LibPcdGetExSize ( IN CONST GUID *Guid, - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber ); @@ -375,7 +377,7 @@ LibPcdGetExSize ( UINT8 EFIAPI LibPcdSet8 ( - IN PCD_TOKEN_NUMBER TokenNumber, + IN UINTN TokenNumber, IN UINT8 Value ); @@ -393,7 +395,7 @@ LibPcdSet8 ( UINT16 EFIAPI LibPcdSet16 ( - IN PCD_TOKEN_NUMBER TokenNumber, + IN UINTN TokenNumber, IN UINT16 Value ); @@ -411,7 +413,7 @@ LibPcdSet16 ( UINT32 EFIAPI LibPcdSet32 ( - IN PCD_TOKEN_NUMBER TokenNumber, + IN UINTN TokenNumber, IN UINT32 Value ); @@ -429,17 +431,26 @@ LibPcdSet32 ( UINT64 EFIAPI LibPcdSet64 ( - IN PCD_TOKEN_NUMBER TokenNumber, + IN UINTN TokenNumber, IN UINT64 Value ); /** - Sets a buffer for the token specified by TokenNumber to - the value specified by Value. Value is returned. - If Value is NULL, then ASSERT(). + Sets a buffer for the token specified by TokenNumber to the value + specified by Buffer and SizeOfValue. Buffer is returned. + If SizeOfValue is greater than the maximum size support by TokenNumber, + then set SizeOfValue to the maximum size supported by TokenNumber and + return NULL to indicate that the set operation was not actually performed. + + If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to the + maximum size supported by TokenName and NULL must be returned. + + If SizeOfValue is NULL, then ASSERT(). + If SizeOfValue > 0 and Buffer is NULL, then ASSERT(). @param[in] TokenNumber The PCD token number to set a current value for. + @param[in,out] SizeOfBuffer The size, in bytes, of Buffer. @param[in] Value A pointer to the buffer to set. @retval VOID* Return the pointer for the buffer been set. @@ -448,9 +459,9 @@ LibPcdSet64 ( VOID* EFIAPI LibPcdSetPtr ( - IN PCD_TOKEN_NUMBER TokenNumber, - IN UINTN SizeOfBuffer, - IN CONST VOID *Value + IN UINTN TokenNumber, + IN OUT UINTN *SizeOfBuffer, + IN VOID *Value ); @@ -467,7 +478,7 @@ LibPcdSetPtr ( BOOLEAN EFIAPI LibPcdSetBool ( - IN PCD_TOKEN_NUMBER TokenNumber, + IN UINTN TokenNumber, IN BOOLEAN Value ); @@ -489,7 +500,7 @@ UINT8 EFIAPI LibPcdSetEx8 ( IN CONST GUID *Guid, - IN PCD_TOKEN_NUMBER TokenNumber, + IN UINTN TokenNumber, IN UINT8 Value ); @@ -511,7 +522,7 @@ UINT16 EFIAPI LibPcdSetEx16 ( IN CONST GUID *Guid, - IN PCD_TOKEN_NUMBER TokenNumber, + IN UINTN TokenNumber, IN UINT16 Value ); @@ -533,7 +544,7 @@ UINT32 EFIAPI LibPcdSetEx32 ( IN CONST GUID *Guid, - IN PCD_TOKEN_NUMBER TokenNumber, + IN UINTN TokenNumber, IN UINT32 Value ); @@ -555,32 +566,38 @@ UINT64 EFIAPI LibPcdSetEx64 ( IN CONST GUID *Guid, - IN PCD_TOKEN_NUMBER TokenNumber, + IN UINTN TokenNumber, IN UINT64 Value ); /** - Sets a buffer for the token specified by TokenNumber and - Guid to the value specified by Value. Value is returned. + Sets a buffer for the token specified by TokenNumber to the value specified by + Buffer and SizeOfValue. Buffer is returned. If SizeOfValue is greater than + the maximum size support by TokenNumber, then set SizeOfValue to the maximum size + supported by TokenNumber and return NULL to indicate that the set operation + was not actually performed. + If Guid is NULL, then ASSERT(). - If Value is NULL, then ASSERT(). + If SizeOfValue is NULL, then ASSERT(). + If SizeOfValue > 0 and Buffer is NULL, then ASSERT(). @param[in] Guid Pointer to a 128-bit unique value that designates which namespace to set a value from. @param[in] TokenNumber The PCD token number to set a current value for. - @param[in] Value The 8-bit value to set. + @param[in, out] SizeOfBuffer The size, in bytes, of Buffer. + @param[in] Buffer A pointer to the buffer to set. - @retval VOID * Return the value been set. + @retval VOID * Return the pinter to the buffer been set. **/ VOID * EFIAPI LibPcdSetExPtr ( - IN CONST GUID *Guid, - IN PCD_TOKEN_NUMBER TokenNumber, - IN UINTN SizeOfBuffer, - IN CONST VOID *Value + IN CONST GUID *Guid, + IN UINTN TokenNumber, + IN OUT UINTN *SizeOfBuffer, + IN VOID *Buffer ); @@ -601,7 +618,7 @@ BOOLEAN EFIAPI LibPcdSetExBool ( IN CONST GUID *Guid, - IN PCD_TOKEN_NUMBER TokenNumber, + IN UINTN TokenNumber, IN BOOLEAN Value ); @@ -612,9 +629,17 @@ LibPcdSetExBool ( If Guid is NULL, then the default token space is used. If NotificationFunction is NULL, then ASSERT(). + This notification function serves two purposes. Firstly, it notifies the module which + did the registration that the value of this PCD token has been set. Secondly, + it provides a mechanism for the module which did the registration to intercept + the set operation and override the value been set if necessary. After the invocation + of the callback function, TokenData will be used by PCD service PEIM or driver to + modify the internal data in PCD database. + + @param[in] CallBackGuid The PCD token GUID being set. @param[in] CallBackToken The PCD token number being set. - @param[in] TokenData A pointer to the token data being set. + @param[in, out] TokenData A pointer to the token data being set. @param[in] TokenDataSize The size, in bytes, of the data being set. @retval VOID @@ -624,7 +649,7 @@ typedef VOID (EFIAPI *PCD_CALLBACK) ( IN CONST GUID *CallBackGuid, OPTIONAL - IN PCD_TOKEN_NUMBER CallBackToken, + IN UINTN CallBackToken, IN OUT VOID *TokenData, IN UINTN TokenDataSize ); @@ -650,7 +675,7 @@ VOID EFIAPI LibPcdCallbackOnSet ( IN CONST GUID *Guid, OPTIONAL - IN PCD_TOKEN_NUMBER TokenNumber, + IN UINTN TokenNumber, IN PCD_CALLBACK NotificationFunction ); @@ -669,7 +694,7 @@ VOID EFIAPI LibPcdCancelCallback ( IN CONST GUID *Guid, OPTIONAL - IN PCD_TOKEN_NUMBER TokenNumber, + IN UINTN TokenNumber, IN PCD_CALLBACK NotificationFunction ); @@ -687,14 +712,68 @@ LibPcdCancelCallback ( @param[in] The previous PCD token number. If 0, then retrieves the first PCD token number. - @retval PCD_TOKEN_NUMBER The next valid token number. + @retval UINTN The next valid token number. **/ -PCD_TOKEN_NUMBER +UINTN EFIAPI LibPcdGetNextToken ( IN CONST GUID *Guid, OPTIONAL - IN PCD_TOKEN_NUMBER TokenNumber + IN UINTN TokenNumber + ); + + + +/** + Retrieves the next PCD token space from a token space specified by Guid. + Guid of NULL is reserved to mark the default local token namespace on the current + platform. If Guid is NULL, then the GUID of the first non-local token space of the + current platform is returned. If Guid is the last non-local token space, + then NULL is returned. + + If Guid is not NULL and is not a valid token space in the current platform, then ASSERT(). + + + + @param[in] Guid Pointer to a 128-bit unique value that designates from which namespace + to start the search. + + @retval CONST GUID * The next valid token namespace. + +**/ +GUID * +EFIAPI +LibPcdGetNextTokenSpace ( + IN CONST GUID *Guid + ); + + +/** + Sets the PCD entry specified by PatchVariable to the value specified by Buffer + and SizeOfValue. Buffer is returned. If SizeOfValue is greater than + MaximumDatumSize, then set SizeOfValue to MaximumDatumSize and return + NULL to indicate that the set operation was not actually performed. + If SizeOfValue is set to MAX_ADDRESS, then SizeOfValue must be set to + MaximumDatumSize and NULL must be returned. + + If PatchVariable is NULL, then ASSERT(). + If SizeOfValue is NULL, then ASSERT(). + If SizeOfValue > 0 and Buffer is NULL, then ASSERT(). + + @param[in] PatchVariable A pointer to the global variable in a module that is + the target of the set operation. + @param[in] MaximumDatumSize The maximum size allowed for the PCD entry specified by PatchVariable. + @param[in, out] SizeOfBuffer A pointer to the size, in bytes, of Buffer. + @param[in] Buffer A pointer to the buffer to used to set the target variable. + +**/ +VOID * +EFIAPI +LibPatchPcdSetPtr ( + IN VOID *PatchVariable, + IN UINTN MaximumDatumSize, + IN OUT UINTN *SizeOfBuffer, + IN CONST VOID *Buffer ); #endif