From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EE0D621A0BABA for ; Mon, 15 May 2017 02:37:39 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 May 2017 02:37:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,344,1491289200"; d="scan'208";a="1169301963" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.9.20]) by fmsmga002.fm.intel.com with ESMTP; 15 May 2017 02:37:37 -0700 From: Star Zeng To: edk2-devel@lists.01.org Cc: Star Zeng , Michael Kinney , Liming Gao , Tim Lewis , Yonghong Zhu Date: Mon, 15 May 2017 17:37:35 +0800 Message-Id: <1494841055-26920-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 MIME-Version: 1.0 Subject: [RFC V2] PCD: Extended SKU support 1 - inheritance X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 May 2017 09:37:40 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Requirement Simplify the PCDs configuring for multiple SKUs in DSC. Provide interface to get the relationship between multiple SKUs for runtime usage. - Current limitation Non-DEFAULT SKU could only derive from DEFAULT SKU, but could not derive from another non-DEFAULT SKU. For example below, SkuA and SkuB could only derive from DEFAULT, but SkuB could not derive from SkuA. [SkuIds] 0 | DEFAULT 1 | SkuA 2 | SkuB - Proposal: One non-DEFAULT SKU could be a derivative of another non-DEFAULT SKU. This proposal extends DSC [SkuIds] section syntax and the extension is optional. This proposal keeps the backward compatibility with current SKU usage. This proposal provides interface to get the relationship between multiple SKUs for runtime usage. BaseTools update is needed to support the extension, and no any change in PCD database and driver is required. DSC syntax: [SkuIds] SkuValue|SkuName[|ParentSkuName] SkuValue: integer, 0 is reserved for DEFAULT SKU. SkuName: string ParentSkuName: string, optional, it is new introduced in this proposal and defines which SKU the PCD value will derive from for this SKU. The PCD value will derive from DEFAULT SKU for this SKU if the ParentSkuName is absent. AutoGen.h: extern UINT64 *_gPcd_SkuId_Array; AutoGen.c: // SkuId array with relationship information for SkuIds listed in SKUID_IDENTIFIER GLOBAL_REMOVE_IF_UNREFERENCED UINT64 *_gPcd_SkuId_Array = { SkuId, ParentSkuId, ParentParentSkuId, …, 0x0, SkuId, ParentSkuId, ParentSkuId, …, 0x0, …, 0x0 }; For the example below, _gPcd_SkuId_Array = { 0x2, 0x1, 0x0, 0x1, 0x0, 0x0 }. PcdLib.h: LibPcdGetParentSkuId function and PcdGetParentSkuId macro, the patch below shows their implementation. - Example: SkuB is a derivative of SkuA, but not a derivative of DEFAULT. [SkuIds] 0 | DEFAULT 1 | SkuA 2 | SkuB | SkuA [PcdsDynamicDefault.Common.DEFAULT] gXXXPkgTokenSpaceGuid.PcdXXXSignature|"DEFAULT” gXXXPkgTokenSpaceGuid.PcdXXXConfig1|FALSE gXXXPkgTokenSpaceGuid.PcdXXXConfig2|FALSE gXXXPkgTokenSpaceGuid.PcdXXXConfig3|FALSE [PcdsDynamicDefault.Common.SkuA] gXXXPkgTokenSpaceGuid.PcdXXXSignature|“SkuA” gXXXPkgTokenSpaceGuid.PcdXXXConfig1|TRUE gXXXPkgTokenSpaceGuid.PcdXXXConfig2|TRUE # No need statement for PcdXXXConfig3 whose value will derive from DEFAULT SKU and be FLASE. [PcdsDynamicDefault.Common.SkuB] gXXXPkgTokenSpaceGuid.PcdXXXSignature|“SkuB” # No need statement for PcdXXXConfig1 and PcdXXXConfig2 whose values will derive from SkuA SKU and be TRUE. gXXXPkgTokenSpaceGuid.PcdXXXConfig3|TRUE Cc: Michael Kinney Cc: Liming Gao Cc: Tim Lewis Cc: Yonghong Zhu --- MdePkg/Include/Library/PcdLib.h | 38 +++++++++++++++++++++++++++++- MdePkg/Library/BasePcdLibNull/PcdLib.c | 43 ++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Library/PcdLib.h b/MdePkg/Include/Library/PcdLib.h index 9e7e09f52cdc..409689156c39 100644 --- a/MdePkg/Include/Library/PcdLib.h +++ b/MdePkg/Include/Library/PcdLib.h @@ -346,6 +346,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. (Size), \ (Buffer) \ ) + +/** + Get the parent SkuId for the input SkuId. + + If SkuId is 0, return 0. + If SkuId is invalid, return SkuId without change. + + @param[in] SkuId SKU ID. + + @return Return the parent SkuId. + +**/ +#define PcdGetParentSkuId(SkuId) \ + LibPcdGetParentSkuId ( \ + _gPcd_SkuId_Array, \ + (SkuId) \ + ) + /** Retrieves an 8-bit PCD token value based on a token name. @@ -2039,7 +2057,6 @@ LibPcdGetNextTokenSpace ( IN CONST GUID *TokenSpaceGuid ); - /** Sets a value of a patchable PCD entry that is type pointer. @@ -2174,6 +2191,25 @@ LibPatchPcdSetPtrAndSizeS ( IN CONST VOID *Buffer ); +/** + Get the parent SkuId for the input SkuId. + + If SkuId is 0, return 0. + If SkuId is invalid, return SkuId without change. + + @param[in] SkuIdArray Pointer to SkuId array with relationship information. + @param[in] SkuId SKU ID. + + @return Return the parent SkuId. + +**/ +UINT64 +EFIAPI +LibPcdGetParentSkuId ( + IN UINT64 *SkuIdArray, + IN UINT64 SkuId + ); + typedef enum { PCD_TYPE_8, PCD_TYPE_16, diff --git a/MdePkg/Library/BasePcdLibNull/PcdLib.c b/MdePkg/Library/BasePcdLibNull/PcdLib.c index 4fc3672b7a36..434508cfc26c 100644 --- a/MdePkg/Library/BasePcdLibNull/PcdLib.c +++ b/MdePkg/Library/BasePcdLibNull/PcdLib.c @@ -1415,6 +1415,49 @@ LibPatchPcdSetPtrAndSizeS ( } /** + Get the parent SkuId for the input SkuId. + + If SkuId is 0, return 0. + If SkuId is invalid, return SkuId without change. + + @param[in] SkuIdArray Pointer to SkuId array with relationship information. + @param[in] SkuId SKU ID. + + @return Return the parent SkuId. + +**/ +UINT64 +EFIAPI +LibPcdGetParentSkuId ( + IN UINT64 *SkuIdArray, + IN UINT64 SkuId + ) +{ + UINT64 *TempSkuId; + + if (SkuId == 0) { + return 0; + } + + TempSkuId = SkuIdArray; + while (*TempSkuId != 0) { + if (*TempSkuId == SkuId) { + TempSkuId++; + return (*TempSkuId); + } + while (*TempSkuId != 0) { + TempSkuId++; + } + TempSkuId++; + } + + // + // Not found the input SkuId, return it without change. + // + return SkuId; +} + +/** 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 -- 2.7.0.windows.1