public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Sami Mujawar <sami.mujawar@arm.com>
To: edk2-devel@lists.01.org
Cc: alexei.fedorov@arm.com, leif.lindholm@linaro.org,
	Matteo.Carlini@arm.com,  Stephanie.Hughes-Fitt@arm.com,
	nd@arm.com
Subject: [PATCH v1 10/22] DynamicTablesPkg: Configuration Manager Helper
Date: Fri, 21 Dec 2018 16:57:07 +0000	[thread overview]
Message-ID: <20181221165719.49480-11-sami.mujawar@arm.com> (raw)
In-Reply-To: <20181221165719.49480-1-sami.mujawar@arm.com>

This patch defines a helper macro 'GET_OBJECT_LIST()' that
expands to a function that uses the configuration manager
protocol to retrieve configuration manager object(s).

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
 DynamicTablesPkg/Include/ConfigurationManagerHelper.h | 119 ++++++++++++++++++++
 1 file changed, 119 insertions(+)

diff --git a/DynamicTablesPkg/Include/ConfigurationManagerHelper.h b/DynamicTablesPkg/Include/ConfigurationManagerHelper.h
new file mode 100644
index 0000000000000000000000000000000000000000..0630afc5ad755a613c273bfd02cf53fefcedccc5
--- /dev/null
+++ b/DynamicTablesPkg/Include/ConfigurationManagerHelper.h
@@ -0,0 +1,119 @@
+/** @file
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+    - Cm or CM   - Configuration Manager
+    - Obj or OBJ - Object
+**/
+
+#ifndef CONFIGURATION_MANAGER_HELPER_H_
+#define CONFIGURATION_MANAGER_HELPER_H_
+
+/** The GET_OBJECT_LIST macro expands to a function that is used to retrieve
+    an object or an object list from the Configuration Manager using the
+    Configuration Manager Protocol interface.
+
+  The macro expands to a function which has the following prototype:
+
+  STATIC
+  EFI_STATUS
+  EFIAPI
+  Get<CmObjectId> (
+    IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
+    IN  CONST CM_OBJECT_TOKEN                              Token OPTIONAL,
+    OUT       Type                                **       List,
+    OUT       UINT32                               *       Count OPTIONAL
+    );
+
+  Generated function parameters:
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager protocol
+                              interface.
+  @param [in]  Token          Reference token for the Object.
+  @param [out] List           Pointer to the Object list.
+  @param [out] Count          Count of the objects returned in the list.
+
+  Macro Parameters:
+  @param [in] CmObjectNameSpace The Object Namespace
+  @param [in] CmObjectId        Object Id.
+  @param [in] Type              Structure used to describe the Object.
+
+  @retval EFI_SUCCESS           Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND         The required object information is not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+                                Manager is less than the Object size for the
+                                requested object.
+**/
+#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type)                  \
+STATIC                                                                        \
+EFI_STATUS                                                                    \
+EFIAPI                                                                        \
+Get##CmObjectId (                                                             \
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST CfgMgrProtocol,     \
+  IN  CONST CM_OBJECT_TOKEN                               Token OPTIONAL,     \
+  OUT       Type                                 **       List,               \
+  OUT       UINT32                                * CONST Count OPTIONAL      \
+  )                                                                           \
+{                                                                             \
+  EFI_STATUS         Status;                                                  \
+  CM_OBJ_DESCRIPTOR  CmObjectDesc;                                            \
+  UINT32             ObjCount = 0;                                            \
+  if (List == NULL) {                                                         \
+    Status = EFI_INVALID_PARAMETER;                                           \
+    DEBUG ((                                                                  \
+      DEBUG_ERROR,                                                            \
+      "ERROR: Get" #CmObjectId ": Invalid out parameter for"                  \
+      " object list. Status = %r\n",                                          \
+      Status                                                                  \
+      ));                                                                     \
+    goto error_handler;                                                       \
+  }                                                                           \
+  Status = CfgMgrProtocol->GetObject (                                        \
+                             CfgMgrProtocol,                                  \
+                             CREATE_CM_OBJECT_ID (                            \
+                               CmObjectNameSpace,                             \
+                               CmObjectId                                     \
+                               ),                                             \
+                             Token,                                           \
+                             &CmObjectDesc                                    \
+                             );                                               \
+  if (EFI_ERROR (Status)) {                                                   \
+    DEBUG ((                                                                  \
+      DEBUG_INFO,                                                             \
+      "INFO: Get" #CmObjectId ": Platform does not implement "                \
+      #CmObjectId ". Status = %r\n",                                          \
+      Status                                                                  \
+      ));                                                                     \
+    *List = NULL;                                                             \
+    goto error_handler;                                                       \
+  }                                                                           \
+  if (CmObjectDesc.Size < sizeof (Type)) {                                    \
+    DEBUG ((                                                                  \
+      DEBUG_ERROR,                                                            \
+      "ERROR: Get" #CmObjectId ": " #CmObjectId                               \
+      ": Buffer too small, size = 0x%x\n",                                    \
+      CmObjectDesc.Size                                                       \
+      ));                                                                     \
+    ASSERT (CmObjectDesc.Size >= sizeof (Type));                              \
+    Status = EFI_BAD_BUFFER_SIZE;                                             \
+    goto error_handler;                                                       \
+  }                                                                           \
+  ObjCount = CmObjectDesc.Size / sizeof (Type);                               \
+  *List = (Type*)CmObjectDesc.Data;                                           \
+error_handler:                                                                \
+  if (Count != NULL) {                                                        \
+    *Count = ObjCount;                                                        \
+  }                                                                           \
+  return Status;                                                              \
+}
+
+#endif // CONFIGURATION_MANAGER_HELPER_H_
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'




  parent reply	other threads:[~2018-12-21 17:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-21 16:56 [PATCH v1 00/22] DynamicTablesPkg: Introduce Dynamic Tables Framework Sami Mujawar
2018-12-21 16:56 ` [PATCH v1 01/22] DynamicTablesPkg: " Sami Mujawar
2018-12-21 16:56 ` [PATCH v1 02/22] DynamicTablesPkg: Table Generator definition Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 03/22] DynamicTablesPkg: Acpi Table Generator Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 04/22] DynamicTablesPkg: SMBIOS " Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 05/22] DynamicTablesPkg: DT " Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 06/22] DynamicTablesPkg: Standard NameSpace Objects Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 07/22] DynamicTablesPkg: Arm " Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 08/22] DynamicTablesPkg: Configuration Manager Objects Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 09/22] DynamicTablesPkg: Configuration Manager Protocol Sami Mujawar
2018-12-21 16:57 ` Sami Mujawar [this message]
2018-12-21 16:57 ` [PATCH v1 11/22] DynamicTablesPkg: Table Helper Library Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 12/22] DynamicTablesPkg: Dynamic Table Factory Protocol Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 13/22] DynamicTablesPkg: Dynamic Table Factory Dxe Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 14/22] DynamicTablesPkg: Dynamic Table Manager Dxe Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 15/22] DynamicTablesPkg: Arm Raw/DSDT/SSDT Generator Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 16/22] DynamicTablesPkg: Arm ACPI FADT Generator Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 17/22] DynamicTablesPkg: Arm ACPI MADT Generator Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 18/22] DynamicTablesPkg: Arm ACPI GTDT Generator Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 19/22] DynamicTablesPkg: Arm SPCR Table Generator Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 20/22] DynamicTablesPkg: Arm DBG2 " Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 21/22] DynamicTablesPkg: Arm PCI MCFG " Sami Mujawar
2018-12-21 16:57 ` [PATCH v1 22/22] DynamicTablesPkg: Arm IORT " Sami Mujawar

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=20181221165719.49480-11-sami.mujawar@arm.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