From nobody Sun Feb 8 21:47:56 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+65863+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 16016732805431023.4906793505417; Fri, 2 Oct 2020 14:14:40 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id HpPdYY1788612xhW5evdKaGN; Fri, 02 Oct 2020 14:14:40 -0700 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.47]) by mx.groups.io with SMTP id smtpd.web10.5609.1601673278312160596 for ; Fri, 02 Oct 2020 14:14:38 -0700 X-Received: from AM6P193CA0096.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::37) by DB7PR08MB3257.eurprd08.prod.outlook.com (2603:10a6:5:19::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22; Fri, 2 Oct 2020 21:14:32 +0000 X-Received: from VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:88:cafe::2b) by AM6P193CA0096.outlook.office365.com (2603:10a6:209:88::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.35 via Frontend Transport; Fri, 2 Oct 2020 21:14:32 +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=pass 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+65863+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 VE1EUR03FT049.mail.protection.outlook.com (10.152.19.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.34 via Frontend Transport; Fri, 2 Oct 2020 21:14:32 +0000 X-Received: ("Tessian outbound 7a6fb63c1e64:v64"); Fri, 02 Oct 2020 21:14:30 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: edd61c0462aa69db X-CR-MTA-TID: 64aa7808 X-Received: from ffbcc8e9eb4d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 89197AE4-96A0-4DFF-A825-66ED00B436EF.1; Fri, 02 Oct 2020 21:14:25 +0000 X-Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ffbcc8e9eb4d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 02 Oct 2020 21:14:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mf4cSadqeA91o4hMaL2/MoD4W6Wi+UydlS34ug0qhtv2J50lop4sF9UsJKhvfQqtjSMsOlRP5R+nVvkJLbc3kfNQH+pxEqsBawhOq6lUd28WJ68KcEfPJYtfmnIJDxiB5NH/ia3hTh13Pzvy00pqMomH4gypviGMRdtW75ONwgEw8NvV1KCTgXusbMS6uvTs+p6vi8epGaTUeOQyRsrAtHi53Tw1Vn6y+12xo56G+UF0zpZC4FEB7NrdCuCqeMcgmE8ibyRN6wK+wxveYqsEhetfXi9aQXArjc50lcPg6M1zmblHljIaI5HkTHXZXVG/a7Ql+UnLqmsxW5JizdNH4g== 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=2A67lEqI6GXPHAkgJJxtwpkKZcIVqavkelDDRf3Q5Zg=; b=Lz3AYt69bXx7KkkobwQFtw3+fYCfmGECg/CWoikZGa5DqOIi2VGsLWiCocZiQglCs9RWfT89Lh1hhOW6TU9pKYT7SaGIYbs7koRKC0SUSaliFfMmhAH0D6veAhLch3XL3a39e94Tbw9+nBpgNHUvRHsmTq+YJApKZ5b2rIHH1HojwTI2DsAb95+PjUk2L/M7609d4hqQ8951wTfEJZbO708g2/apCrpnWsD3wLfv7f6lUS1XrsOevZY5ATetE6AqLMJZzTYQ4jniurn2XYna8M49ZsY8PZV8NapV8mOIcsaAlEOigzsrkLPKVz5eZUmq5td8baiEAcZvHT1JA6SPVg== 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=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AM3PR05CA0116.eurprd05.prod.outlook.com (2603:10a6:207:2::18) by VI1PR08MB4318.eurprd08.prod.outlook.com (2603:10a6:803:f8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.34; Fri, 2 Oct 2020 21:14:23 +0000 X-Received: from AM5EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:207:2:cafe::fd) by AM3PR05CA0116.outlook.office365.com (2603:10a6:207:2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.35 via Frontend Transport; Fri, 2 Oct 2020 21:14:23 +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=pass 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 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.3433.34 via Frontend Transport; Fri, 2 Oct 2020 21:14:23 +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; Fri, 2 Oct 2020 21:14:19 +0000 X-Received: from E107187.Arm.com (10.57.53.44) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2044.4 via Frontend Transport; Fri, 2 Oct 2020 21:14:18 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , Subject: [edk2-devel] [PATCH v5 09/15] ArmVirtPkg: 16550 UART Platform hook library Date: Fri, 2 Oct 2020 22:14:03 +0100 Message-ID: <20201002211409.43888-10-sami.mujawar@arm.com> In-Reply-To: <20201002211409.43888-1-sami.mujawar@arm.com> References: <20201002211409.43888-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: 3fe6acca-1e54-41c4-9e3d-08d86718280b X-MS-TrafficTypeDiagnostic: VI1PR08MB4318:|DB7PR08MB3257: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3383;OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: kqprTn3qphJmnKtFo5OwtglydO/UTvX9x52YAqKEKp9gSvEhfj4LLHqqMNFz1HsWO/qQn4EYSkwsUEpNoXGg7x+eri+kVfWSuS3q13l/7E1drsqRH7n3ZImVUHzlVYNw/4wiW3EvjLoi1SC94qJpzubQpi8sMe84uLusNMnaM8dVH0V3OVbn49+TywEbdGH034PXxrxwAEX7wJ3F4RwacBqGs9jMV/HQXc1BwBOvoVS7l63z7ztsZSbXbaDEK14Aeis4JNySVasRgOszQ3CYl0Ul2rRMty2C1c3vMhOVjy0IjKDN3SqSFck290Rq7HKx1NyJ22n3K/ZIwlTF4zNHoc7/k7eSgGeh2HWQM72XEP+riLWykvf6E7Y7BQv5nhq+FPAu+8R6t6OTobM/wQv65uFpHbwUd1tHXOAvKky0NGZTbmZruFSHYlRjYrp5J5FuDGDESBsbybPrwFmicWsPpMVs5zUtKcVZ5kqItx1Z+E8= 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)(39860400002)(136003)(346002)(376002)(396003)(46966005)(82740400003)(8936002)(36756003)(47076004)(336012)(82310400003)(19627235002)(81166007)(356005)(83380400001)(70586007)(83080400001)(6666004)(1076003)(70206006)(186003)(26005)(426003)(4326008)(86362001)(44832011)(5660300002)(7696005)(6916009)(30864003)(2616005)(54906003)(8676002)(316002)(966005)(478600001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4318 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 7056d319-baf5-45d5-4b0e-08d8671822de X-Microsoft-Antispam-Message-Info: 8cQvoNdIMUtT33avHFAWHnr1MHSeANaJEu+wmCLMW7twq/K3mJBxp7AqC99y1sV5COnGDcMiHMjlt4UabVExiyppxTxXcQmRIiRpYLE82Mq7J7gaWFG3rUUThkFUwMXCDhznJ6ylG4qdXKzPm0XUN5z/hQr57q8JzjXjrv+Gvth33vveXiQlH7tJeaDHlPOQ9Vxuhn9nwG+PVgNp31G82TZ7G0buKgAz/sbw+kBKcCZ3puw3RNidZpxEm/t+Mi89DpPdopTRwSpPUCqV/TrRfV36h936/z50j+h5F3RBiad+ihOb+nwdWeRqiN+2FQ8i+kp7p2t5z6z4A0m/d/Tzl2Rk7v5wSc9ycLoPWCX2ipuvOLuTnzL957WoXcZ23dPymAKG0Z47Y9JBhhUmGYnOsO/d2121JuSqNGroEpL9kCBOQEU4sAPJ9/zKdQCSrZbIdc6GWNG5gDjsAw6IE8AiqQpto49ybR4Vne3c1Kk46cunU2zJWB0yCIjzBZbKMGZOslO9ZimPYdhmL8Q/tZ9h1w== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2020 21:14:32.0491 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3fe6acca-1e54-41c4-9e3d-08d86718280b 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: VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3257 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: 1Iru1IhF4XGwnJPkPFgk0CXIx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1601673280; bh=MWmly8+mx/j01Yck9BUUsHttBTOP3Wkyj1D4l0neCoo=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=ZR++yu+jsJepEQqQZPvx162krZKbzFc0Vhn58vDWmoHKaaxiLpl53j2wIlYeJeocLLK foVPkfGDO9nHC4JKw1Vbz4Q5qNjIpJaJgM8Bgl1JTsPPpItNrN1L2oFilym26Q2moR6sE 7XuE7JeRw1SlvdUzTHNyP7KtY4Sp5jlpkcE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The BaseSerialPort16550 library invokes the PlatformHookSerialPortInitialize() implemented as part of the PlatformHook library, to perform platform specific initialization required to enable use of the 16550 device. The BaseSerialPort16550 library uses the PcdSerialRegisterBase to obtain the base address of the UART for MMIO operations. Some VMMs like Kvmtool provide the base address of the console serial port in the platform device tree. This patch introduces two instances of the Platform Hook library: 1. EarlyFdt16550SerialPortHookLib - parses the platform device tree to extract the base address of the 16550 UART and update the PCD PcdSerialRegisterBase. 2. Fdt16550SerialPortHookLib - reads the GUID Hob gEarly16550UartBaseAddressGuid (that caches the base address of the 16550 UART discovered during early stages) and updates the PCD PcdSerialRegisterBase. Note: a. The PCD PcdSerialRegisterBase is configured as PatchableInModule. b. A separate patch introduces a PlatformPeiLib that trampolines the 16550 UART base address from the Pcd PcdSerialRegisterBase to the GUID Hob gEarly16550UartBaseAddressGuid. Signed-off-by: Sami Mujawar Reviewed-by: Ard Biesheuvel --- Notes: v5: - No code changes, resending patch with v5 series. [Sami] Ref: https://edk2.groups.io/g/devel/message/62142 =20 v4: - No code change, resending patch with v4 series. [Sami] Ref: https://edk2.groups.io/g/devel/message/61721 ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortHookLi= b.c | 138 ++++++++++++++++++++ ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortHookLi= b.inf | 36 +++++ ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550SerialPortHookLib.c = | 57 ++++++++ ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550SerialPortHookLib.inf= | 39 ++++++ ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550SerialPortHookLib.uni= | 14 ++ 5 files changed, 284 insertions(+) diff --git a/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550Seri= alPortHookLib.c b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt1655= 0SerialPortHookLib.c new file mode 100644 index 0000000000000000000000000000000000000000..4e97302d01dc5692e046fb90166= 3373828b532ee --- /dev/null +++ b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortH= ookLib.c @@ -0,0 +1,138 @@ +/** @file + Early Platform Hook Library instance for 16550 Uart. + + Copyright (c) 2020, ARM Ltd. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +/** Get the UART base address of the console serial-port from the DT. + + This function fetches the node referenced in the "stdout-path" + property of the "chosen" node and returns the base address of + the console UART. + + @param [in] Fdt Pointer to a Flattened Device Tree (= Fdt). + @param [out] SerialConsoleAddress If success, contains the base address + of the console serial-port. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_NOT_FOUND Console serial-port info not found in DT. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +STATIC +EFI_STATUS +EFIAPI +GetSerialConsolePortAddress ( + IN CONST VOID *Fdt, + OUT UINT64 *SerialConsoleAddress + ) +{ + CONST CHAR8 *Prop; + INT32 PropSize; + CONST CHAR8 *Path; + INT32 PathLen; + INT32 ChosenNode; + INT32 SerialConsoleNode; + INT32 Len; + CONST CHAR8 *NodeStatus; + CONST UINT64 *RegProperty; + + if ((Fdt =3D=3D NULL) || (fdt_check_header (Fdt) !=3D 0)) { + return EFI_INVALID_PARAMETER; + } + + // The "chosen" node resides at the the root of the DT. Fetch it. + ChosenNode =3D fdt_path_offset (Fdt, "/chosen"); + if (ChosenNode < 0) { + return EFI_NOT_FOUND; + } + + Prop =3D fdt_getprop (Fdt, ChosenNode, "stdout-path", &PropSize); + if (PropSize < 0) { + return EFI_NOT_FOUND; + } + + // Determine the actual path length, as a colon terminates the path. + Path =3D ScanMem8 (Prop, ':', PropSize); + if (Path =3D=3D NULL) { + PathLen =3D AsciiStrLen (Prop); + } else { + PathLen =3D Path - Prop; + } + + // Aliases cannot start with a '/', so it must be the actual path. + if (Prop[0] =3D=3D '/') { + SerialConsoleNode =3D fdt_path_offset_namelen (Fdt, Prop, PathLen); + } else { + // Lookup the alias, as this contains the actual path. + Path =3D fdt_get_alias_namelen (Fdt, Prop, PathLen); + if (Path =3D=3D NULL) { + return EFI_NOT_FOUND; + } + SerialConsoleNode =3D fdt_path_offset (Fdt, Path); + } + + NodeStatus =3D fdt_getprop (Fdt, SerialConsoleNode, "status", &Len); + if ((NodeStatus !=3D NULL) && (AsciiStrCmp (NodeStatus, "okay") !=3D 0))= { + return EFI_NOT_FOUND; + } + + RegProperty =3D fdt_getprop (Fdt, SerialConsoleNode, "reg", &Len); + if (Len !=3D 16) { + return EFI_INVALID_PARAMETER; + } + + *SerialConsoleAddress =3D fdt64_to_cpu (ReadUnaligned64 (RegProperty)); + + return EFI_SUCCESS; +} + +/** Platform hook to retrieve the 16550 UART base address from the platform + Device tree and store it in PcdSerialRegisterBase. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter was invalid. + @retval RETURN_NOT_FOUND Serial port information not found. + +**/ +RETURN_STATUS +EFIAPI +PlatformHookSerialPortInitialize ( + VOID + ) +{ + RETURN_STATUS Status; + VOID *DeviceTreeBase; + UINT64 SerialConsoleAddress; + + if (PcdGet64 (PcdSerialRegisterBase) !=3D 0) { + return RETURN_SUCCESS; + } + + DeviceTreeBase =3D (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddr= ess); + if (DeviceTreeBase =3D=3D NULL) { + return RETURN_NOT_FOUND; + } + + Status =3D GetSerialConsolePortAddress (DeviceTreeBase, &SerialConsoleAd= dress); + if (RETURN_ERROR (Status)) { + return Status; + } + + return (EFI_STATUS)PcdSet64S (PcdSerialRegisterBase, SerialConsoleAddres= s); +} + diff --git a/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550Seri= alPortHookLib.inf b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16= 550SerialPortHookLib.inf new file mode 100644 index 0000000000000000000000000000000000000000..007a45eca2a622118044b527a5b= c6403b706608a --- /dev/null +++ b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortH= ookLib.inf @@ -0,0 +1,36 @@ +## @file +# Early Platform Hook Library instance for 16550 Uart. +# +# Copyright (c) 2020, ARM Ltd. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D EarlyFdt16550SerialPortHookLib + MODULE_UNI_FILE =3D Fdt16550SerialPortHookLib.uni + FILE_GUID =3D FFB19961-79CC-4684-84A8-C31B0A2BBE82 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PlatformHookLib|SEC PEI_CORE PEIM + +[Sources] + EarlyFdt16550SerialPortHookLib.c + +[LibraryClasses] + BaseLib + PcdLib + FdtLib + HobLib + +[Packages] + ArmVirtPkg/ArmVirtPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + +[Pcd] + gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase diff --git a/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550SerialPor= tHookLib.c b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550SerialPor= tHookLib.c new file mode 100644 index 0000000000000000000000000000000000000000..1100c12aef361e39cf78f0c3e4e= 14cc2feecfcee --- /dev/null +++ b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550SerialPortHookLi= b.c @@ -0,0 +1,57 @@ +/** @file + Platform Hook Library instance for 16550 Uart. + + Copyright (c) 2020, ARM Ltd. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +/** Platform hook to retrieve the 16550 UART base address from the GUID Hob + that caches the UART base address from early boot stage and store it in + PcdSerialRegisterBase. + + @retval RETURN_SUCCESS Success. + @retval RETURN_NOT_FOUND Serial Port information not found. + +**/ +RETURN_STATUS +EFIAPI +PlatformHookSerialPortInitialize ( + VOID + ) +{ + VOID *Hob; + UINT64 *UartBase; + + if (PcdGet64 (PcdSerialRegisterBase) !=3D 0) { + return RETURN_SUCCESS; + } + + Hob =3D GetFirstGuidHob (&gEarly16550UartBaseAddressGuid); + if ((Hob =3D=3D NULL) || (GET_GUID_HOB_DATA_SIZE (Hob) !=3D sizeof (*Uar= tBase))) { + return RETURN_NOT_FOUND; + } + + UartBase =3D GET_GUID_HOB_DATA (Hob); + if ((UINTN)*UartBase =3D=3D 0) { + return RETURN_NOT_FOUND; + } + + return (RETURN_STATUS)PcdSet64S (PcdSerialRegisterBase, (UINTN)*UartBase= ); +} + diff --git a/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550SerialPor= tHookLib.inf b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550SerialP= ortHookLib.inf new file mode 100644 index 0000000000000000000000000000000000000000..ba789ca69041b647a4a881b0311= 0ff853df89f65 --- /dev/null +++ b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550SerialPortHookLi= b.inf @@ -0,0 +1,39 @@ +## @file +# Platform Hook Library instance for 16550 Uart. +# +# Copyright (c) 2020, ARM Ltd. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D Fdt16550SerialPortHookLib + MODULE_UNI_FILE =3D Fdt16550SerialPortHookLib.uni + FILE_GUID =3D C6DFD3F0-179D-4376-89A5-F641A2E7EFB5 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PlatformHookLib|DXE_CORE DXE_DRIVER U= EFI_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION + CONSTRUCTOR =3D PlatformHookSerialPortInitialize + +[Sources] + Fdt16550SerialPortHookLib.c + +[LibraryClasses] + BaseLib + PcdLib + HobLib + +[Packages] + ArmVirtPkg/ArmVirtPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase + +[Guids] + gEarly16550UartBaseAddressGuid + diff --git a/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550SerialPor= tHookLib.uni b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550SerialP= ortHookLib.uni new file mode 100644 index 0000000000000000000000000000000000000000..19a61a4a03244321bda7c88cd26= 128b44bfd46b4 --- /dev/null +++ b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550SerialPortHookLi= b.uni @@ -0,0 +1,14 @@ +// /** @file +// Platform Hook Library instance for 16550 Uart. +// +// +// Copyright (c) 2020, ARM Ltd. All rights reserved.
+// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "Platform Hook Library ins= tance for 16550 Uart." + +#string STR_MODULE_DESCRIPTION #language en-US "Platform Hook Library ins= tance for 16550 Uart." + --=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 (#65863): https://edk2.groups.io/g/devel/message/65863 Mute This Topic: https://groups.io/mt/77270955/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-