public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Tomas Pilar (tpilar)" <tomas@nuviainc.com>
To: devel@edk2.groups.io
Cc: Sami Mujawar <Sami.Mujawar@arm.com>,
	Alexei Fedorov <Alexei.Fedorov@arm.com>
Subject: [PATCH 2/8] DynamicTablesPkg: Fold Namespaces into CmObjectId Enums
Date: Fri, 31 Jul 2020 17:19:20 +0100	[thread overview]
Message-ID: <20200731161926.341330-3-tomas@nuviainc.com> (raw)
In-Reply-To: <20200731161926.341330-1-tomas@nuviainc.com>

The enums for CmObjectIds defined in Dynamic Tables Framework
that are used to identify types of configuration manager objects
already include their namespaces in the symbols for enum values.

Namespace enum values are shifted up by NAMESPACE_BIT_SHIFT and
the enums tables for CmObjectIds are bitwise-ORed with their
corresponding namespace.

This means we no longer need to use macros to compose and decompose
CmObjectIds. The macros are adjusted so that they result in NOP.

Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>
Signed-off-by: Tomas Pilar <tomas@nuviainc.com>
---
 .../Include/ArmNameSpaceObjects.h             |  3 +-
 .../Include/ConfigurationManagerNameSpace.h   | 43 ++++++++++++++
 .../Include/ConfigurationManagerObject.h      | 57 ++++++++-----------
 .../Include/StandardNameSpaceObjects.h        |  7 ++-
 4 files changed, 72 insertions(+), 38 deletions(-)
 create mode 100644 DynamicTablesPkg/Include/ConfigurationManagerNameSpace.h

diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
index 2f32696031..cf7846e024 100644
--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
@@ -14,6 +14,7 @@
 #define ARM_NAMESPACE_OBJECTS_H_
 
 #include <StandardNameSpaceObjects.h>
+#include <ConfigurationManagerNameSpace.h>
 
 #pragma pack(1)
 
@@ -21,7 +22,7 @@
     in the ARM Namespace
 */
 typedef enum ArmObjectID {
-  EArmObjReserved,                     ///<  0 - Reserved
+  EArmObjReserved = EObjNameSpaceArm,  ///<  0 - Reserved, namespace starts at 0x10000000
   EArmObjBootArchInfo,                 ///<  1 - Boot Architecture Info
   EArmObjCpuInfo,                      ///<  2 - CPU Info
   EArmObjPowerManagementProfileInfo,   ///<  3 - Power Management Profile Info
diff --git a/DynamicTablesPkg/Include/ConfigurationManagerNameSpace.h b/DynamicTablesPkg/Include/ConfigurationManagerNameSpace.h
new file mode 100644
index 0000000000..acba77e2b3
--- /dev/null
+++ b/DynamicTablesPkg/Include/ConfigurationManagerNameSpace.h
@@ -0,0 +1,43 @@
+/** @file
+
+  Copyright (c) 2020, ARM Limited. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef CONFIGURATION_MANAGER_NAMESPACE_H_
+#define CONFIGURATION_MANAGER_NAMESPACE_H_
+
+/** The EOBJECT_NAMESPACE_ID enum describes the defined namespaces
+    for the Configuration Manager Objects.
+
+ Description of Configuration Manager Object ID
+_______________________________________________________________________________
+|31 |30 |29 |28 || 27 | 26 | 25 | 24 || 23 | 22 | 21 | 20 || 19 | 18 | 17 | 16|
+-------------------------------------------------------------------------------
+| Name Space ID ||  0 |  0 |  0 |  0 ||  0 |  0 |  0 |  0 ||  0 |  0 |  0 |  0|
+_______________________________________________________________________________
+
+Bits: [31:28] - Name Space ID
+                0000 - Standard
+                0001 - ARM
+                1000 - Custom/OEM
+                All other values are reserved.
+
+Bits: [27:16] - Reserved.
+_______________________________________________________________________________
+|15 |14 |13 |12 || 11 | 10 |  9 |  8 ||  7 |  6 |  5 |  4 ||  3 |  2 |  1 |  0|
+-------------------------------------------------------------------------------
+| 0 | 0 | 0 | 0 ||  0 |  0 |  0 |  0 ||                 Object ID             |
+_______________________________________________________________________________
+
+Bits: [15:8] - Are reserved and must be zero.
+Bits: [7:0] - Object ID
+*/
+typedef enum ObjectNameSpaceID {
+  EObjNameSpaceStandard = 0x00000000,      ///< Standard Objects Namespace
+  EObjNameSpaceArm      = 0x10000000,      ///< ARM Objects Namespace
+  EObjNameSpaceOem      = 0x80000000,      ///< OEM Objects Namespace
+} EOBJECT_NAMESPACE_ID;
+
+#endif
diff --git a/DynamicTablesPkg/Include/ConfigurationManagerObject.h b/DynamicTablesPkg/Include/ConfigurationManagerObject.h
index b0d3e709ec..9d39bd8a9e 100644
--- a/DynamicTablesPkg/Include/ConfigurationManagerObject.h
+++ b/DynamicTablesPkg/Include/ConfigurationManagerObject.h
@@ -86,25 +86,11 @@ typedef UINT32  CM_OBJECT_ID;
 
 /** A mask for Object ID
 */
-#define OBJECT_ID_MASK            0xFF
+#define OBJECT_ID_MASK            0x000000FF
 
 /** A mask for Namespace ID
 */
-#define NAMESPACE_ID_MASK         0xF
-
-/** Starting bit position for Namespace ID
-*/
-#define NAMESPACE_ID_BIT_SHIFT    28
-
-/** The EOBJECT_NAMESPACE_ID enum describes the defined namespaces
-    for the Configuration Manager Objects.
-*/
-typedef enum ObjectNameSpaceID {
-  EObjNameSpaceStandard,      ///< Standard Objects Namespace
-  EObjNameSpaceArm,           ///< ARM Objects Namespace
-  EObjNameSpaceOem = 0x8,     ///< OEM Objects Namespace
-  EObjNameSpaceMax
-} EOBJECT_NAMESPACE_ID;
+#define NAMESPACE_ID_MASK         0xF0000000
 
 /** A descriptor for Configuration Manager Objects.
 
@@ -133,19 +119,21 @@ typedef struct CmObjDescriptor {
 
   @retval Returns the Namespace ID corresponding to the CmObjectID.
 **/
-#define GET_CM_NAMESPACE_ID(CmObjectId)               \
-          (((CmObjectId) >> NAMESPACE_ID_BIT_SHIFT) & \
-            NAMESPACE_ID_MASK)
+#define GET_CM_NAMESPACE_ID(CmObjectId) ((CmObjectId) & NAMESPACE_ID_MASK)
+
+/** Deprecated, use just CmObjectId.
 
-/** This macro returns the Object ID from the CmObjectID.
+  This macro returns the Object ID from the CmObjectID.
 
   @param [in] CmObjectId  The Configuration Manager Object ID.
 
   @retval Returns the Object ID corresponding to the CmObjectID.
 **/
-#define GET_CM_OBJECT_ID(CmObjectId)    ((CmObjectId) & OBJECT_ID_MASK)
+#define GET_CM_OBJECT_ID(CmObjectId)    (CmObjectId)
 
-/** This macro returns a Configuration Manager Object ID
+/** Deprecated. Use just ObjectId.
+
+    This macro returns a Configuration Manager Object ID
     from the NameSpace ID and the ObjectID.
 
   @param [in] NameSpaceId The namespace ID for the Object.
@@ -153,38 +141,39 @@ typedef struct CmObjDescriptor {
 
   @retval Returns the Configuration Manager Object ID.
 **/
-#define CREATE_CM_OBJECT_ID(NameSpaceId, ObjectId)                           \
-          ((((NameSpaceId) & NAMESPACE_ID_MASK) << NAMESPACE_ID_BIT_SHIFT) | \
-            ((ObjectId) & OBJECT_ID_MASK))
+#define CREATE_CM_OBJECT_ID(NameSpaceId, ObjectId) (ObjectId)
+
+/** Deprecated, use just ObjectId.
 
-/** This macro returns a Configuration Manager Object ID
+    This macro returns a Configuration Manager Object ID
     in the Standard Object Namespace.
 
   @param [in] ObjectId    The Object ID.
 
   @retval Returns a Standard Configuration Manager Object ID.
 **/
-#define CREATE_CM_STD_OBJECT_ID(ObjectId) \
-          (CREATE_CM_OBJECT_ID (EObjNameSpaceStandard, ObjectId))
+#define CREATE_CM_STD_OBJECT_ID(ObjectId) (ObjectId)
 
-/** This macro returns a Configuration Manager Object ID
+/** Deprecated, use just ObjectId.
+
+    This macro returns a Configuration Manager Object ID
     in the ARM Object Namespace.
 
   @param [in] ObjectId    The Object ID.
 
   @retval Returns an ARM Configuration Manager Object ID.
 **/
-#define CREATE_CM_ARM_OBJECT_ID(ObjectId) \
-          (CREATE_CM_OBJECT_ID (EObjNameSpaceArm, ObjectId))
+#define CREATE_CM_ARM_OBJECT_ID(ObjectId) (ObjectId)
+
+/** Deprecated, use just ObjectId.
 
-/** This macro returns a Configuration Manager Object ID
+    This macro returns a Configuration Manager Object ID
     in the OEM Object Namespace.
 
   @param [in] ObjectId    The Object ID.
 
   @retval Returns an OEM Configuration Manager Object ID.
 **/
-#define CREATE_CM_OEM_OBJECT_ID(ObjectId) \
-          (CREATE_CM_OBJECT_ID (EObjNameSpaceOem, ObjectId))
+#define CREATE_CM_OEM_OBJECT_ID(ObjectId) (ObjectId)
 
 #endif // CONFIGURATION_MANAGER_OBJECT_H_
diff --git a/DynamicTablesPkg/Include/StandardNameSpaceObjects.h b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
index 0ba6b16369..053ef937a4 100644
--- a/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
@@ -15,6 +15,7 @@
 
 #include <AcpiTableGenerator.h>
 #include <SmbiosTableGenerator.h>
+#include <ConfigurationManagerNameSpace.h>
 
 #pragma pack(1)
 
@@ -44,9 +45,9 @@ typedef UINTN   CM_OBJECT_TOKEN;
     in the Standard Namespace.
 */
 typedef enum StdObjectID {
-  EStdObjCfgMgrInfo = 0x00000000, ///< 0 - Configuration Manager Info
-  EStdObjAcpiTableList,           ///< 1 - ACPI table Info List
-  EStdObjSmbiosTableList,         ///< 2 - SMBIOS table Info List
+  EStdObjCfgMgrInfo = EObjNameSpaceStandard, ///< 0 - Configuration Manager Info, namespace starts at 0
+  EStdObjAcpiTableList,                      ///< 1 - ACPI table Info List
+  EStdObjSmbiosTableList,                    ///< 2 - SMBIOS table Info List
   EStdObjMax
 } ESTD_OBJECT_ID;
 
-- 
2.25.1


  parent reply	other threads:[~2020-07-31 16:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 16:19 [PATCH 0/8] ConfigurationManagerProtocol update Tomas Pilar (tpilar)
2020-07-31 16:19 ` [PATCH 1/8] DynamicTablesPkg: Include BaseStackCheckLib Tomas Pilar (tpilar)
2020-07-31 16:19 ` Tomas Pilar (tpilar) [this message]
2020-07-31 16:19 ` [PATCH 3/8] DynamicTablesPkg: Add ConfigurationManagerDumpApp Tomas Pilar (tpilar)
2020-07-31 16:19 ` [PATCH 4/8] DynamicTablesPkg: Update ConfigurationManagerProtocol Tomas Pilar (tpilar)
2020-07-31 16:19 ` [PATCH 5/8] DynamicTablesPkg: Add CfgMgrProtocol helper functions Tomas Pilar (tpilar)
2020-07-31 16:19 ` [PATCH 6/8] DynamicTablesPkg/TableHelperLib: User friendly strings Tomas Pilar (tpilar)
2020-07-31 16:19 ` [PATCH 7/8] DynamicTablesPkg: Simplify AddAcpiHeader, CfgMgrGetInfo Tomas Pilar (tpilar)
2020-07-31 16:19 ` [PATCH 8/8] DynamicTablesPkg: Remove GET_OBJECT_LIST Tomas Pilar (tpilar)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200731161926.341330-3-tomas@nuviainc.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox