summaryrefslogtreecommitdiff
path: root/BraswellPlatformPkg/Common
diff options
context:
space:
mode:
authorGuo Mang <mang.guo@intel.com>2016-08-03 10:32:47 +0800
committerGuo Mang <mang.guo@intel.com>2016-08-04 10:31:30 +0800
commitdc562585b86bba84eeb5cec697f83b04adf742e6 (patch)
treeb1947a02a77f5806445d2d59dcb896ba6ea96aaf /BraswellPlatformPkg/Common
parent31dacecfd185d25f0577f57cea5b64fff4cfdda2 (diff)
downloadedk2-platforms-dc562585b86bba84eeb5cec697f83b04adf742e6.tar.xz
BraswellPlatformPkg: Move PcdConfigHook to Common/PcdConfigHook
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang <mang.guo@intel.com> Reviewed-by: David Wei <david.wei@intel.com>
Diffstat (limited to 'BraswellPlatformPkg/Common')
-rw-r--r--BraswellPlatformPkg/Common/PcdConfigHook/DxePcdConfigHook.c110
-rw-r--r--BraswellPlatformPkg/Common/PcdConfigHook/DxePcdConfigHook.inf60
2 files changed, 170 insertions, 0 deletions
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.<BR>
+
+ 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 <PiDxe.h>
+#include <Protocol/PiPcd.h>
+#include <Library/PcdLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Guid/SetupVariable.h>
+
+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.<BR>
+#
+# 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
+
+