public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [RFC V2] PCD: Extended SKU support 1 - inheritance
@ 2017-05-15  9:37 Star Zeng
  0 siblings, 0 replies; only message in thread
From: Star Zeng @ 2017-05-15  9:37 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Michael Kinney, Liming Gao, Tim Lewis, Yonghong Zhu

- 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 <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Tim Lewis <tim.lewis@insyde.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>

---
 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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-15  9:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-15  9:37 [RFC V2] PCD: Extended SKU support 1 - inheritance Star Zeng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox