From dc562585b86bba84eeb5cec697f83b04adf742e6 Mon Sep 17 00:00:00 2001 From: Guo Mang Date: Wed, 3 Aug 2016 10:32:47 +0800 Subject: BraswellPlatformPkg: Move PcdConfigHook to Common/PcdConfigHook Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang Reviewed-by: David Wei --- .../Common/PcdConfigHook/DxePcdConfigHook.c | 110 +++++++++++++++++++++ .../Common/PcdConfigHook/DxePcdConfigHook.inf | 60 +++++++++++ .../PcdConfigHook/DxePcdConfigHook.c | 110 --------------------- .../PcdConfigHook/DxePcdConfigHook.inf | 60 ----------- 4 files changed, 170 insertions(+), 170 deletions(-) create mode 100644 BraswellPlatformPkg/Common/PcdConfigHook/DxePcdConfigHook.c create mode 100644 BraswellPlatformPkg/Common/PcdConfigHook/DxePcdConfigHook.inf delete mode 100644 BraswellPlatformPkg/PcdConfigHook/DxePcdConfigHook.c delete mode 100644 BraswellPlatformPkg/PcdConfigHook/DxePcdConfigHook.inf diff --git a/BraswellPlatformPkg/Common/PcdConfigHook/DxePcdConfigHook.c b/BraswellPlatformPkg/Common/PcdConfigHook/DxePcdConfigHook.c new file mode 100644 index 0000000000..2de67f3a5f --- /dev/null +++ b/BraswellPlatformPkg/Common/PcdConfigHook/DxePcdConfigHook.c @@ -0,0 +1,110 @@ +/** @file + PCD DXE driver manage all PCD entry initialized in PEI phase and DXE phase, and + produce the implementation of native PCD protocol and EFI_PCD_PROTOCOL defined in + PI 1.2 Vol3. + + Copyright (c) 2006 - 2015, 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 + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct { + GUID *PcdGuid; + UINTN Token; + CHAR16 *VarName; + GUID *VarGuid; + UINTN Size; + UINT32 Attributes; +} PCD_HOOK_STRUCT; + +PCD_HOOK_STRUCT mPcdHookToken[] = { + {&gEfiEdkIIPlatformTokenSpaceGuid, 0, L"Setup", &gEfiSetupVariableGuid, sizeof(SYSTEM_CONFIGURATION), EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS}, +}; + +PCD_HOOK_STRUCT * +GetPcdHookStructByToken ( + IN UINTN Token + ) +{ + UINTN Index; + + for (Index = 0; Index < sizeof(mPcdHookToken)/sizeof(mPcdHookToken[0]); Index++) { + if (mPcdHookToken[Index].Token == Token) { + return &mPcdHookToken[Index]; + } + } + return NULL; +} + +EFI_STATUS +EFIAPI +PcdAccessOnSetHook ( + IN EFI_GUID *Guid OPTIONAL, + IN UINTN CallBackToken, + IN VOID *TokenData, + IN UINTN TokenDataSize + ) +{ + PCD_HOOK_STRUCT *PcdHookStruct; + EFI_STATUS Status; + + DEBUG ((EFI_D_INFO, "PcdAccessOnSetHook - 0x%x\n", CallBackToken)); + + PcdHookStruct = GetPcdHookStructByToken (CallBackToken); + ASSERT (PcdHookStruct == NULL); + + Status = gRT->SetVariable ( + PcdHookStruct->VarName, + PcdHookStruct->VarGuid, + PcdHookStruct->Attributes, + TokenDataSize, + TokenData + ); + DEBUG ((EFI_D_INFO, "PcdAccessOnSetHook - %r\n", Status)); + + return Status; +} + +EFI_STATUS +EFIAPI +DxePcdConfigHookEntrypoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_PCD_PROTOCOL *PcdProtocol; + UINTN Index; + + Status = gBS->LocateProtocol ( + &gEfiPcdProtocolGuid, + NULL, + &PcdProtocol + ); + ASSERT_EFI_ERROR (Status); + + mPcdHookToken[0].Token = PcdTokenEx(&gEfiEdkIIPlatformTokenSpaceGuid, PcdSystemConfiguration); + + for (Index = 0; Index < sizeof(mPcdHookToken)/sizeof(mPcdHookToken[0]); Index++) { + Status = PcdProtocol->CallbackOnSet (mPcdHookToken[Index].PcdGuid, mPcdHookToken[Index].Token, PcdAccessOnSetHook); + ASSERT_EFI_ERROR (Status); + } + + return EFI_SUCCESS; +} diff --git a/BraswellPlatformPkg/Common/PcdConfigHook/DxePcdConfigHook.inf b/BraswellPlatformPkg/Common/PcdConfigHook/DxePcdConfigHook.inf new file mode 100644 index 0000000000..2cd976136a --- /dev/null +++ b/BraswellPlatformPkg/Common/PcdConfigHook/DxePcdConfigHook.inf @@ -0,0 +1,60 @@ +## @file +# PCD DXE driver manage database contains all dynamic PCD entries and produce the implementation of PCD protocol. +# +# Copyright (c) 2006 - 2015, 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. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = DxePcdConfigHook + FILE_GUID = 2A717275-758E-44FF-89CB-0CA88BF76732 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 0.1 + ENTRY_POINT = DxePcdConfigHookEntrypoint + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources] + DxePcdConfigHook.c + +[Packages] + MdePkg/MdePkg.dec + BraswellPlatformPkg/BraswellPlatformPkg.dec + +[LibraryClasses] + BaseMemoryLib + UefiBootServicesTableLib + UefiRuntimeServicesTableLib + UefiDriverEntryPoint + UefiLib + DebugLib + BaseLib + PcdLib + +[PcdEx] + gEfiEdkIIPlatformTokenSpaceGuid.PcdSystemConfiguration + +[Protocols] + gEfiPcdProtocolGuid + +[Guids] + gEfiSetupVariableGuid ## CONSUMES + +[Depex] + gEfiPcdProtocolGuid AND + gEfiVariableWriteArchProtocolGuid + + diff --git a/BraswellPlatformPkg/PcdConfigHook/DxePcdConfigHook.c b/BraswellPlatformPkg/PcdConfigHook/DxePcdConfigHook.c deleted file mode 100644 index 2de67f3a5f..0000000000 --- a/BraswellPlatformPkg/PcdConfigHook/DxePcdConfigHook.c +++ /dev/null @@ -1,110 +0,0 @@ -/** @file - PCD DXE driver manage all PCD entry initialized in PEI phase and DXE phase, and - produce the implementation of native PCD protocol and EFI_PCD_PROTOCOL defined in - PI 1.2 Vol3. - - Copyright (c) 2006 - 2015, 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 - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include -#include -#include - -typedef struct { - GUID *PcdGuid; - UINTN Token; - CHAR16 *VarName; - GUID *VarGuid; - UINTN Size; - UINT32 Attributes; -} PCD_HOOK_STRUCT; - -PCD_HOOK_STRUCT mPcdHookToken[] = { - {&gEfiEdkIIPlatformTokenSpaceGuid, 0, L"Setup", &gEfiSetupVariableGuid, sizeof(SYSTEM_CONFIGURATION), EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS}, -}; - -PCD_HOOK_STRUCT * -GetPcdHookStructByToken ( - IN UINTN Token - ) -{ - UINTN Index; - - for (Index = 0; Index < sizeof(mPcdHookToken)/sizeof(mPcdHookToken[0]); Index++) { - if (mPcdHookToken[Index].Token == Token) { - return &mPcdHookToken[Index]; - } - } - return NULL; -} - -EFI_STATUS -EFIAPI -PcdAccessOnSetHook ( - IN EFI_GUID *Guid OPTIONAL, - IN UINTN CallBackToken, - IN VOID *TokenData, - IN UINTN TokenDataSize - ) -{ - PCD_HOOK_STRUCT *PcdHookStruct; - EFI_STATUS Status; - - DEBUG ((EFI_D_INFO, "PcdAccessOnSetHook - 0x%x\n", CallBackToken)); - - PcdHookStruct = GetPcdHookStructByToken (CallBackToken); - ASSERT (PcdHookStruct == NULL); - - Status = gRT->SetVariable ( - PcdHookStruct->VarName, - PcdHookStruct->VarGuid, - PcdHookStruct->Attributes, - TokenDataSize, - TokenData - ); - DEBUG ((EFI_D_INFO, "PcdAccessOnSetHook - %r\n", Status)); - - return Status; -} - -EFI_STATUS -EFIAPI -DxePcdConfigHookEntrypoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - EFI_PCD_PROTOCOL *PcdProtocol; - UINTN Index; - - Status = gBS->LocateProtocol ( - &gEfiPcdProtocolGuid, - NULL, - &PcdProtocol - ); - ASSERT_EFI_ERROR (Status); - - mPcdHookToken[0].Token = PcdTokenEx(&gEfiEdkIIPlatformTokenSpaceGuid, PcdSystemConfiguration); - - for (Index = 0; Index < sizeof(mPcdHookToken)/sizeof(mPcdHookToken[0]); Index++) { - Status = PcdProtocol->CallbackOnSet (mPcdHookToken[Index].PcdGuid, mPcdHookToken[Index].Token, PcdAccessOnSetHook); - ASSERT_EFI_ERROR (Status); - } - - return EFI_SUCCESS; -} diff --git a/BraswellPlatformPkg/PcdConfigHook/DxePcdConfigHook.inf b/BraswellPlatformPkg/PcdConfigHook/DxePcdConfigHook.inf deleted file mode 100644 index 2cd976136a..0000000000 --- a/BraswellPlatformPkg/PcdConfigHook/DxePcdConfigHook.inf +++ /dev/null @@ -1,60 +0,0 @@ -## @file -# PCD DXE driver manage database contains all dynamic PCD entries and produce the implementation of PCD protocol. -# -# Copyright (c) 2006 - 2015, 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. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = DxePcdConfigHook - FILE_GUID = 2A717275-758E-44FF-89CB-0CA88BF76732 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 0.1 - ENTRY_POINT = DxePcdConfigHookEntrypoint - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - DxePcdConfigHook.c - -[Packages] - MdePkg/MdePkg.dec - BraswellPlatformPkg/BraswellPlatformPkg.dec - -[LibraryClasses] - BaseMemoryLib - UefiBootServicesTableLib - UefiRuntimeServicesTableLib - UefiDriverEntryPoint - UefiLib - DebugLib - BaseLib - PcdLib - -[PcdEx] - gEfiEdkIIPlatformTokenSpaceGuid.PcdSystemConfiguration - -[Protocols] - gEfiPcdProtocolGuid - -[Guids] - gEfiSetupVariableGuid ## CONSUMES - -[Depex] - gEfiPcdProtocolGuid AND - gEfiVariableWriteArchProtocolGuid - - -- cgit v1.2.3