From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (EUR03-AM5-obe.outbound.protection.outlook.com [40.107.3.83]) by mx.groups.io with SMTP id smtpd.web10.17212.1597245839147752244 for ; Wed, 12 Aug 2020 08:23:59 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=nGn26/Xx; spf=pass (domain: arm.com, ip: 40.107.3.83, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kvtA68BYBTidU9sBLa5+UtCVqXCK/+wphUm70TR6o/g=; b=nGn26/Xxo247f3td+xIEcJS7xxnoj5SMnBO2F98P4k9zd4vF6mw8QQkDeuMeVUVZRFCuPrcrYoNnz8iIYbQU6G8p7jeEaA0qoofVpSe4F99eLMP8fTLxnTL8Okhxy+ADcWbkssU7rqi5/FprWpJ9zFygprN8k8D0trrISp5zUnY= Received: from MR2P264CA0071.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::35) by VE1PR08MB5152.eurprd08.prod.outlook.com (2603:10a6:803:109::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.22; Wed, 12 Aug 2020 15:23:56 +0000 Received: from VE1EUR03FT028.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:31:cafe::76) by MR2P264CA0071.outlook.office365.com (2603:10a6:500:31::35) 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:56 +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 (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; 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:55 +0000 Received: ("Tessian outbound a0bffebca527:v64"); Wed, 12 Aug 2020 15:23:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3b8d97003a880db5 X-CR-MTA-TID: 64aa7808 Received: from e2fd11da9c51.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A2EB9D91-52EB-4705-8EF3-A3437DD82898.1; Wed, 12 Aug 2020 15:23:50 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e2fd11da9c51.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 12 Aug 2020 15:23:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gbRs5NlmLls5n29yQX9FhDZuT9oR3gmf49AjsPNEOP6GBSwD5BH5vk9EVy3W5gf37sEUOLgxtLWg8H5Vf1GK15J1cy+zqQ6c1bz3AEvyGfnBgroML4zeQb7oUpeMKsFfv+XXEuvIt+1q/cHhMbEt1qm3Tis5vX7AdMk8I0hPlfPo2LolAxxE6vWgwM2jqNAduwW+RAldpBzscpJsEBXap5cxgkWc5qwhcxN+cTV4z8wRlVB0FWFXdQbeTxldjFQzicWb+EtZB1D9mBsmDlNkRn/zHti2RnKuqLidA0zOQAZ4SfRYw4xcOm+iwgv5yEmJTpaSgzfRlr04l808bXVxmw== 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=kvtA68BYBTidU9sBLa5+UtCVqXCK/+wphUm70TR6o/g=; b=hBjdl2Ki2vqKYLgmohuKosoTCe4fTTX07CcarHe6JiVWtfS6ZI2VZQRq7RaP/t4e1oL/2/yGx/U8SVJM84xwGomYTQ2aadVfaDa3sU3hOoMHjkTzWCNbCUfsAPNkC6EtgHLdxjZaL+55hxi61vOginSfP4pnik31TZWK30EQh/pGaIeq1xlwrN8aOb7lHNaOcd/gyP+Ye3Qtka07JZXSLwYyPKqzJ9E1ySSv7h2Ed+5s5tAo1cIypNfFtdajScoXjrN712shQRsmaXUJIXWr52NdwIArjhXufzhqfqS2oP1DjAwBFhnswoidqi/o3Kr8tx+SA+LgjHlyL2Uw9oBQ6w== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kvtA68BYBTidU9sBLa5+UtCVqXCK/+wphUm70TR6o/g=; b=nGn26/Xxo247f3td+xIEcJS7xxnoj5SMnBO2F98P4k9zd4vF6mw8QQkDeuMeVUVZRFCuPrcrYoNnz8iIYbQU6G8p7jeEaA0qoofVpSe4F99eLMP8fTLxnTL8Okhxy+ADcWbkssU7rqi5/FprWpJ9zFygprN8k8D0trrISp5zUnY= Received: from AM6PR10CA0095.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::36) by DBBPR08MB4887.eurprd08.prod.outlook.com (2603:10a6:10:d7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15; Wed, 12 Aug 2020 15:23:49 +0000 Received: from AM5EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8c:cafe::b2) by AM6PR10CA0095.outlook.office365.com (2603:10a6:209:8c::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15 via Frontend Transport; Wed, 12 Aug 2020 15:23:49 +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; Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT049.mail.protection.outlook.com (10.152.17.130) 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:48 +0000 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:44 +0000 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: [PATCH v1 29/30] DynamicTablesPkg: Add SSDT Serial port for SPCR Date: Wed, 12 Aug 2020 16:22:35 +0100 Message-ID: <20200812152236.31164-30-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 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: 1f8902ef-ebc4-4fe7-8e0f-08d83ed3ba63 X-MS-TrafficTypeDiagnostic: DBBPR08MB4887:|VE1PR08MB5152: 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-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;SFS:(4636009)(346002)(136003)(376002)(396003)(39860400002)(46966005)(81166007)(47076004)(336012)(426003)(6666004)(186003)(82740400003)(2906002)(70586007)(1076003)(6916009)(26005)(36756003)(70206006)(356005)(5660300002)(7696005)(2616005)(478600001)(30864003)(44832011)(4326008)(86362001)(316002)(83380400001)(8936002)(8676002)(82310400002)(54906003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4887 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT028.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 564b0ae5-b3e6-45ec-b7eb-08d83ed3b647 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JhB7nAc+T8O2LskDPCO9o666iQBtLr4X6+cfod9Bp0PPM8Ngs3BBkaXO1YaLLquwfOwH7yq+U74N0czUdfuadU48mpncTPHUQ2eDF+UWbWyhLwdVepp155v/GBzMaDG2fSI3bbVrzwoeawgiUi+OskVzrrGlTfuuU5StvMONKrajPc1PK6XslSwGkUUeenwNtHsbcCbtfhq0dllycbxpHCuNtJjwrF0ZezdHU6rdQkhQSsohEgdzAMKhLTsdhxTlxEbN4GhVb2mamfS4d03iGQcCMW68rQzmAWXLSBHON9oJTuROZ0QfZU0T2FLlmWdgeyJUKi/7SD5igJI2/AxK5h18HyHZ4SF6WhDXKsnpY/lTi3SnIGf1U+JYvfkbjNfHqkj+rwyi0+yxzrWGTrFn5A== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFTY:;SFS:(4636009)(39860400002)(136003)(396003)(376002)(346002)(46966005)(8936002)(5660300002)(82310400002)(336012)(36756003)(86362001)(47076004)(2616005)(426003)(8676002)(4326008)(6916009)(316002)(36906005)(186003)(26005)(7696005)(54906003)(478600001)(83380400001)(81166007)(6666004)(44832011)(30864003)(70586007)(1076003)(2906002)(82740400003)(70206006);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2020 15:23:55.7554 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f8902ef-ebc4-4fe7-8e0f-08d83ed3ba63 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: VE1PR08MB5152 Content-Type: text/plain From: Pierre Gondois According to Arm Server Base Boot Requirements, Platform Design Document version 1.2 revision D, September 2, 2019, section '4.2.1.8 SPCR'; the SPCR console device must be included in the DSDT. The SSDT Serial port fixup library provides interfaces to generate a SSDT Serial port table based on the serial port information. Update the SPCR Generator to use the SSDT serial port fixup library to build a serial port definition block corresponding to the SPCR serial port and install the SSDT table. Signed-off-by: Pierre Gondois Signed-off-by: Sami Mujawar --- DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf | 3 +- DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c | 219 ++++++++++++++------ 2 files changed, 162 insertions(+), 60 deletions(-) diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf index 0ebe1ffbbdf0b53d9bab4fe454dffdceaeb7f48b..e11f878ec83e050592c8b0428c01c2eafba37cd8 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf @@ -1,7 +1,7 @@ ## @file # SPCR 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 ## @@ -27,6 +27,7 @@ [Packages] [LibraryClasses] BaseLib + SsdtSerialPortFixupLib [Pcd] diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c index b80e98ee7e143e39c540557d53a4129bf4ac5eb7..24bb5c014607b0746c4a8bb8bd260510fbdff08b 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c @@ -1,7 +1,8 @@ /** @file SPCR Table Generator - 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 @par Reference(s): @@ -14,12 +15,14 @@ #include #include #include +#include #include // Module specific include files. #include #include #include +#include #include #include @@ -40,6 +43,14 @@ NOTE: This implementation ignores the possibility that the Serial settings may #pragma pack(1) +/** A string representing the name of the SPCR port. +*/ +#define NAME_STR_SPCR_PORT "COM1" + +/** An UID representing the SPCR port. +*/ +#define UID_SPCR_PORT 1 + /** This macro defines the no flow control option. */ #define SPCR_FLOW_CONTROL_NONE 0 @@ -92,47 +103,111 @@ GET_OBJECT_LIST ( CM_ARM_SERIAL_PORT_INFO ) -/** Construct the SPCR 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 +FreeSpcrTableEx ( + 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, + IN OUT EFI_ACPI_DESCRIPTION_HEADER *** CONST Table, + IN CONST UINTN TableCount + ) +{ + EFI_STATUS Status; + EFI_ACPI_DESCRIPTION_HEADER ** TableList; + + ASSERT (This != NULL); + ASSERT (AcpiTableInfo != NULL); + ASSERT (CfgMgrProtocol != NULL); + ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID); + ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature); + + if ((Table == NULL) || + (*Table == NULL) || + (TableCount != 2)) { + DEBUG ((DEBUG_ERROR, "ERROR: SPCR: Invalid Table Pointer\n")); + return EFI_INVALID_PARAMETER; + } + + TableList = *Table; + + if ((TableList[1] == NULL) || + (TableList[1]->Signature != + EFI_ACPI_6_3_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE)) { + DEBUG ((DEBUG_ERROR, "ERROR: SPCR: Invalid SSDT table pointer.\n")); + return EFI_INVALID_PARAMETER; + } + + // Only need to free the SSDT table at index 1. The SPCR table is static. + Status = FreeSsdtSerialPortTable (TableList[1]); + ASSERT_EFI_ERROR (Status); + + // Free the table list. + FreePool (*Table); + + return Status; +} + +/** Construct the SPCR ACPI table and its associated SSDT table. This function invokes the Configuration Manager protocol interface to get the required hardware information for generating the ACPI table. If this function allocates any resources then they must be freed - in the FreeXXXXTableResources function. + in the FreeXXXXTableResourcesEx function. - @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). - @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_UNSUPPORTED An unsupported baudrate was specified by the - Configuration Manager. - @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration - Manager is less than the Object size for the - 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 -BuildSpcrTable ( - 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 +BuildSpcrTableEx ( + 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; ASSERT (This != NULL); ASSERT (AcpiTableInfo != NULL); ASSERT (CfgMgrProtocol != NULL); ASSERT (Table != NULL); + ASSERT (TableCount != NULL); ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID); ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature); @@ -155,7 +230,7 @@ BuildSpcrTable ( CfgMgrProtocol, CM_NULL_TOKEN, &SerialPortInfo, - NULL + &SerialPortCount ); if (EFI_ERROR (Status)) { DEBUG (( @@ -163,44 +238,46 @@ BuildSpcrTable ( "ERROR: SPCR: Failed to get serial port information. Status = %r\n", Status )); - goto error_handler; + return Status; } - if (SerialPortInfo->BaseAddress == 0) { - Status = EFI_INVALID_PARAMETER; + if (SerialPortCount == 0) { DEBUG (( DEBUG_ERROR, - "ERROR: SPCR: Uart port base address is invalid. BaseAddress = 0x%lx\n", - SerialPortInfo->BaseAddress + "ERROR: SPCR: Serial port information not found. Status = %r\n", + EFI_NOT_FOUND )); - goto error_handler; + return EFI_NOT_FOUND; } - if ((SerialPortInfo->PortSubtype != - EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART) && - (SerialPortInfo->PortSubtype != - EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_SBSA_GENERIC_UART_2X) && - (SerialPortInfo->PortSubtype != - EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_SBSA_GENERIC_UART) && - (SerialPortInfo->PortSubtype != - EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_FULL_16550) && - (SerialPortInfo->PortSubtype != - EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_DCC)) { - Status = EFI_INVALID_PARAMETER; + // Validate the SerialPort info. Only one SPCR port can be described. + // If platform provides description for multiple SPCR ports, use the + // first SPCR port information. + Status = ValidateSerialPortInfo (SerialPortInfo, 1); + if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, - "ERROR: SPCR: Uart port subtype is invalid. PortSubtype = 0x%x\n", - SerialPortInfo->PortSubtype + "ERROR: SPCR: Invalid serial port information. Status = %r\n", + Status )); - goto error_handler; + return Status; } - DEBUG ((DEBUG_INFO, "SPCR UART Configuration:\n")); - DEBUG ((DEBUG_INFO, " UART Base = 0x%lx\n", SerialPortInfo->BaseAddress)); - DEBUG ((DEBUG_INFO, " Clock = %d\n", SerialPortInfo->Clock)); - DEBUG ((DEBUG_INFO, " Baudrate = %ld\n", SerialPortInfo->BaudRate)); - DEBUG ((DEBUG_INFO, " Interrupt = %d\n", SerialPortInfo->Interrupt)); + // Allocate a table to store pointers to the SPCR and SSDT tables. + TableList = (EFI_ACPI_DESCRIPTION_HEADER**) + AllocateZeroPool (sizeof (EFI_ACPI_DESCRIPTION_HEADER*) * 2); + if (TableList == NULL) { + Status = EFI_OUT_OF_RESOURCES; + DEBUG (( + DEBUG_ERROR, + "ERROR: SPCR: Failed to allocate memory for Table List," \ + " Status = %r\n", + Status + )); + return Status; + } + // Build SPCR table. Status = AddAcpiHeader ( CfgMgrProtocol, This, @@ -267,9 +344,35 @@ BuildSpcrTable ( goto error_handler; } // switch - *Table = (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiSpcr; + TableList[0] = (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiSpcr; + + // Build a SSDT table describing the serial port. + Status = BuildSsdtSerialPortTable ( + AcpiTableInfo, + SerialPortInfo, + NAME_STR_SPCR_PORT, + UID_SPCR_PORT, + &TableList[1] + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: SPCR: Failed to build associated SSDT table. Status = %r\n", + Status + )); + goto error_handler; + } + + *TableCount = 2; + *Table = TableList; + + return Status; error_handler: + if (TableList != NULL) { + FreePool (TableList); + } + return Status; } @@ -287,7 +390,7 @@ ACPI_TABLE_GENERATOR SpcrGenerator = { // Generator Description L"ACPI.STD.SPCR.GENERATOR", // ACPI Table Signature - EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, // ACPI Table Revision supported by this Generator EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_REVISION, // Minimum supported ACPI Table Revision @@ -296,16 +399,14 @@ ACPI_TABLE_GENERATOR SpcrGenerator = { TABLE_GENERATOR_CREATOR_ID_ARM, // Creator Revision SPCR_GENERATOR_REVISION, - // Build Table function - BuildSpcrTable, - // 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. + BuildSpcrTableEx, + // Extended free function. + FreeSpcrTableEx }; /** Register the Generator with the ACPI Table Factory. -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'