X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FDxePcdLib%2FDxePcdLib.c;h=f14a74652978bb38f6c1af867ab4294c7faa6e77;hp=a7303e800c3d9046c6fbd5cc567a8b2013f936eb;hb=da660118bd391d1f421f99921f9f15a66a8fc7ea;hpb=b35a5f731c499f1fb5b6817c77ceaff4ef0f896b diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.c b/MdePkg/Library/DxePcdLib/DxePcdLib.c index a7303e800c..f14a746529 100644 --- a/MdePkg/Library/DxePcdLib/DxePcdLib.c +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.c @@ -1,7 +1,7 @@ /** @file Implementation of PcdLib class library for DXE phase. -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+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 @@ -18,17 +18,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include +#include #include #include #include #include -PCD_PROTOCOL *mPcd = NULL; -EFI_PCD_PROTOCOL *mPiPcd = NULL; +PCD_PROTOCOL *mPcd = NULL; +EFI_PCD_PROTOCOL *mPiPcd = NULL; +GET_PCD_INFO_PROTOCOL *mPcdInfo = NULL; +EFI_GET_PCD_INFO_PROTOCOL *mPiPcdInfo = NULL; /** Retrieves the PI PCD protocol from the handle database. + + @retval EFI_PCD_PROTOCOL * The pointer to the EFI_PCD_PROTOCOL. **/ EFI_PCD_PROTOCOL * EFIAPI @@ -52,6 +58,8 @@ GetPiPcdProtocol ( /** Retrieves the PCD protocol from the handle database. + + @retval PCD_PROTOCOL * The pointer to the PCD_PROTOCOL. **/ PCD_PROTOCOL * EFIAPI @@ -73,6 +81,45 @@ GetPcdProtocol ( return mPcd; } +/** + Retrieves the PI PCD info protocol from the handle database. + + @retval EFI_GET_PCD_INFO_PROTOCOL * The pointer to the EFI_GET_PCD_INFO_PROTOCOL defined in PI 1.2.1 Vol 3. +**/ +EFI_GET_PCD_INFO_PROTOCOL * +GetPiPcdInfoProtocolPointer ( + VOID + ) +{ + EFI_STATUS Status; + + if (mPiPcdInfo == NULL) { + Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo); + ASSERT_EFI_ERROR (Status); + ASSERT (mPiPcdInfo != NULL); + } + return mPiPcdInfo; +} + +/** + Retrieves the PCD info protocol from the handle database. + + @retval GET_PCD_INFO_PROTOCOL * The pointer to the GET_PCD_INFO_PROTOCOL. +**/ +GET_PCD_INFO_PROTOCOL * +GetPcdInfoProtocolPointer ( + VOID + ) +{ + EFI_STATUS Status; + + if (mPcdInfo == NULL) { + Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo); + ASSERT_EFI_ERROR (Status); + ASSERT (mPcdInfo != NULL); + } + return mPcdInfo; +} /** This function provides a means by which SKU support can be established in the PCD infrastructure. @@ -955,10 +1002,10 @@ LibPcdGetNextToken ( IN UINTN TokenNumber ) { - EFI_STATUS Status; + EFI_STATUS Status; Status = GetPiPcdProtocol()->GetNextToken (Guid, &TokenNumber); - ASSERT_EFI_ERROR (Status); + ASSERT (!EFI_ERROR (Status) || TokenNumber == 0); return TokenNumber; } @@ -984,10 +1031,7 @@ LibPcdGetNextTokenSpace ( IN CONST GUID *TokenSpaceGuid ) { - EFI_STATUS Status; - - Status = GetPiPcdProtocol()->GetNextTokenSpace (&TokenSpaceGuid); - ASSERT_EFI_ERROR (Status); + GetPiPcdProtocol()->GetNextTokenSpace (&TokenSpaceGuid); return (GUID *)TokenSpaceGuid; } @@ -1043,5 +1087,78 @@ 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 = GetPcdInfoProtocolPointer()->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 = GetPiPcdInfoProtocolPointer()->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 = GetPiPcdInfoProtocolPointer()->GetSku (); + ASSERT (SkuId < PCD_MAX_SKU_ID); + + return SkuId; +}