From 425084cd45860df8959ea1f890ca0e855d2a6220 Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Fri, 12 Oct 2018 18:01:40 +0800 Subject: [PATCH] MdeModulePkg PcdDxe: ASSERT PcdSetNvStoreDefaultId set REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1245 In current implementation and according to the description in MdeModulePkg.dec, PcdSetNvStoreDefaultId should be set in PEI phase to take effect. This patch ASSERTs PcdSetNvStoreDefaultId set in PcdDxe to alert the invalid operation. Cc: Liming Gao Cc: Jiewen Yao Cc: Jian J Wang Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng Reviewed-by: Liming Gao Reviewed-by: Jian J Wang --- MdeModulePkg/Universal/PCD/Dxe/Pcd.c | 5 +++++ MdeModulePkg/Universal/PCD/Dxe/Pcd.inf | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c index bc308af1c5..f977c7f18e 100644 --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c @@ -890,6 +890,11 @@ DxePcdSet16Ex ( IN UINT16 Value ) { + // + // PcdSetNvStoreDefaultId should be set in PEI phase to take effect. + // + ASSERT (!(CompareGuid (Guid, &gEfiMdeModulePkgTokenSpaceGuid) && + (ExTokenNumber == PcdToken(PcdSetNvStoreDefaultId)))); return ExSetValueWorker (ExTokenNumber, Guid, &Value, sizeof (Value)); } diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf index 066b86aaa5..1f41a316bd 100644 --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf @@ -331,6 +331,7 @@ [Guids] gPcdDataBaseHobGuid ## SOMETIMES_CONSUMES ## HOB gPcdDataBaseSignatureGuid ## CONSUMES ## GUID # PCD database signature GUID. + gEfiMdeModulePkgTokenSpaceGuid ## SOMETIMES_CONSUMES ## GUID [Protocols] gPcdProtocolGuid ## PRODUCES @@ -342,7 +343,8 @@ gEdkiiVariableLockProtocolGuid [Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress ## SOMETIMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress ## SOMETIMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdSetNvStoreDefaultId ## SOMETIMES_CONSUMES [Depex] TRUE