X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FPeiPcdLib%2FPeiPcdLib.c;h=31ff457fc8f7823cfc3b4d103298b3b9054f7ed4;hp=057a95716559ed5797bf7492e768b1b76b01c2b8;hb=da660118bd391d1f421f99921f9f15a66a8fc7ea;hpb=d6b58d3219bccd98867bae0733bed5b2228aeef1 diff --git a/MdePkg/Library/PeiPcdLib/PeiPcdLib.c b/MdePkg/Library/PeiPcdLib/PeiPcdLib.c index 057a957165..31ff457fc8 100644 --- a/MdePkg/Library/PeiPcdLib/PeiPcdLib.c +++ b/MdePkg/Library/PeiPcdLib/PeiPcdLib.c @@ -1,8 +1,8 @@ /** @file Implementation of PcdLib class library for PEI phase. -Copyright (c) 2006 - 2009, Intel Corporation
-All rights reserved. This program and the accompanying materials +Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -20,6 +20,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include +#include #include #include @@ -71,15 +73,61 @@ GetPiPcdPpiPointer ( return PiPcdPpi; } + +/** + Retrieve the GET_PCD_INFO_PPI pointer. + + This function is to locate GET_PCD_INFO_PPI PPI via PeiService. + If fail to locate GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR(). + + @retval GET_PCD_INFO_PPI * The pointer to the GET_PCD_INFO_PPI. + +**/ +GET_PCD_INFO_PPI * +GetPcdInfoPpiPointer ( + VOID + ) +{ + EFI_STATUS Status; + GET_PCD_INFO_PPI *PcdInfoPpi; + Status = PeiServicesLocatePpi (&gGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PcdInfoPpi); + ASSERT_EFI_ERROR (Status); + + return PcdInfoPpi; +} + +/** + Retrieve the pointer of EFI_GET_PCD_INFO_PPI defined in PI 1.2.1 Vol 3. + + This function is to locate EFI_GET_PCD_INFO_PPI PPI via PeiService. + If fail to locate EFI_GET_PCD_INFO_PPI, then ASSERT_EFI_ERROR(). + + @retval EFI_GET_PCD_INFO_PPI * The pointer to the EFI_GET_PCD_INFO_PPI. + +**/ +EFI_GET_PCD_INFO_PPI * +GetPiPcdInfoPpiPointer ( + VOID + ) +{ + EFI_STATUS Status; + EFI_GET_PCD_INFO_PPI *PiPcdInfoPpi; + + Status = PeiServicesLocatePpi (&gEfiGetPcdInfoPpiGuid, 0, NULL, (VOID **)&PiPcdInfoPpi); + ASSERT_EFI_ERROR (Status); + + return PiPcdInfoPpi; +} + /** This function provides a means by which SKU support can be established in the PCD infrastructure. Sets the current SKU in the PCD database to the value specified by SkuId. SkuId is returned. If SkuId >= PCD_MAX_SKU_ID, then ASSERT(). - @param SkuId The SKU value that will be used when the PCD service retrieves and sets values - associated with a PCD token. + @param SkuId The SKU value that will be used when the PCD service retrieves + and sets values associated with a PCD token. @return Return the SKU ID that just be set. @@ -252,7 +300,7 @@ LibPcdGetSize ( If Guid is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that designates + @param[in] Guid The pointer to a 128-bit unique value that designates which namespace to retrieve a value from. @param[in] TokenNumber The PCD token number to retrieve a current value for. @@ -268,7 +316,7 @@ LibPcdGetEx8 ( { ASSERT (Guid != NULL); - return (GetPiPcdPpiPointer ())->GetEx8 (Guid, TokenNumber); + return (GetPiPcdPpiPointer ())->Get8 (Guid, TokenNumber); } @@ -280,7 +328,7 @@ LibPcdGetEx8 ( If Guid is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that designates + @param[in] Guid The pointer to a 128-bit unique value that designates which namespace to retrieve a value from. @param[in] TokenNumber The PCD token number to retrieve a current value for. @@ -297,7 +345,7 @@ LibPcdGetEx16 ( ASSERT (Guid != NULL); - return (GetPiPcdPpiPointer ())->GetEx16 (Guid, TokenNumber); + return (GetPiPcdPpiPointer ())->Get16 (Guid, TokenNumber); } @@ -306,7 +354,7 @@ LibPcdGetEx16 ( Returns the 32-bit value for the token specified by TokenNumber and Guid. If Guid is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that designates + @param[in] Guid The pointer to a 128-bit unique value that designates which namespace to retrieve a value from. @param[in] TokenNumber The PCD token number to retrieve a current value for. @@ -322,7 +370,7 @@ LibPcdGetEx32 ( { ASSERT (Guid != NULL); - return (GetPiPcdPpiPointer ())->GetEx32 (Guid, TokenNumber); + return (GetPiPcdPpiPointer ())->Get32 (Guid, TokenNumber); } @@ -335,7 +383,7 @@ LibPcdGetEx32 ( If Guid is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that designates + @param[in] Guid The pointer to a 128-bit unique value that designates which namespace to retrieve a value from. @param[in] TokenNumber The PCD token number to retrieve a current value for. @@ -350,7 +398,7 @@ LibPcdGetEx64 ( ) { ASSERT (Guid != NULL); - return (GetPiPcdPpiPointer ())->GetEx64 (Guid, TokenNumber); + return (GetPiPcdPpiPointer ())->Get64 (Guid, TokenNumber); } @@ -362,7 +410,7 @@ LibPcdGetEx64 ( If Guid is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that designates + @param[in] Guid The pointer to a 128-bit unique value that designates which namespace to retrieve a value from. @param[in] TokenNumber The PCD token number to retrieve a current value for. @@ -378,7 +426,7 @@ LibPcdGetExPtr ( { ASSERT (Guid != NULL); - return (GetPiPcdPpiPointer ())->GetExPtr (Guid, TokenNumber); + return (GetPiPcdPpiPointer ())->GetPtr (Guid, TokenNumber); } @@ -390,7 +438,7 @@ LibPcdGetExPtr ( If Guid is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that designates + @param[in] Guid The pointer to a 128-bit unique value that designates which namespace to retrieve a value from. @param[in] TokenNumber The PCD token number to retrieve a current value for. @@ -405,7 +453,7 @@ LibPcdGetExBool ( ) { ASSERT (Guid != NULL); - return (GetPiPcdPpiPointer ())->GetExBool (Guid, TokenNumber); + return (GetPiPcdPpiPointer ())->GetBool (Guid, TokenNumber); } @@ -417,7 +465,7 @@ LibPcdGetExBool ( If Guid is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that designates + @param[in] Guid The pointer to a 128-bit unique value that designates which namespace to retrieve a value from. @param[in] TokenNumber The PCD token number to retrieve a current value for. @@ -432,7 +480,7 @@ LibPcdGetExSize ( ) { ASSERT (Guid != NULL); - return (GetPiPcdPpiPointer ())->GetExSize (Guid, TokenNumber); + return (GetPiPcdPpiPointer ())->GetSize (Guid, TokenNumber); } @@ -446,7 +494,7 @@ LibPcdGetExSize ( @param[in] TokenNumber The PCD token number to set a current value for. @param[in] Value The 8-bit value to set. - @return Return the value been set. + @return Return the value that was set. **/ UINT8 @@ -476,7 +524,7 @@ LibPcdSet8 ( @param[in] TokenNumber The PCD token number to set a current value for. @param[in] Value The 16-bit value to set. - @return Return the value been set. + @return Return the value that was set. **/ UINT16 @@ -506,7 +554,7 @@ LibPcdSet16 ( @param[in] TokenNumber The PCD token number to set a current value for. @param[in] Value The 32-bit value to set. - @return Return the value been set. + @return Return the value that was set. **/ UINT32 @@ -536,7 +584,7 @@ LibPcdSet32 ( @param[in] TokenNumber The PCD token number to set a current value for. @param[in] Value The 64-bit value to set. - @return Return the value been set. + @return Return the value that was set. **/ UINT64 @@ -615,7 +663,7 @@ LibPcdSetPtr ( @param[in] TokenNumber The PCD token number to set a current value for. @param[in] Value The boolean value to set. - @return Return the value been set. + @return Return the value that was set. **/ BOOLEAN @@ -644,12 +692,12 @@ LibPcdSetBool ( If Guid is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that + @param[in] Guid The 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. - @return Return the value been set. + @return Return the value that was set. **/ UINT8 @@ -664,7 +712,7 @@ LibPcdSetEx8 ( ASSERT (Guid != NULL); - Status = (GetPiPcdPpiPointer ())->SetEx8 (Guid, TokenNumber, Value); + Status = (GetPiPcdPpiPointer ())->Set8 (Guid, TokenNumber, Value); ASSERT_EFI_ERROR (Status); @@ -681,12 +729,12 @@ LibPcdSetEx8 ( If Guid is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that + @param[in] Guid The 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 16-bit value to set. - @return Return the value been set. + @return Return the value that was set. **/ UINT16 @@ -699,7 +747,7 @@ LibPcdSetEx16 ( { EFI_STATUS Status; ASSERT (Guid != NULL); - Status = (GetPiPcdPpiPointer ())->SetEx16 (Guid, TokenNumber, Value); + Status = (GetPiPcdPpiPointer ())->Set16 (Guid, TokenNumber, Value); ASSERT_EFI_ERROR (Status); @@ -716,12 +764,12 @@ LibPcdSetEx16 ( If Guid is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that + @param[in] Guid The 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 32-bit value to set. - @return Return the value been set. + @return Return the value that was set. **/ UINT32 @@ -736,7 +784,7 @@ LibPcdSetEx32 ( ASSERT (Guid != NULL); - Status = (GetPiPcdPpiPointer ())->SetEx32 (Guid, TokenNumber, Value); + Status = (GetPiPcdPpiPointer ())->Set32 (Guid, TokenNumber, Value); ASSERT_EFI_ERROR (Status); @@ -752,12 +800,12 @@ LibPcdSetEx32 ( Guid to the value specified by Value. Value is returned. If Guid is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that + @param[in] Guid The 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 64-bit value to set. - @return Return the value been set. + @return Return the value that was set. **/ UINT64 @@ -771,7 +819,7 @@ LibPcdSetEx64 ( EFI_STATUS Status; ASSERT (Guid != NULL); - Status = (GetPiPcdPpiPointer ())->SetEx64 (Guid, TokenNumber, Value); + Status = (GetPiPcdPpiPointer ())->Set64 (Guid, TokenNumber, Value); ASSERT_EFI_ERROR (Status); @@ -793,7 +841,7 @@ LibPcdSetEx64 ( If SizeOfBuffer is NULL, then ASSERT(). If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that + @param[in] Guid The 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, out] SizeOfBuffer The size, in bytes, of Buffer. @@ -818,7 +866,7 @@ LibPcdSetExPtr ( } ASSERT (Guid != NULL); - Status = (GetPiPcdPpiPointer ())->SetExPtr (Guid, TokenNumber, SizeOfBuffer, Buffer); + Status = (GetPiPcdPpiPointer ())->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer); if (EFI_ERROR (Status)) { return NULL; @@ -837,12 +885,12 @@ LibPcdSetExPtr ( If Guid is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that + @param[in] Guid The 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 Boolean value to set. - @return Return the value been set. + @return Return the value that was set. **/ BOOLEAN @@ -856,7 +904,7 @@ LibPcdSetExBool ( EFI_STATUS Status; ASSERT (Guid != NULL); - Status = (GetPiPcdPpiPointer ())->SetExBool (Guid, TokenNumber, Value); + Status = (GetPiPcdPpiPointer ())->SetBool (Guid, TokenNumber, Value); ASSERT_EFI_ERROR (Status); @@ -873,9 +921,9 @@ LibPcdSetExBool ( If Guid is NULL, then the default token space is used. If NotificationFunction is NULL, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that designates which - namespace to set a value from. If NULL, then the default - token space is used. + @param[in] Guid The pointer to a 128-bit unique value that + designates which namespace to set a value from. + If NULL, then the default token space is used. @param[in] TokenNumber The PCD token number to monitor. @param[in] NotificationFunction The function to call when the token specified by Guid and TokenNumber is set. @@ -947,7 +995,7 @@ LibPcdCancelCallback ( If TokenNumber is not 0 and is not in the token space specified by Guid, then ASSERT(). - @param[in] Guid Pointer to a 128-bit unique value that designates which namespace + @param[in] Guid The pointer to a 128-bit unique value that designates which namespace to set a value from. If NULL, then the default token space is used. @param[in] TokenNumber The previous PCD token number. If 0, then retrieves the first PCD token number. @@ -962,11 +1010,10 @@ LibPcdGetNextToken ( IN UINTN TokenNumber ) { - EFI_STATUS Status; + EFI_STATUS Status; Status = (GetPiPcdPpiPointer ())->GetNextToken (Guid, &TokenNumber); - - ASSERT_EFI_ERROR (Status); + ASSERT (!EFI_ERROR (Status) || TokenNumber == 0); return TokenNumber; } @@ -980,7 +1027,7 @@ LibPcdGetNextToken ( If TokenSpaceGuid is NULL, then a pointer to the first PCD token spaces returned. If TokenSpaceGuid is the last PCD token space GUID in the list, then NULL is returned. - @param TokenSpaceGuid Pointer to the a PCD token space GUID + @param TokenSpaceGuid The pointer to the a PCD token space GUID @return The next valid token namespace. @@ -991,11 +1038,7 @@ LibPcdGetNextTokenSpace ( IN CONST GUID *TokenSpaceGuid ) { - EFI_STATUS Status; - - Status = (GetPiPcdPpiPointer ())->GetNextTokenSpace (&TokenSpaceGuid); - - ASSERT_EFI_ERROR (Status); + (GetPiPcdPpiPointer ())->GetNextTokenSpace (&TokenSpaceGuid); return (GUID *) TokenSpaceGuid; } @@ -1052,4 +1095,77 @@ LibPatchPcdSetPtr ( return (VOID *) Buffer; } +/** + Retrieve additional information associated with a PCD token. + + This includes information such as the type of value the TokenNumber is associated with as well as possible + human readable name that is associated with the token. + + If TokenNumber is not in the default token space specified, then ASSERT(). + + @param[in] TokenNumber The PCD token number. + @param[out] PcdInfo The returned information associated with the requested TokenNumber. + The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName. +**/ +VOID +EFIAPI +LibPcdGetInfo ( + IN UINTN TokenNumber, + OUT PCD_INFO *PcdInfo + ) +{ + EFI_STATUS Status; + + Status = GetPcdInfoPpiPointer()->GetInfo (TokenNumber, (EFI_PCD_INFO *) PcdInfo); + ASSERT_EFI_ERROR (Status); +} + +/** + Retrieve additional information associated with a PCD token. + + This includes information such as the type of value the TokenNumber is associated with as well as possible + human readable name that is associated with the token. + + If TokenNumber is not in the token space specified by Guid, then ASSERT(). + @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value. + @param[in] TokenNumber The PCD token number. + @param[out] PcdInfo The returned information associated with the requested TokenNumber. + The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName. +**/ +VOID +EFIAPI +LibPcdGetInfoEx ( + IN CONST GUID *Guid, + IN UINTN TokenNumber, + OUT PCD_INFO *PcdInfo + ) +{ + EFI_STATUS Status; + + Status = GetPiPcdInfoPpiPointer()->GetInfo (Guid, TokenNumber, (EFI_PCD_INFO *) PcdInfo); + ASSERT_EFI_ERROR (Status); +} + +/** + Retrieve the currently set SKU Id. + + If the sku id got >= PCD_MAX_SKU_ID, then ASSERT(). + + @return The currently set SKU Id. If the platform has not set at a SKU Id, then the + default SKU Id value of 0 is returned. If the platform has set a SKU Id, then the currently set SKU + Id is returned. +**/ +UINTN +EFIAPI +LibPcdGetSku ( + VOID + ) +{ + UINTN SkuId; + + SkuId = GetPiPcdInfoPpiPointer()->GetSku (); + ASSERT (SkuId < PCD_MAX_SKU_ID); + + return SkuId; +}