From nobody Mon Feb 9 19:08:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109400+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109400+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696779574; cv=none; d=zohomail.com; s=zohoarc; b=hZvMe+b/3FkgBOifSkNOMGCTK1c449gaXGR8M5x5Twam4pv/c4qVMmVQ6lWGarIuJpsx8RPXuqF8ihTuT/0hmeb6MhhiDGw/HEypzYS7d0OQ80A/KoB4g9WKJ9Bbj7wYw4LQUr4Awvz7fWe81ixanMKlzl+VQt4jqSTBL2pm43g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696779574; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=FVhxwGbuXQ/j6GdlYaCnJuy2iEShah+d6X0fpa7xIrY=; b=f+nRHAoUg4kAeUvKnox0rnmY2jZF6gHA82SCjJtbcV2+QibIstKmSQWyeh7XOWXR8sP+qtanEAE9J9x+EASlywiNRw/8C6avuHWn4N1I4FbDkCSoJq5tqLRE57s8fwk9R7U+OfQWzpS6dTfllCg9SAKbq2afv4Nts6u6P8k/4KA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109400+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1696779574500462.28963326165865; Sun, 8 Oct 2023 08:39:34 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=FVhxwGbuXQ/j6GdlYaCnJuy2iEShah+d6X0fpa7xIrY=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1696779574; v=1; b=qeowPHgZJyd++QWlG0k4uDoQ7SddXuYJpPra2CIa6xIQFlDQxCt8KfaeI5LG2GxkD4vNjitJ tzOVV+9e6T9A0cXd/IJjl/yOYo2M14jth76THuy0/Qb2BlruoN7l6MDmI0asY/hxaC5T7LzJZLE wy7MpPUWtfw3tcfZnjRem2v8= X-Received: by 127.0.0.2 with SMTP id pycqYY1788612xe4qlKaupW3; Sun, 08 Oct 2023 08:39:34 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.40421.1696779573038207278 for ; Sun, 08 Oct 2023 08:39:33 -0700 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-52-sZOcZS3GMpaMIzgY7VPKiQ-1; Sun, 08 Oct 2023 11:39:19 -0400 X-MC-Unique: sZOcZS3GMpaMIzgY7VPKiQ-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC1553C176E1; Sun, 8 Oct 2023 15:39:18 +0000 (UTC) X-Received: from lacos-laptop-9.usersys.redhat.com (unknown [10.39.192.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF69F492B05; Sun, 8 Oct 2023 15:39:17 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Leif Lindholm , Sami Mujawar Subject: [edk2-devel] [PATCH 2/9] ArmVirtPkg/Fdt16550SerialPortHookLib: rebase to FdtSerialPortAddressLib Date: Sun, 8 Oct 2023 17:39:05 +0200 Message-Id: <20231008153912.175941-3-lersek@redhat.com> In-Reply-To: <20231008153912.175941-1-lersek@redhat.com> References: <20231008153912.175941-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: y7Rc9MngkYvbdq4K2kyYbgaox1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696779575117100023 Content-Type: text/plain; charset="utf-8"; x-default="true" This is only a refactoring; the patch is not supposed to cause any observable change. Build-tested only (with "ArmVirtKvmTool.dsc"). Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Leif Lindholm Cc: Sami Mujawar Signed-off-by: Laszlo Ersek --- ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortHookLi= b.inf | 3 +- ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortHookLi= b.c | 88 +------------------- 2 files changed, 4 insertions(+), 87 deletions(-) diff --git a/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550Seri= alPortHookLib.inf b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16= 550SerialPortHookLib.inf index 007a45eca2a6..22aba53d9b48 100644 --- a/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortH= ookLib.inf +++ b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortH= ookLib.inf @@ -22,12 +22,11 @@ [Sources] [LibraryClasses] BaseLib PcdLib - FdtLib + FdtSerialPortAddressLib HobLib =20 [Packages] ArmVirtPkg/ArmVirtPkg.dec - EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec =20 diff --git a/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550Seri= alPortHookLib.c b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt1655= 0SerialPortHookLib.c index c1b81920214b..03d28b9282ea 100644 --- a/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortH= ookLib.c +++ b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortH= ookLib.c @@ -17,90 +17,7 @@ #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 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; -} +#include =20 /** Platform hook to retrieve the 16550 UART base address from the platform Device tree and store it in PcdSerialRegisterBase. @@ -108,6 +25,7 @@ GetSerialConsolePortAddress ( @retval RETURN_SUCCESS Success. @retval RETURN_INVALID_PARAMETER A parameter was invalid. @retval RETURN_NOT_FOUND Serial port information not found. + @retval RETURN_PROTOCOL_ERROR Invalid information in the Device Tree. =20 **/ RETURN_STATUS @@ -129,7 +47,7 @@ PlatformHookSerialPortInitialize ( return RETURN_NOT_FOUND; } =20 - Status =3D GetSerialConsolePortAddress (DeviceTreeBase, &SerialConsoleAd= dress); + Status =3D FdtSerialGetConsolePort (DeviceTreeBase, &SerialConsoleAddres= s); if (RETURN_ERROR (Status)) { return Status; } -=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 (#109400): https://edk2.groups.io/g/devel/message/109400 Mute This Topic: https://groups.io/mt/101834887/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-