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.muja...@arm.com>
Cc: Alexei Fedorov <alexei.fedo...@arm.com>
Signed-off-by: Tomas Pilar <to...@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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63581): https://edk2.groups.io/g/devel/message/63581
Mute This Topic: https://groups.io/mt/75910565/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to