From nobody Mon Feb 9 18:18:47 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64108+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1597245852279750.429770752687; Wed, 12 Aug 2020 08:24:12 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id whogYY1788612xITmpguAE7N; Wed, 12 Aug 2020 08:24:11 -0700 X-Received: from EUR05-DB8-obe.outbound.protection.outlook.com (EUR05-DB8-obe.outbound.protection.outlook.com [40.107.20.81]) by mx.groups.io with SMTP id smtpd.web12.16989.1597245841767433673 for ; Wed, 12 Aug 2020 08:24:02 -0700 X-Received: from MR2P264CA0066.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::30) by AM5PR0802MB2402.eurprd08.prod.outlook.com (2603:10a6:203:a1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.16; Wed, 12 Aug 2020 15:23:58 +0000 X-Received: from VE1EUR03FT028.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:31:cafe::cc) by MR2P264CA0066.outlook.office365.com (2603:10a6:500:31::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Wed, 12 Aug 2020 15:23:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+64108+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT028.mail.protection.outlook.com (10.152.18.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Wed, 12 Aug 2020 15:23:58 +0000 X-Received: ("Tessian outbound a0bffebca527:v64"); Wed, 12 Aug 2020 15:23:58 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c30cb861c7dad406 X-CR-MTA-TID: 64aa7808 X-Received: from 7c045cdf71a9.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D8F30D48-2299-42BC-AED4-3AC58EF68326.1; Wed, 12 Aug 2020 15:23:52 +0000 X-Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 7c045cdf71a9.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 12 Aug 2020 15:23:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FmN5Smw7Rqi1tNxxg6Mkv9StQhc1p+2TjkD+qBBEoYVkP+/yoj5Lx3kYmagEELCy7r8GTU6byyroeQlq3ltKWHokAh+nYcJ+4cbD9qG3UT8xhkb2IPleFMo12x3BJIAXO+1rZQLsSMMn4zKdwGE8GS3uj2IYYdHjKr5Uweu0qx5lH60o64R5cGtwTbxd/i/IWqqlg7HJnG30EDGmnu8S3GrOFV4QYRLTUWfq1yksgOVJ57Wes4MgG4hlPNIorPyxbH9Uz72nWDtFdPKQm3zAYdbcTSbYKOfDVc+0Od8IWNd7QCu3YcAu/mTcgE6H/X45C6s+fOeo2/gOp2AmGGjpuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zrLrA+5nj1xTg0KI5PUWP5XLnbxc79w9bFPr9aTR8Wg=; b=IyZ9RmMBhVG0/cZ8XZXeqC+3yRFj9ga//SYy95yk5qBod2y2XHiS3qRgJ1X4YarQYem8SDi+/QKHAhixK8zVD8zjxvh8qsRqcoYegG4Tr+NztlI01DPH36iaH1NW7lGsayo3YHjXyxNVtRBR/l8Z/zcJwE9QlqiFgsKYK+BZaaK+biGv/ka38qe/98u2ZYr/hfYTKcEcdp1odLIucjlBzeDcX+jx8dwiTuNyw/jker9NN55MDIRRmGvN1xN6Cn5Qc2RyeICNGPev2XCBPgchfRb5RS1mSi7mfoIBFkLcLq5YlPdqZca5Da8EyeCxmvoNpQiVR6nBasTBmuxAXwdYRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AM5PR0402CA0001.eurprd04.prod.outlook.com (2603:10a6:203:90::11) by VI1PR08MB3264.eurprd08.prod.outlook.com (2603:10a6:803:4b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.20; Wed, 12 Aug 2020 15:23:50 +0000 X-Received: from AM5EUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:90:cafe::da) by AM5PR0402CA0001.outlook.office365.com (2603:10a6:203:90::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Wed, 12 Aug 2020 15:23:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; X-Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT057.mail.protection.outlook.com (10.152.17.44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3283.16 via Frontend Transport; Wed, 12 Aug 2020 15:23:50 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Wed, 12 Aug 2020 15:23:45 +0000 X-Received: from E107187.Arm.com (10.57.41.222) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2044.4 via Frontend Transport; Wed, 12 Aug 2020 15:23:44 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , Subject: [edk2-devel] [PATCH v1 30/30] DynamicTablesPkg: Add SSDT Serial port for DBG2 Date: Wed, 12 Aug 2020 16:22:36 +0100 Message-ID: <20200812152236.31164-31-sami.mujawar@arm.com> In-Reply-To: <20200812152236.31164-1-sami.mujawar@arm.com> References: <20200812152236.31164-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 67e6cb57-06dd-4146-f3d2-08d83ed3bbe2 X-MS-TrafficTypeDiagnostic: VI1PR08MB3264:|AM5PR0802MB2402: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:4941;OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ceDkrnWA1tZ1ondlv9+ZUBWGBxg3Zf6ZDdKvYs+KtKQAsxRK9aSkO+vQgpLGEF03vyZ2zqDJYPuJYeJdp3OxxoQMGPopShd8fFM/nPM9LvTMmYTPvIQnAAP3Ju6mF+C95DgGwRVXItWV2hFzojHeowOs69th9dDiHM02pVX0nr8+Kc7wilioBsw+pziMFxanAxcd+kFoFC66IF6ffl1PgztRYAgZ+Na07oJvqRy7IO2/4e5fS+u4p8UQuKlAz12hH/9AaixEKooS/n+uUFvENC4Py30IjhEwv9LSR84jk2mZIHtBNGRLOKxI+CvrS0V3pEK75ueGQH1FZhcrX5FapLNCbLPMMzSRKnKArO6FfteHJHlH59gHf3XRCUntLzWOp0AkP4YeFpcccQUECgJsTA== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFTY:;SFS:(4636009)(136003)(346002)(376002)(39860400002)(396003)(46966005)(83380400001)(6916009)(86362001)(81166007)(2906002)(478600001)(426003)(47076004)(186003)(70586007)(70206006)(4326008)(316002)(36756003)(26005)(336012)(5660300002)(82740400003)(7696005)(1076003)(8936002)(54906003)(44832011)(6666004)(8676002)(19627235002)(82310400002)(2616005)(30864003)(356005);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3264 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT028.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 13c7c9ed-887a-41e7-3726-08d83ed3b716 X-Microsoft-Antispam-Message-Info: xYkkRmFy19j9BKq4zaQFAavMUbG1IwNIgmKRWl0rYA/xnX+HZQo4UMT/JNHGrYlpAjYFCdWmSFHGsXcJRZzW0LXM3KKWe44eYng7r2aH/AJbp2/70KcnpvVIBSRJ0rXvKpgSWK12BLa2rhh9ao9QInseNpUCUM1OeQwbpXiATkxwzn1PlDt7ctTSVf37suGPiw307EqcCqP3gMJuBT8y3n6BXwSYL+KCL1TCgc2oFGqpzwPZMHbmIi4b4X+ru7OugoVZFScqISeGIUQXuG/t1MKOvxBPgNosggmk/lOdRQC9nENMqR0DIk5LqrEkmxOwNoFq8dyjSvgQ0i17E+OgV4CoX9CS/9ELIi7Sn+/u+8639yIs6Kt9L2pZ2sWQcZxk/vSLxFAzULa5RfxtoIMPYA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2020 15:23:58.2670 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67e6cb57-06dd-4146-f3d2-08d83ed3bbe2 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT028.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2402 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: mBARuiTsVProX3DSJtxXM6HEx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1597245851; bh=DWTmrajlpRsjkbCjbrc+9XIg6KeOZ2uBo4Gb4XOfG5w=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Px6QUokBRdLEp715g60a6qRGEVmEYOTCCVMV+V4RPfxh4jHD9h03t/JH5Zb+4lV93+g VzLuXiAlKRbbaV0d+pnDk0vBth8NViYINyOslk7IDDACuZlS5veKxPD9m2CNTqEMfU5Xt 6xZh4SEtchCG2OWRxdy8whUcp0JVQE0HeyE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Pierre Gondois The SSDT Serial port fixup library provides interfaces to generate a SSDT Serial port table based on the serial port information. Update the DBG2 Generator to use the SSDT serial port fixup library to build a serial port definition block for the DBG2 serial port and install the SSDT table. Signed-off-by: Pierre Gondois Signed-off-by: Sami Mujawar --- DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf | 3 = +- DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c | 228 = ++++++++++++++------ 2 files changed, 163 insertions(+), 68 deletions(-) diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibAr= m.inf b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf index 0f8d3cd687700d01fce6ced5d31a7a2b890bc551..f7b7c1c025a68989166faf34915= e1754bfb44ad0 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf @@ -1,7 +1,7 @@ ## @file # DBG2 Table Generator # -# Copyright (c) 2017 - 2018, ARM Limited. All rights reserved. +# Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -29,6 +29,7 @@ [Packages] [LibraryClasses] BaseLib PL011UartLib + SsdtSerialPortFixupLib =20 [FixedPcd] gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c index 172d99f61cf36e7e65d62249960fd7527d8dae00..d902bbc8463921624f1a6333e8d= 6bd84c6cb38f2 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c @@ -1,7 +1,8 @@ /** @file DBG2 Table Generator =20 - Copyright (c) 2017 - 2020, ARM Limited. All rights reserved. + Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent =20 @par Reference(s): @@ -12,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -20,6 +22,7 @@ #include #include #include +#include #include #include =20 @@ -44,17 +47,21 @@ Requirements: */ #define DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS 1 =20 -/** The index for the debug port 1 in the Debug port information list. +/** The index for the debug port 0 in the Debug port information list. */ -#define DBG_PORT_INDEX_PORT1 0 +#define INDEX_DBG_PORT0 0 =20 -/** A string representing the name of the debug port 1. +/** A string representing the name of the debug port 0. */ -#define NAME_STR_PORT1 "COM1" +#define NAME_STR_DBG_PORT0 "COM0" + +/** An UID representing the debug port 0. +*/ +#define UID_DBG_PORT0 0 =20 /** The length of the namespace string. */ -#define DBG2_NAMESPACESTRING_FIELD_SIZE sizeof (NAME_STR_PORT1) +#define DBG2_NAMESPACESTRING_FIELD_SIZE sizeof (NAME_STR_DBG_PO= RT0) =20 /** The PL011 UART address range length. */ @@ -159,7 +166,7 @@ DBG2_TABLE AcpiDbg2 =3D { 0, // {Template}: Serial Port Subtype 0, // {Template}: Serial Port Base Address PL011_UART_LENGTH, - NAME_STR_PORT1 + NAME_STR_DBG_PORT0 ) } }; @@ -217,58 +224,115 @@ SetupDebugUart ( &StopBits ); =20 - DEBUG ((DEBUG_INFO, "Debug UART Configuration:\n")); - DEBUG ((DEBUG_INFO, "UART Base =3D 0x%lx\n", SerialPortInfo->BaseAddres= s)); - DEBUG ((DEBUG_INFO, "Clock =3D %d\n", SerialPortInfo->Clock)); - DEBUG ((DEBUG_INFO, "Baudrate =3D %ld\n", BaudRate)); - DEBUG ((DEBUG_INFO, "Configuring Debug UART. Status =3D %r\n", Status)); - ASSERT_EFI_ERROR (Status); return Status; } =20 -/** Construct the DBG2 ACPI table +/** Free any resources allocated for constructing the tables. + + @param [in] This Pointer to the ACPI table generator. + @param [in] AcpiTableInfo Pointer to the ACPI Table Info. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in, out] Table Pointer to an array of pointers + to ACPI Table(s). + @param [in] TableCount Number of ACPI table(s). + + @retval EFI_SUCCESS The resources were freed successfully. + @retval EFI_INVALID_PARAMETER The table pointer is NULL or invalid. +**/ +STATIC +EFI_STATUS +EFIAPI +FreeDbg2TableEx ( + IN CONST ACPI_TABLE_GENERATOR * CONST This, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableIn= fo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProto= col, + IN OUT EFI_ACPI_DESCRIPTION_HEADER *** CONST Table, + IN CONST UINTN TableCount + ) +{ + EFI_STATUS Status; + EFI_ACPI_DESCRIPTION_HEADER ** TableList; + + ASSERT (This !=3D NULL); + ASSERT (AcpiTableInfo !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); + ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); + + if ((Table =3D=3D NULL) || + (*Table =3D=3D NULL) || + (TableCount !=3D 2)) { + DEBUG ((DEBUG_ERROR, "ERROR: DBG2: Invalid Table Pointer\n")); + return EFI_INVALID_PARAMETER; + } + + TableList =3D *Table; + + if ((TableList[1] =3D=3D NULL) || + (TableList[1]->Signature !=3D + EFI_ACPI_6_3_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE)) { + DEBUG ((DEBUG_ERROR, "ERROR: DBG2: Invalid SSDT table pointer.\n")); + return EFI_INVALID_PARAMETER; + } + + // Only need to free the SSDT table at index 1. The DBG2 table is static. + Status =3D FreeSsdtSerialPortTable (TableList[1]); + ASSERT_EFI_ERROR (Status); + + // Free the table list. + FreePool (*Table); + + return Status; +} =20 - The BuildDbg2Table function is called by the Dynamic Table Manager - to construct the DBG2 ACPI table. +/** Construct the DBG2 ACPI table and its associated SSDT table. =20 This function invokes the Configuration Manager protocol interface to get the required hardware information for generating the ACPI table. =20 If this function allocates any resources then they must be freed - in the FreeXXXXTableResources function. + in the FreeXXXXTableResourcesEx function. =20 - @param [in] This Pointer to the table generator. - @param [in] AcpiTableInfo Pointer to the ACPI Table Info. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. - @param [out] Table Pointer to the constructed ACPI Table. + @param [in] This Pointer to the ACPI table generator. + @param [in] AcpiTableInfo Pointer to the ACPI table information. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol interface. + @param [out] Table Pointer to a list of generated ACPI table(s= ). + @param [out] TableCount Number of generated ACPI table(s). =20 - @retval EFI_SUCCESS Table generated successfully. - @retval EFI_INVALID_PARAMETER A parameter is invalid. - @retval EFI_NOT_FOUND The required object was not found. - @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration - Manager is less than the Object size for t= he - requested object. + @retval EFI_SUCCESS Table generated successfully. + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + Manager is less than the Object size for + the requested object. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND Could not find information. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. + @retval EFI_UNSUPPORTED Unsupported configuration. **/ STATIC EFI_STATUS EFIAPI -BuildDbg2Table ( - IN CONST ACPI_TABLE_GENERATOR * CONST This, - IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, - OUT EFI_ACPI_DESCRIPTION_HEADER ** CONST Table +BuildDbg2TableEx ( + IN CONST ACPI_TABLE_GENERATOR * This, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + OUT EFI_ACPI_DESCRIPTION_HEADER *** Table, + OUT UINTN * CONST TableCount ) { - EFI_STATUS Status; - CM_ARM_SERIAL_PORT_INFO * SerialPortInfo; + EFI_STATUS Status; + CM_ARM_SERIAL_PORT_INFO * SerialPortInfo; + UINT32 SerialPortCount; + EFI_ACPI_DESCRIPTION_HEADER ** TableList; =20 ASSERT (This !=3D NULL); ASSERT (AcpiTableInfo !=3D NULL); ASSERT (CfgMgrProtocol !=3D NULL); ASSERT (Table !=3D NULL); + ASSERT (TableCount !=3D NULL); ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); =20 @@ -291,7 +355,7 @@ BuildDbg2Table ( CfgMgrProtocol, CM_NULL_TOKEN, &SerialPortInfo, - NULL + &SerialPortCount ); if (EFI_ERROR (Status)) { DEBUG (( @@ -299,34 +363,41 @@ BuildDbg2Table ( "ERROR: DBG2: Failed to get serial port information. Status =3D %r\n= ", Status )); - goto error_handler; + return Status; } =20 - if (SerialPortInfo->BaseAddress =3D=3D 0) { - Status =3D EFI_INVALID_PARAMETER; + if (SerialPortCount =3D=3D 0) { DEBUG (( DEBUG_ERROR, - "ERROR: DBG2: Uart port base address is invalid. BaseAddress =3D 0x%= lx\n", - SerialPortInfo->BaseAddress + "ERROR: DBG2: Serial port information not found. Status =3D %r\n", + EFI_NOT_FOUND )); - goto error_handler; + return EFI_NOT_FOUND; } =20 - if ((SerialPortInfo->PortSubtype !=3D - EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART) && - (SerialPortInfo->PortSubtype !=3D - EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_SBSA_GENERIC_UART_2X) && - (SerialPortInfo->PortSubtype !=3D - EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_SBSA_GENERIC_UART) && - (SerialPortInfo->PortSubtype !=3D - EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_DCC)) { - Status =3D EFI_INVALID_PARAMETER; + // Only use the first DBG2 port information. + Status =3D ValidateSerialPortInfo (SerialPortInfo, 1); + if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, - "ERROR: DBG2: Uart port subtype is invalid. PortSubtype =3D 0x%x\n", - SerialPortInfo->PortSubtype + "ERROR: DBG2: Invalid serial port information. Status =3D %r\n", + Status )); - goto error_handler; + return Status; + } + + // Allocate a table to store pointers to the DBG2 and SSDT tables. + TableList =3D (EFI_ACPI_DESCRIPTION_HEADER**) + AllocateZeroPool (sizeof (EFI_ACPI_DESCRIPTION_HEADER*) * 2); + if (TableList =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG (( + DEBUG_ERROR, + "ERROR: DBG2: Failed to allocate memory for Table List," \ + " Status =3D %r\n", + Status + )); + return Status; } =20 Status =3D AddAcpiHeader ( @@ -346,11 +417,11 @@ BuildDbg2Table ( } =20 // Update the base address - AcpiDbg2.Dbg2DeviceInfo[DBG_PORT_INDEX_PORT1].BaseAddressRegister.Addres= s =3D + AcpiDbg2.Dbg2DeviceInfo[INDEX_DBG_PORT0].BaseAddressRegister.Address =3D SerialPortInfo->BaseAddress; =20 // Update the serial port subtype - AcpiDbg2.Dbg2DeviceInfo[DBG_PORT_INDEX_PORT1].Dbg2Device.PortSubtype =3D + AcpiDbg2.Dbg2DeviceInfo[INDEX_DBG_PORT0].Dbg2Device.PortSubtype =3D SerialPortInfo->PortSubtype; =20 if ((SerialPortInfo->PortSubtype =3D=3D @@ -371,9 +442,35 @@ BuildDbg2Table ( } } =20 - *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiDbg2; + TableList[0] =3D (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiDbg2; + + // Build a SSDT table describing the serial port. + Status =3D BuildSsdtSerialPortTable ( + AcpiTableInfo, + SerialPortInfo, + NAME_STR_DBG_PORT0, + UID_DBG_PORT0, + &TableList[1] + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: DBG2: Failed to build associated SSDT table. Status =3D %r\n= ", + Status + )); + goto error_handler; + } + + *TableCount =3D 2; + *Table =3D TableList; + + return Status; =20 error_handler: + if (TableList !=3D NULL) { + FreePool (TableList); + } + return Status; } =20 @@ -391,7 +488,7 @@ ACPI_TABLE_GENERATOR Dbg2Generator =3D { // Generator Description L"ACPI.STD.DBG2.GENERATOR", // ACPI Table Signature - EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE, + EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE, // ACPI Table Revision supported by this Generator EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION, // Minimum supported ACPI Table Revision @@ -400,16 +497,14 @@ ACPI_TABLE_GENERATOR Dbg2Generator =3D { TABLE_GENERATOR_CREATOR_ID_ARM, // Creator Revision DBG2_GENERATOR_REVISION, - // Build Table function - BuildDbg2Table, - // No additional resources are allocated by the generator. - // Hence the Free Resource function is not required. + // Build table function. Use the extended version instead. NULL, - // Extended build function not needed + // Free table function. Use the extended version instead. NULL, - // Extended build function not implemented by the generator. - // Hence extended free resource function is not required. - NULL + // Extended Build table function. + BuildDbg2TableEx, + // Extended free function. + FreeDbg2TableEx }; =20 /** Register the Generator with the ACPI Table Factory. @@ -433,7 +528,6 @@ AcpiDbg2LibConstructor ( Status =3D RegisterAcpiTableGenerator (&Dbg2Generator); DEBUG ((DEBUG_INFO, "DBG2: Register Generator. Status =3D %r\n", Status)= ); ASSERT_EFI_ERROR (Status); - return Status; } =20 --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#64108): https://edk2.groups.io/g/devel/message/64108 Mute This Topic: https://groups.io/mt/76149194/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-