mirror of https://github.com/acidanthera/audk.git
DynamicTablesPkg: Extract AcpiHelperLib from TableHelperLib
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>
This commit is contained in:
parent
422e5d2f7f
commit
0875443f7e
|
@ -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 @@
|
|||
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
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
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
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
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
|
||||
|
|
|
@ -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_
|
|
@ -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_
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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 @@
|
|||
DynamicTablesPkg/DynamicTablesPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
AcpiHelperLib
|
||||
AmlLib
|
||||
BaseLib
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 @@
|
|||
DynamicTablesPkg/DynamicTablesPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
AcpiHelperLib
|
||||
AmlLib
|
||||
BaseLib
|
||||
TableHelperLib
|
||||
SsdtSerialPortFixupLib
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -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 @@
|
|||
DynamicTablesPkg/DynamicTablesPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
AcpiHelperLib
|
||||
BaseLib
|
||||
|
||||
[BuildOptions]
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
DynamicTablesPkg/DynamicTablesPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
AcpiHelperLib
|
||||
AmlLib
|
||||
BaseLib
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue