X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FDxePcdLib%2FDxePcdLib.c;h=cd8212824fc74d773c2107221fd7ac87f8168dd3;hp=703dd428a0ccfad3eff262e130e306848871f397;hb=419db80bef66edff583a0a5f406e801d70f11344;hpb=c00bdbb14ae126f1f614f396eae19a36afc863c6 diff --git a/MdePkg/Library/DxePcdLib/DxePcdLib.c b/MdePkg/Library/DxePcdLib/DxePcdLib.c index 703dd428a0..cd8212824f 100644 --- a/MdePkg/Library/DxePcdLib/DxePcdLib.c +++ b/MdePkg/Library/DxePcdLib/DxePcdLib.c @@ -1,8 +1,8 @@ /** @file Implementation of PcdLib class library for DXE phase. -Copyright (c) 2006 - 2008, 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 @@ -17,42 +17,60 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include #include #include #include #include -PCD_PROTOCOL *mPcd = NULL; - +PCD_PROTOCOL *mPcd = NULL; +EFI_PCD_PROTOCOL *mPiPcd = NULL; /** - The constructor function caches the PCD_PROTOCOL pointer. + Retrieves the PI PCD protocol from the handle database. +**/ +EFI_PCD_PROTOCOL * +EFIAPI +GetPiPcdProtocol ( + VOID + ) +{ + EFI_STATUS Status; - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The constructor always return EFI_SUCCESS. + if (mPiPcd == NULL) { + // + // PI Pcd protocol defined in PI 1.2 vol3 should be installed before the module + // access DynamicEx type PCD. + // + Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd); + ASSERT_EFI_ERROR (Status); + ASSERT (mPiPcd != NULL); + } + return mPiPcd; +} +/** + Retrieves the PCD protocol from the handle database. **/ -EFI_STATUS +PCD_PROTOCOL * EFIAPI -PcdLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +GetPcdProtocol ( + VOID ) { EFI_STATUS Status; - // - // PCD protocol has not been installed, but a module needs to access a - // dynamic PCD entry. - // - Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd); - ASSERT_EFI_ERROR (Status); - ASSERT (mPcd!= NULL); - - return Status; + if (mPcd == NULL) { + // + // PCD protocol need to be installed before the module access Dynamic type PCD. + // But dynamic type PCD is not required in PI 1.2 specification. + // + Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd); + ASSERT_EFI_ERROR (Status); + ASSERT (mPcd != NULL); + } + return mPcd; } @@ -76,7 +94,7 @@ LibPcdSetSku ( { ASSERT (SkuId < PCD_MAX_SKU_ID); - mPcd->SetSku (SkuId); + GetPcdProtocol()->SetSku (SkuId); return SkuId; } @@ -99,7 +117,7 @@ LibPcdGet8 ( IN UINTN TokenNumber ) { - return mPcd->Get8 (TokenNumber); + return GetPcdProtocol()->Get8 (TokenNumber); } @@ -120,7 +138,7 @@ LibPcdGet16 ( IN UINTN TokenNumber ) { - return mPcd->Get16 (TokenNumber); + return GetPcdProtocol()->Get16 (TokenNumber); } @@ -141,7 +159,7 @@ LibPcdGet32 ( IN UINTN TokenNumber ) { - return mPcd->Get32 (TokenNumber); + return GetPcdProtocol()->Get32 (TokenNumber); } @@ -162,7 +180,7 @@ LibPcdGet64 ( IN UINTN TokenNumber ) { - return mPcd->Get64 (TokenNumber); + return GetPcdProtocol()->Get64 (TokenNumber); } @@ -183,7 +201,7 @@ LibPcdGetPtr ( IN UINTN TokenNumber ) { - return mPcd->GetPtr (TokenNumber); + return GetPcdProtocol()->GetPtr (TokenNumber); } @@ -204,7 +222,7 @@ LibPcdGetBool ( IN UINTN TokenNumber ) { - return mPcd->GetBool (TokenNumber); + return GetPcdProtocol()->GetBool (TokenNumber); } @@ -223,7 +241,7 @@ LibPcdGetSize ( IN UINTN TokenNumber ) { - return mPcd->GetSize (TokenNumber); + return GetPcdProtocol()->GetSize (TokenNumber); } @@ -235,7 +253,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. @@ -251,7 +269,7 @@ LibPcdGetEx8 ( { ASSERT (Guid != NULL); - return mPcd->Get8Ex (Guid, TokenNumber); + return GetPiPcdProtocol()->Get8 (Guid, TokenNumber); } @@ -262,7 +280,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. @@ -278,7 +296,7 @@ LibPcdGetEx16 ( { ASSERT (Guid != NULL); - return mPcd->Get16Ex (Guid, TokenNumber); + return GetPiPcdProtocol()->Get16 (Guid, TokenNumber); } @@ -286,7 +304,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. @@ -302,7 +320,7 @@ LibPcdGetEx32 ( { ASSERT (Guid != NULL); - return mPcd->Get32Ex (Guid, TokenNumber); + return GetPiPcdProtocol()->Get32 (Guid, TokenNumber); } @@ -314,7 +332,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. @@ -330,7 +348,7 @@ LibPcdGetEx64 ( { ASSERT (Guid != NULL); - return mPcd->Get64Ex (Guid, TokenNumber); + return GetPiPcdProtocol()->Get64 (Guid, TokenNumber); } @@ -342,7 +360,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. @@ -358,7 +376,7 @@ LibPcdGetExPtr ( { ASSERT (Guid != NULL); - return mPcd->GetPtrEx (Guid, TokenNumber); + return GetPiPcdProtocol()->GetPtr (Guid, TokenNumber); } @@ -370,7 +388,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. @@ -386,7 +404,7 @@ LibPcdGetExBool ( { ASSERT (Guid != NULL); - return mPcd->GetBoolEx (Guid, TokenNumber); + return GetPiPcdProtocol()->GetBool (Guid, TokenNumber); } @@ -398,7 +416,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. @@ -414,7 +432,7 @@ LibPcdGetExSize ( { ASSERT (Guid != NULL); - return mPcd->GetSizeEx (Guid, TokenNumber); + return GetPiPcdProtocol()->GetSize (Guid, TokenNumber); } @@ -428,7 +446,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 @@ -440,8 +458,7 @@ LibPcdSet8 ( { EFI_STATUS Status; - Status = mPcd->Set8 (TokenNumber, Value); - + Status = GetPcdProtocol()->Set8 (TokenNumber, Value); ASSERT_EFI_ERROR (Status); return Value; @@ -458,7 +475,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 @@ -470,8 +487,7 @@ LibPcdSet16 ( { EFI_STATUS Status; - Status = mPcd->Set16 (TokenNumber, Value); - + Status = GetPcdProtocol()->Set16 (TokenNumber, Value); ASSERT_EFI_ERROR (Status); return Value; @@ -488,7 +504,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 @@ -499,8 +515,8 @@ LibPcdSet32 ( ) { EFI_STATUS Status; - Status = mPcd->Set32 (TokenNumber, Value); - + + Status = GetPcdProtocol()->Set32 (TokenNumber, Value); ASSERT_EFI_ERROR (Status); return Value; @@ -517,7 +533,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 @@ -529,8 +545,7 @@ LibPcdSet64 ( { EFI_STATUS Status; - Status = mPcd->Set64 (TokenNumber, Value); - + Status = GetPcdProtocol()->Set64 (TokenNumber, Value); ASSERT_EFI_ERROR (Status); return Value; @@ -576,13 +591,12 @@ LibPcdSetPtr ( ASSERT (Buffer != NULL); } - Status = mPcd->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer); - + Status = GetPcdProtocol()->SetPtr (TokenNumber, SizeOfBuffer, (VOID *) Buffer); if (EFI_ERROR (Status)) { return NULL; } - return (VOID *) Buffer; + return (VOID *)Buffer; } @@ -596,7 +610,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 @@ -608,8 +622,7 @@ LibPcdSetBool ( { EFI_STATUS Status; - Status = mPcd->SetBool (TokenNumber, Value); - + Status = GetPcdProtocol()->SetBool (TokenNumber, Value); ASSERT_EFI_ERROR (Status); return Value; @@ -625,12 +638,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 @@ -645,8 +658,7 @@ LibPcdSetEx8 ( ASSERT (Guid != NULL); - Status = mPcd->Set8Ex (Guid, TokenNumber, Value); - + Status = GetPiPcdProtocol()->Set8 (Guid, TokenNumber, Value); ASSERT_EFI_ERROR (Status); return Value; @@ -662,12 +674,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 @@ -682,8 +694,7 @@ LibPcdSetEx16 ( ASSERT (Guid != NULL); - Status = mPcd->Set16Ex (Guid, TokenNumber, Value); - + Status = GetPiPcdProtocol()->Set16 (Guid, TokenNumber, Value); ASSERT_EFI_ERROR (Status); return Value; @@ -699,12 +710,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 @@ -719,8 +730,7 @@ LibPcdSetEx32 ( ASSERT (Guid != NULL); - Status = mPcd->Set32Ex (Guid, TokenNumber, Value); - + Status = GetPiPcdProtocol()->Set32 (Guid, TokenNumber, Value); ASSERT_EFI_ERROR (Status); return Value; @@ -735,12 +745,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 @@ -755,8 +765,7 @@ LibPcdSetEx64 ( ASSERT (Guid != NULL); - Status = mPcd->Set64Ex (Guid, TokenNumber, Value); - + Status = GetPiPcdProtocol()->Set64 (Guid, TokenNumber, Value); ASSERT_EFI_ERROR (Status); return Value; @@ -777,13 +786,13 @@ 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. @param[in] Buffer A pointer to the buffer to set. - @return Return the pinter to the buffer been set. + @return Return the pointer to the buffer been set. **/ VOID * @@ -805,8 +814,7 @@ LibPcdSetExPtr ( ASSERT (Buffer != NULL); } - Status = mPcd->SetPtrEx (Guid, TokenNumber, SizeOfBuffer, Buffer); - + Status = GetPiPcdProtocol()->SetPtr (Guid, TokenNumber, SizeOfBuffer, Buffer); if (EFI_ERROR (Status)) { return NULL; } @@ -824,12 +832,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 @@ -844,8 +852,7 @@ LibPcdSetExBool ( ASSERT (Guid != NULL); - Status = mPcd->SetBoolEx (Guid, TokenNumber, Value); - + Status = GetPiPcdProtocol()->SetBool (Guid, TokenNumber, Value); ASSERT_EFI_ERROR (Status); return Value; @@ -861,7 +868,7 @@ 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 + @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. @@ -881,8 +888,7 @@ LibPcdCallbackOnSet ( ASSERT (NotificationFunction != NULL); - Status = mPcd->CallbackOnSet (Guid, TokenNumber, NotificationFunction); - + Status = GetPiPcdProtocol()->CallbackOnSet (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction); ASSERT_EFI_ERROR (Status); return; @@ -915,8 +921,7 @@ LibPcdCancelCallback ( ASSERT (NotificationFunction != NULL); - Status = mPcd->CancelCallback (Guid, TokenNumber, NotificationFunction); - + Status = GetPiPcdProtocol()->CancelCallback (Guid, TokenNumber, (EFI_PCD_PROTOCOL_CALLBACK) NotificationFunction); ASSERT_EFI_ERROR (Status); return; @@ -935,7 +940,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. @@ -950,11 +955,7 @@ LibPcdGetNextToken ( IN UINTN TokenNumber ) { - EFI_STATUS Status; - - Status = mPcd->GetNextToken (Guid, &TokenNumber); - - ASSERT_EFI_ERROR (Status); + GetPiPcdProtocol()->GetNextToken (Guid, &TokenNumber); return TokenNumber; } @@ -969,7 +970,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. @@ -980,13 +981,9 @@ LibPcdGetNextTokenSpace ( IN CONST GUID *TokenSpaceGuid ) { - EFI_STATUS Status; - - Status = mPcd->GetNextTokenSpace (&TokenSpaceGuid); - - ASSERT_EFI_ERROR (Status); + GetPiPcdProtocol()->GetNextTokenSpace (&TokenSpaceGuid); - return (GUID *) TokenSpaceGuid; + return (GUID *)TokenSpaceGuid; }