public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io, Sami Mujawar <sami.mujawar@arm.com>,
	Alexei.Fedorov@arm.com, Joey Gouly <joey.gouly@arm.com>
Subject: [PATCH v2 01/10] DynamicTablesPkg: Extract AcpiHelperLib from TableHelperLib
Date: Thu, 30 Sep 2021 08:48:12 +0100	[thread overview]
Message-ID: <20210930074821.12546-2-Pierre.Gondois@arm.com> (raw)
In-Reply-To: <20210930074821.12546-1-Pierre.Gondois@arm.com>

From: Pierre Gondois <Pierre.Gondois@arm.com>

The TableHelperLib contains helper functions. Some rely on
DynamicTablesPkg definitions (they use Configuration Manager objects).
Some others are more generic.

To allow using these generic functions without including
DynamicTablesPkg definitions, move them to a new AcpiHelperLib
library.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---

Notes:
    v2:
    - Change AcpiTableHelperLib to AcpiHelperLib in commit message.
      [Sami]

 DynamicTablesPkg/DynamicTables.dsc.inc        |   3 +-
 DynamicTablesPkg/DynamicTablesPkg.dec         |   4 +
 DynamicTablesPkg/DynamicTablesPkg.dsc         |   1 +
 .../Include/Library/AcpiHelperLib.h           |  60 ++++++++++
 .../Include/Library/TableHelperLib.h          |  49 --------
 .../SsdtCmn600Generator.c                     |   2 +-
 .../AcpiSsdtCmn600LibArm/SsdtCmn600LibArm.inf |   3 +-
 .../SsdtSerialPortGenerator.c                 |   3 +-
 .../SsdtSerialPortLibArm.inf                  |   4 +-
 .../Library/Common/AcpiHelperLib/AcpiHelper.c | 109 ++++++++++++++++++
 .../Common/AcpiHelperLib/AcpiHelperLib.inf    |  25 ++++
 .../Library/Common/AmlLib/AmlLib.inf          |   3 +-
 .../SsdtSerialPortFixupLib.c                  |   2 +-
 .../SsdtSerialPortFixupLib.inf                |   1 +
 .../Common/TableHelperLib/TableHelper.c       |  96 ---------------
 15 files changed, 212 insertions(+), 153 deletions(-)
 create mode 100644 DynamicTablesPkg/Include/Library/AcpiHelperLib.h
 create mode 100644 DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c
 create mode 100644 DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.inf

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc b/DynamicTablesPkg/DynamicTables.dsc.inc
index fa33b7ee67e6..ed221d1681eb 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -1,7 +1,7 @@
 ## @file
 #  Dsc include file for Dynamic Tables Framework.
 #
-#  Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.<BR>
+#  Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -13,6 +13,7 @@ [BuildOptions]
   RELEASE_*_*_CC_FLAGS     = -DMDEPKG_NDEBUG
 
 [LibraryClasses.common]
+  AcpiHelperLib|DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.inf
   AmlLib|DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf
   SsdtSerialPortFixupLib|DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
   TableHelperLib|DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec b/DynamicTablesPkg/DynamicTablesPkg.dec
index b242df010587..9996bdf6f520 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dec
+++ b/DynamicTablesPkg/DynamicTablesPkg.dec
@@ -17,6 +17,10 @@ [Includes]
   Include
 
 [LibraryClasses]
+  ##  @libraryclass  Defines a set of Acpi helper methods
+  #   independent from the Dynamic Tables Framework.
+  AcpiHelperLib|Include/Library/AcpiHelperLib.h
+
   ##  @libraryclass  Defines a set of APIs for Dynamic AML generation.
   AmlLib|Include/Library/AmlLib/AmlLib.h
 
diff --git a/DynamicTablesPkg/DynamicTablesPkg.dsc b/DynamicTablesPkg/DynamicTablesPkg.dsc
index 33b2a84c9dd9..46b2e667fd25 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dsc
+++ b/DynamicTablesPkg/DynamicTablesPkg.dsc
@@ -38,6 +38,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
   PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf
 
 [Components.common]
+  DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.inf
   DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf
   DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
   DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
diff --git a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h b/DynamicTablesPkg/Include/Library/AcpiHelperLib.h
new file mode 100644
index 000000000000..2731a2e4fb27
--- /dev/null
+++ b/DynamicTablesPkg/Include/Library/AcpiHelperLib.h
@@ -0,0 +1,60 @@
+/** @file
+
+  Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef ACPI_HELPER_LIB_H_
+#define ACPI_HELPER_LIB_H_
+
+/** Is a character upper case
+*/
+#define IS_UPPER_CHAR(x) ((x >= 'A') && (x <= 'Z'))
+
+/** Is a character a decimal digit
+*/
+#define IS_DIGIT(x) ((x >= '0') && (x <= '9'))
+
+/** Is a character an upper case hexadecimal digit
+*/
+#define IS_UPPER_HEX(x) (((x >= 'A') && (x <= 'F')) || IS_DIGIT (x))
+
+/** Convert a hex number to its ASCII code.
+
+ @param [in]  x   Hex number to convert.
+                  Must be 0 <= x < 16.
+
+ @return The ASCII code corresponding to x.
+**/
+UINT8
+EFIAPI
+AsciiFromHex (
+  IN  UINT8   x
+  );
+
+/** Check if a HID is a valid PNP ID.
+
+  @param     [in] Hid     The Hid to validate.
+
+  @retval    TRUE         The Hid is a valid PNP ID.
+  @retval    FALSE        The Hid is not a valid PNP ID.
+**/
+BOOLEAN
+IsValidPnpId (
+  IN  CONST CHAR8  * Hid
+  );
+
+/** Check if a HID is a valid ACPI ID.
+
+  @param     [in] Hid     The Hid to validate.
+
+  @retval    TRUE         The Hid is a valid ACPI ID.
+  @retval    FALSE        The Hid is not a valid ACPI ID.
+**/
+BOOLEAN
+IsValidAcpiId (
+  IN  CONST CHAR8  * Hid
+  );
+
+#endif // ACPI_HELPER_LIB_H_
diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h b/DynamicTablesPkg/Include/Library/TableHelperLib.h
index 0f93cdbf0895..57af51134546 100644
--- a/DynamicTablesPkg/Include/Library/TableHelperLib.h
+++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h
@@ -12,18 +12,6 @@
 #ifndef TABLE_HELPER_LIB_H_
 #define TABLE_HELPER_LIB_H_
 
-/** Is a character upper case
-*/
-#define IS_UPPER_CHAR(x) ((x >= 'A') && (x <= 'Z'))
-
-/** Is a character a decimal digit
-*/
-#define IS_DIGIT(x) ((x >= '0') && (x <= '9'))
-
-/** Is a character an upper case hexadecimal digit
-*/
-#define IS_UPPER_HEX(x) (((x >= 'A') && (x <= 'F')) || IS_DIGIT (x))
-
 /** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_INFO
     object from the Configuration Manager.
 
@@ -119,41 +107,4 @@ FindDuplicateValue (
   IN        PFN_IS_EQUAL    EqualTestFunction
   );
 
-/** Convert a hex number to its ASCII code.
-
- @param [in]  x   Hex number to convert.
-                  Must be 0 <= x < 16.
-
- @return The ASCII code corresponding to x.
-**/
-UINT8
-EFIAPI
-AsciiFromHex (
-  IN  UINT8   x
-  );
-
-/** Check if a HID is a valid PNP ID.
-
-  @param     [in] Hid     The Hid to validate.
-
-  @retval    TRUE         The Hid is a valid PNP ID.
-  @retval    FALSE        The Hid is not a valid PNP ID.
-**/
-BOOLEAN
-IsValidPnpId (
-  IN  CONST CHAR8  * Hid
-  );
-
-/** Check if a HID is a valid ACPI ID.
-
-  @param     [in] Hid     The Hid to validate.
-
-  @retval    TRUE         The Hid is a valid ACPI ID.
-  @retval    FALSE        The Hid is not a valid ACPI ID.
-**/
-BOOLEAN
-IsValidAcpiId (
-  IN  CONST CHAR8  * Hid
-  );
-
 #endif // TABLE_HELPER_LIB_H_
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600Generator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600Generator.c
index 1e8c2bfca5de..cc730cd90fea 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600Generator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600Generator.c
@@ -23,8 +23,8 @@
 #include <AcpiTableGenerator.h>
 #include <ConfigurationManagerObject.h>
 #include <ConfigurationManagerHelper.h>
+#include <Library/AcpiHelperLib.h>
 #include <Library/AmlLib/AmlLib.h>
-#include <Library/TableHelperLib.h>
 #include <Protocol/ConfigurationManagerProtocol.h>
 #include "SsdtCmn600Generator.h"
 
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600LibArm.inf b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600LibArm.inf
index 821c0d531b98..12b028fcde22 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600LibArm.inf
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600LibArm.inf
@@ -1,7 +1,7 @@
 ## @file
 # Ssdt CMN-600 Table Generator
 #
-#  Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
+#  Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 ##
@@ -29,6 +29,7 @@ [Packages]
   DynamicTablesPkg/DynamicTablesPkg.dec
 
 [LibraryClasses]
+  AcpiHelperLib
   AmlLib
   BaseLib
 
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerialPortGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerialPortGenerator.c
index 570f53aacf16..1b70fe1db1d7 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerialPortGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerialPortGenerator.c
@@ -19,8 +19,9 @@
 #include <AcpiTableGenerator.h>
 #include <ConfigurationManagerObject.h>
 #include <ConfigurationManagerHelper.h>
+#include <Library/AcpiHelperLib.h>
+#include <Library/AmlLib/AmlLib.h>
 #include <Library/SsdtSerialPortFixupLib.h>
-#include <Library/TableHelperLib.h>
 #include <Protocol/ConfigurationManagerProtocol.h>
 
 /** ARM standard SSDT Serial Port Table Generator
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerialPortLibArm.inf b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerialPortLibArm.inf
index fb7663e280ad..36e61ea9b132 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerialPortLibArm.inf
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerialPortLibArm.inf
@@ -1,7 +1,7 @@
 ## @file
 # Ssdt Serial Port Table Generator
 #
-#  Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.<BR>
+#  Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 ##
@@ -27,7 +27,7 @@ [Packages]
   DynamicTablesPkg/DynamicTablesPkg.dec
 
 [LibraryClasses]
+  AcpiHelperLib
   AmlLib
   BaseLib
-  TableHelperLib
   SsdtSerialPortFixupLib
diff --git a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c
new file mode 100644
index 000000000000..85a32269aae5
--- /dev/null
+++ b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c
@@ -0,0 +1,109 @@
+/** @file
+  Acpi Helper
+
+  Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+// Module specific include files.
+#include <Library/AcpiHelperLib.h>
+
+/** Convert a hex number to its ASCII code.
+
+ @param [in]  x   Hex number to convert.
+                  Must be 0 <= x < 16.
+
+ @return The ASCII code corresponding to x.
+**/
+UINT8
+EFIAPI
+AsciiFromHex (
+  IN  UINT8   x
+  )
+{
+  if (x < 10) {
+    return (UINT8)(x + '0');
+  }
+
+  if (x < 16) {
+    return (UINT8)(x - 10 + 'A');
+  }
+
+  ASSERT (FALSE);
+  return (UINT8)-1;
+}
+
+/** Check if a HID is a valid PNP ID.
+
+  @param     [in] Hid     The Hid to validate.
+
+  @retval    TRUE         The Hid is a valid PNP ID.
+  @retval    FALSE        The Hid is not a valid PNP ID.
+**/
+BOOLEAN
+IsValidPnpId (
+  IN  CONST CHAR8  * Hid
+  )
+{
+  UINTN Index;
+
+  if (AsciiStrLen (Hid) != 7) {
+    return FALSE;
+  }
+
+  // A valid PNP ID must be of the form "AAA####"
+  // where A is an uppercase letter and # is a hex digit.
+  for (Index = 0; Index < 3; Index++) {
+    if (!IS_UPPER_CHAR (Hid[Index])) {
+      return FALSE;
+    }
+  }
+
+  for (Index = 3; Index < 7; Index++) {
+    if (!IS_UPPER_HEX (Hid[Index])) {
+      return FALSE;
+    }
+  }
+
+  return TRUE;
+}
+
+/** Check if a HID is a valid ACPI ID.
+
+  @param     [in] Hid     The Hid to validate.
+
+  @retval    TRUE         The Hid is a valid ACPI ID.
+  @retval    FALSE        The Hid is not a valid ACPI ID.
+**/
+BOOLEAN
+IsValidAcpiId (
+  IN  CONST CHAR8  * Hid
+  )
+{
+  UINTN Index;
+
+  if (AsciiStrLen (Hid) != 8) {
+    return FALSE;
+  }
+
+  // A valid ACPI ID must be of the form "NNNN####"
+  // where N is an uppercase letter or a digit ('0'-'9')
+  // and # is a hex digit.
+  for (Index = 0; Index < 4; Index++) {
+    if (!(IS_UPPER_CHAR (Hid[Index]) || IS_DIGIT (Hid[Index]))) {
+      return FALSE;
+    }
+  }
+
+  for (Index = 4; Index < 8; Index++) {
+    if (!IS_UPPER_HEX (Hid[Index])) {
+      return FALSE;
+    }
+  }
+
+  return TRUE;
+}
diff --git a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.inf b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.inf
new file mode 100644
index 000000000000..ba7a04eb5a77
--- /dev/null
+++ b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.inf
@@ -0,0 +1,25 @@
+## @file
+#  Acpi Helper
+#
+#  Copyright (c) 2021, ARM Limited. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION    = 0x0001001B
+  BASE_NAME      = AcpiHelperLib
+  FILE_GUID      = 45968FB4-A724-46FC-822D-F9E557601F9B
+  VERSION_STRING = 1.0
+  MODULE_TYPE    = DXE_DRIVER
+  LIBRARY_CLASS  = AcpiHelperLib
+
+[Sources]
+  AcpiHelper.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf b/DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf
index e2babef445d5..723de3ad4482 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf
+++ b/DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf
@@ -1,7 +1,7 @@
 ## @file
 #  AML Generation Library
 #
-#  Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.<BR>
+#  Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 ##
@@ -66,6 +66,7 @@ [Packages]
   DynamicTablesPkg/DynamicTablesPkg.dec
 
 [LibraryClasses]
+  AcpiHelperLib
   BaseLib
 
 [BuildOptions]
diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
index f2b4831ad596..8c77f172b795 100644
--- a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
+++ b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
@@ -23,8 +23,8 @@
 #include <AcpiTableGenerator.h>
 #include <ConfigurationManagerObject.h>
 #include <ConfigurationManagerHelper.h>
+#include <Library/AcpiHelperLib.h>
 #include <Library/AmlLib/AmlLib.h>
-#include <Library/TableHelperLib.h>
 #include <Protocol/ConfigurationManagerProtocol.h>
 
 /** C array containing the compiled AML template.
diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
index 54bf71a3b739..965167bdc4e1 100644
--- a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
+++ b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
@@ -25,6 +25,7 @@ [Packages]
   DynamicTablesPkg/DynamicTablesPkg.dec
 
 [LibraryClasses]
+  AcpiHelperLib
   AmlLib
   BaseLib
 
diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
index 9830ce62b3cb..9249e6b87f70 100644
--- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
+++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
@@ -245,99 +245,3 @@ FindDuplicateValue (
   }
   return FALSE;
 }
-
-/** Convert a hex number to its ASCII code.
-
- @param [in]  x   Hex number to convert.
-                  Must be 0 <= x < 16.
-
- @return The ASCII code corresponding to x.
-**/
-UINT8
-EFIAPI
-AsciiFromHex (
-  IN  UINT8   x
-  )
-{
-  if (x < 10) {
-    return (UINT8)(x + '0');
-  }
-
-  if (x < 16) {
-    return (UINT8)(x - 10 + 'A');
-  }
-
-  ASSERT (FALSE);
-  return (UINT8)0;
-}
-
-/** Check if a HID is a valid PNP ID.
-
-  @param     [in] Hid     The Hid to validate.
-
-  @retval    TRUE         The Hid is a valid PNP ID.
-  @retval    FALSE        The Hid is not a valid PNP ID.
-**/
-BOOLEAN
-IsValidPnpId (
-  IN  CONST CHAR8  * Hid
-  )
-{
-  UINTN Index;
-
-  if (AsciiStrLen (Hid) != 7) {
-    return FALSE;
-  }
-
-  // A valid PNP ID must be of the form "AAA####"
-  // where A is an uppercase letter and # is a hex digit.
-  for (Index = 0; Index < 3; Index++) {
-    if (!IS_UPPER_CHAR (Hid[Index])) {
-      return FALSE;
-    }
-  }
-
-  for (Index = 3; Index < 7; Index++) {
-    if (!IS_UPPER_HEX (Hid[Index])) {
-      return FALSE;
-    }
-  }
-
-  return TRUE;
-}
-
-/** Check if a HID is a valid ACPI ID.
-
-  @param     [in] Hid     The Hid to validate.
-
-  @retval    TRUE         The Hid is a valid ACPI ID.
-  @retval    FALSE        The Hid is not a valid ACPI ID.
-**/
-BOOLEAN
-IsValidAcpiId (
-  IN  CONST CHAR8  * Hid
-  )
-{
-  UINTN Index;
-
-  if (AsciiStrLen (Hid) != 8) {
-    return FALSE;
-  }
-
-  // A valid ACPI ID must be of the form "NNNN####"
-  // where N is an uppercase letter or a digit ('0'-'9')
-  // and # is a hex digit.
-  for (Index = 0; Index < 4; Index++) {
-    if (!(IS_UPPER_CHAR (Hid[Index]) || IS_DIGIT (Hid[Index]))) {
-      return FALSE;
-    }
-  }
-
-  for (Index = 4; Index < 8; Index++) {
-    if (!IS_UPPER_HEX (Hid[Index])) {
-      return FALSE;
-    }
-  }
-
-  return TRUE;
-}
-- 
2.17.1


  reply	other threads:[~2021-09-30  7:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-30  7:48 [PATCH v2 00/10] Various DynamicTablesPkg modifications PierreGondois
2021-09-30  7:48 ` PierreGondois [this message]
2021-09-30  7:48 ` [PATCH v2 02/10] DynamicTablesPkg: Update TableHelperLib.inf PierreGondois
2021-09-30  7:48 ` [PATCH v2 03/10] DynamicTablesPkg: Rename single char input parameter PierreGondois
2021-09-30  7:48 ` [PATCH v2 04/10] DynamicTablesPkg: Add HexFromAscii() to AcpiHelperLib PierreGondois
2021-09-30  7:48 ` [PATCH v2 05/10] DynamicTablesPkg: Add AmlGetEisaIdFromString() " PierreGondois
2021-09-30  7:48 ` [PATCH v2 06/10] DynamicTablesPkg: Add Configuration Manager Object parser PierreGondois
2021-09-30  7:48 ` [PATCH v2 07/10] DynamicTablesPkg: Use %a formatter in AmlDbgPrint PierreGondois
2021-09-30  7:48 ` [PATCH v2 08/10] DynamicTablesPkg: Update DynamicTablesPkg.ci.yaml PierreGondois
2021-09-30  7:48 ` [PATCH v2 09/10] DynamicTablesPkg: Deprecate Crs specific methods in AmlLib PierreGondois
2021-09-30  7:48 ` [PATCH v2 10/10] DynamicTablesPkg: Rework AmlResourceDataCodegen.c/h PierreGondois
2021-10-01 12:04 ` [PATCH v2 00/10] Various DynamicTablesPkg modifications 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=20210930074821.12546-2-Pierre.Gondois@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