From nobody Sun May 19 04:05:41 2024 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+89637+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+89637+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1652166685; cv=none; d=zohomail.com; s=zohoarc; b=E3O+cK5rcNxmWLAG94hNZgW84G9ARjndy/NO/zPNXOSd14d8vYbok4jo0AxbfTE2znvfKDMZeDFi9dYeA4JEz8injaBv6mjxLg6v5jKpmSk+gFKHTa/kpN9g/VeAQZQ8j+miTh0WR+oc6SXS8itvXfSNchPt6ZIeSD7qRrN6oiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652166685; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=MDV1Vb6/T+eiIwZipgnOaKhnj3o4tbHaUJzm9xPv4ng=; b=R92UGf94hlHMX8wCiM6/JCVOEXY8D5lEKMpiKoEeyLS9vyeYtP6PJJsf3HLkBPNRlCcuOuusCLlxNKBAko9yRyHif7poS4yDhxFvMVC/g+RfbgLmz2q06FS4cLD1BIXj8sGUH4tpgq9RI/PFmciQemFKRKYxJWbH4wEclJZbUcg= 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+89637+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 1652166685457733.2550795966989; Tue, 10 May 2022 00:11:25 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9jliYY1788612xli5BFr0P4w; Tue, 10 May 2022 00:11:24 -0700 X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.6679.1652166681383551366 for ; Tue, 10 May 2022 00:11:23 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10342"; a="268127925" X-IronPort-AV: E=Sophos;i="5.91,213,1647327600"; d="scan'208";a="268127925" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2022 00:11:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,213,1647327600"; d="scan'208";a="696953428" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.158]) by orsmga004.jf.intel.com with ESMTP; 10 May 2022 00:11:21 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Sean Rhodes Subject: [edk2-devel] [PATCH 1/3] UefiPayloadPkg: Simplify code logic Date: Tue, 10 May 2022 15:11:09 +0800 Message-Id: <2ce68964b1dc683b505e765cdf96b262f66f051c.1652166437.git.zhiguang.liu@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhiguang.liu@intel.com X-Gm-Message-State: 7uEHlMJOrZ8hTVzPgjT5xih6x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1652166684; bh=57LtFHzbJznbynBKnlk1YIQNDjLLNN1ZpWiM6Np2IHQ=; h=Cc:Date:From:Reply-To:Subject:To; b=r4XpNQgqYloCNiy8NslR8VvKuFFwgjMO+8SeRcoH2u+/eJcWJH4ms6vQyANrLZiIL2B uSmkA/HHitbCCXIqXhPfAENF35tPbezPDDGVYSezKDcBBwmPFIqfHdWrefxgwtq/cDT5t hFYSXe2LRzFcnm2HgJlKtMBPiNj3pga+b+Y= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1652166685954100004 Content-Type: text/plain; charset="utf-8" A little overdesign about VisitAllPciInstances function, since there are two call back functions. Simplify the code logic by combining the two call back functions. Cc: Guo Dong Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Cc: Sean Rhodes Signed-off-by: Zhiguang Liu --- .../PlatformBootManagerLib/PlatformConsole.c | 83 +++++-------------- 1 file changed, 21 insertions(+), 62 deletions(-) diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.= c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c index bfaf89e74c..9887183624 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c @@ -387,18 +387,20 @@ VisitAllInstancesOfProtocol ( } =20 /** - For every PCI instance execute a callback function. + Do platform specific PCI Device check and add them to + ConOut, ConIn, ErrOut. =20 - @param[in] Handle - The PCI device handle - @param[in] Instance - The instance of the PciIo protocol - @param[in] Context - The context of the callback + @param[in] Handle - Handle of PCI device instance + @param[in] Instance - The instance of PCI device + @param[in] Context - The context of the callback =20 - @retval EFI_STATUS - Callback function failed. + @retval EFI_SUCCESS - PCI Device check and Console variable update succe= ssfully. + @retval EFI_STATUS - PCI Device check or Console variable update fail. =20 **/ EFI_STATUS EFIAPI -VisitingAPciInstance ( +DetectAndPreparePlatformPciDevicePath ( IN EFI_HANDLE Handle, IN VOID *Instance, IN VOID *Context @@ -424,56 +426,6 @@ VisitingAPciInstance ( return Status; } =20 - return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN)Context)( - Handle, - PciIo, - &Pci - ); -} - -/** - For every PCI instance execute a callback function. - - @param[in] CallBackFunction - Callback function pointer - - @retval EFI_STATUS - Callback function failed. - -**/ -EFI_STATUS -EFIAPI -VisitAllPciInstances ( - IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction - ) -{ - return VisitAllInstancesOfProtocol ( - &gEfiPciIoProtocolGuid, - VisitingAPciInstance, - (VOID *)(UINTN)CallBackFunction - ); -} - -/** - Do platform specific PCI Device check and add them to - ConOut, ConIn, ErrOut. - - @param[in] Handle - Handle of PCI device instance - @param[in] PciIo - PCI IO protocol instance - @param[in] Pci - PCI Header register block - - @retval EFI_SUCCESS - PCI Device check and Console variable update succe= ssfully. - @retval EFI_STATUS - PCI Device check or Console variable update fail. - -**/ -EFI_STATUS -EFIAPI -DetectAndPreparePlatformPciDevicePath ( - IN EFI_HANDLE Handle, - IN EFI_PCI_IO_PROTOCOL *PciIo, - IN PCI_TYPE00 *Pci - ) -{ - EFI_STATUS Status; - Status =3D PciIo->Attributes ( PciIo, EfiPciIoAttributeOperationEnable, @@ -486,9 +438,9 @@ DetectAndPreparePlatformPciDevicePath ( // // Here we decide whether it is LPC Bridge // - if ((IS_PCI_LPC (Pci)) || - ((IS_PCI_ISA_PDECODE (Pci)) && - (Pci->Hdr.VendorId =3D=3D 0x8086) + if ((IS_PCI_LPC (&Pci)) || + ((IS_PCI_ISA_PDECODE (&Pci)) && + (Pci.Hdr.VendorId =3D=3D 0x8086) ) ) { @@ -504,7 +456,7 @@ DetectAndPreparePlatformPciDevicePath ( // // Here we decide which Serial device to enable in PCI bus // - if (IS_PCI_16550SERIAL (Pci)) { + if (IS_PCI_16550SERIAL (&Pci)) { // // Add them to ConOut, ConIn, ErrOut. // @@ -517,7 +469,7 @@ DetectAndPreparePlatformPciDevicePath ( // // Enable all display devices // - if (IS_PCI_DISPLAY (Pci)) { + if (IS_PCI_DISPLAY (&Pci)) { // // Add them to ConOut. // @@ -543,6 +495,8 @@ DetectAndPreparePlatformPciDevicePaths ( BOOLEAN DetectDisplayOnly ) { + EFI_STATUS Status; + mDetectDisplayOnly =3D DetectDisplayOnly; =20 EfiBootManagerUpdateConsoleVariable ( @@ -551,7 +505,12 @@ DetectAndPreparePlatformPciDevicePaths ( NULL ); =20 - return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath); + Status =3D VisitAllInstancesOfProtocol ( + &gEfiPciIoProtocolGuid, + DetectAndPreparePlatformPciDevicePath, + NULL + ); + return Status; } =20 /** --=20 2.32.0.windows.2 -=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 (#89637): https://edk2.groups.io/g/devel/message/89637 Mute This Topic: https://groups.io/mt/91007797/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- From nobody Sun May 19 04:05:41 2024 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+89638+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+89638+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1652166688; cv=none; d=zohomail.com; s=zohoarc; b=XHYDeTU6bcAQk7aMfTnpuak+8jJTl2OgsPW9pIqR7dmPWejihkbH5K9dylokyQjPXmV+EWe91QeZJ3xNQc4eLqKULiUv7d8p0O3qJEcQvrWqGQTMvIFkPJhmJXCM5FmUe7nKJ3c+K+NXNT2s5HvgfFlVOVSBCVhJ/2ELQAQIYU8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652166688; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=uMaK2AhqaVebCGxN9OYis3PSMFfTxybpgv6t4CmPEPA=; b=Ma1rHN1fma/UrgwFFIFUN2wk2Fk/HsCnJBHNjjG/gIoiMs61/JTAId9CJXgsIGK6ZqIPj0sM2AmY4OBsQpkwZ7xSzxnWXWiaPWC700zKmwoTF23ydCUTmEh6ng4sShZRBh2HSBVjO7rBZQIViQj1RkArt4/FqWhvjTwTSyX184Y= 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+89638+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 1652166688253246.67380446539505; Tue, 10 May 2022 00:11:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id WCt6YY1788612xXIspumej3a; Tue, 10 May 2022 00:11:27 -0700 X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.6679.1652166681383551366 for ; Tue, 10 May 2022 00:11:27 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10342"; a="268127951" X-IronPort-AV: E=Sophos;i="5.91,213,1647327600"; d="scan'208";a="268127951" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2022 00:11:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,213,1647327600"; d="scan'208";a="696953457" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.158]) by orsmga004.jf.intel.com with ESMTP; 10 May 2022 00:11:24 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Sean Rhodes Subject: [edk2-devel] [PATCH 2/3] UefiPayloadPkg: Add Serial IO device path according to related protocol Date: Tue, 10 May 2022 15:11:10 +0800 Message-Id: <3e4cc390c9e7ffe9204b1564329086e7c3fc45cf.1652166437.git.zhiguang.liu@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhiguang.liu@intel.com X-Gm-Message-State: n7MKYHDeq1pfN6TUiHUZsK8jx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1652166687; bh=/rEnziUvHUcMOG28vc+3nPvhKEs3U9OSWVS9oLt97pM=; h=Cc:Date:From:Reply-To:Subject:To; b=joR/u72MRXZ4GR1+EYFhHniQmbvdKUprXSgd0tguh/jWlH5/xF3rvoUdaSvGEpl0b6P K6hhD6WckqEFbLJpPYopz3VSOBBZ74BUpY1ppvHHYk1UAU9sxELePpYWHS/2GurjTjMig mqX7k3gn85QliHrF6+yS79EtcHIHQpbI+98= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1652166689856100011 Content-Type: text/plain; charset="utf-8" Current code follow some rules to check if the PCI device connected to a serial port device, but some platform or hardware doesn't follow such rule. By locating gEfiSerialIoProtocolGuid protocol, we can find the related device path. Cc: Guo Dong Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Cc: Sean Rhodes Signed-off-by: Zhiguang Liu --- .../PlatformBootManagerLib.inf | 1 + .../PlatformBootManagerLib/PlatformConsole.c | 149 +++++------------- .../PlatformBootManagerLib/PlatformConsole.h | 1 - 3 files changed, 44 insertions(+), 107 deletions(-) diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf index 80390e0d98..acf2880d22 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf @@ -60,6 +60,7 @@ gEfiDxeSmmReadyToLockProtocolGuid gEfiSmmAccess2ProtocolGuid gUniversalPayloadPlatformBootManagerOverrideProtocolGuid + gEfiSerialIoProtocolGuid =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.= c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c index 9887183624..5e1c77d866 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c @@ -47,36 +47,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define gPnpPs2Keyboard \ PNPID_DEVICE_PATH_NODE(0x0303) =20 -#define gUartVendor \ - { \ - { \ - HARDWARE_DEVICE_PATH, \ - HW_VENDOR_DP, \ - { \ - (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \ - (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \ - } \ - }, \ - EDKII_SERIAL_PORT_LIB_VENDOR_GUID \ - } - -#define gUart \ - { \ - { \ - MESSAGING_DEVICE_PATH, \ - MSG_UART_DP, \ - { \ - (UINT8) (sizeof (UART_DEVICE_PATH)), \ - (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \ - } \ - }, \ - 0, \ - 115200, \ - 8, \ - 1, \ - 1 \ - } - #define gPcAnsiTerminal \ { \ { \ @@ -92,9 +62,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode =3D gPnpPs2Keyboard; ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode =3D gPnp16550ComPort; -UART_DEVICE_PATH gUartDeviceNode =3D gUart; VENDOR_DEVICE_PATH gTerminalTypeDeviceNode =3D gPcAnsiTerminal; -VENDOR_DEVICE_PATH gUartDeviceVendorNode =3D gUartVendor; =20 // // Predefined platform root bridge @@ -112,13 +80,11 @@ EFI_DEVICE_PATH_PROTOCOL *gPlatformRootBridges[] =3D { BOOLEAN mDetectDisplayOnly; =20 /** - Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut. + Add IsaKeyboard to ConIn. =20 @param[in] DeviceHandle Handle of the LPC Bridge device. =20 - @retval EFI_SUCCESS Console devices on the LPC bridge have been added to - ConOut, ConIn, and ErrOut. - + @retval EFI_SUCCESS IsaKeyboard on the LPC bridge have been added to Co= nIn. @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing from DeviceHandle. **/ @@ -129,7 +95,6 @@ PrepareLpcBridgeDevicePath ( { EFI_STATUS Status; EFI_DEVICE_PATH_PROTOCOL *DevicePath; - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; =20 DevicePath =3D NULL; Status =3D gBS->HandleProtocol ( @@ -141,26 +106,11 @@ PrepareLpcBridgeDevicePath ( return Status; } =20 - TempDevicePath =3D DevicePath; - // // Register Keyboard // DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gPnpPs2KeyboardDeviceNode); EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL); - - // - // Register COM1 - // - DevicePath =3D TempDevicePath; - DevicePath =3D AppendDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *)NULL, (= EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceVendorNode); - DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gUartDeviceNode); - DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gTerminalTypeDeviceNode); - - EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL); - return EFI_SUCCESS; } =20 @@ -291,43 +241,6 @@ PreparePciVgaDevicePath ( return EFI_SUCCESS; } =20 -/** - Add PCI Serial to ConOut, ConIn, ErrOut. - - @param[in] DeviceHandle - Handle of PciIo protocol. - - @retval EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut. - @retval EFI_STATUS - No PCI Serial device is added. - -**/ -EFI_STATUS -PreparePciSerialDevicePath ( - IN EFI_HANDLE DeviceHandle - ) -{ - EFI_STATUS Status; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - - DevicePath =3D NULL; - Status =3D gBS->HandleProtocol ( - DeviceHandle, - &gEfiDevicePathProtocolGuid, - (VOID *)&DevicePath - ); - if (EFI_ERROR (Status)) { - return Status; - } - - DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gUartDeviceNode); - DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gTerminalTypeDeviceNode); - - EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL); - - return EFI_SUCCESS; -} - /** For every PCI instance execute a callback function. =20 @@ -452,18 +365,6 @@ DetectAndPreparePlatformPciDevicePath ( PrepareLpcBridgeDevicePath (Handle); return EFI_SUCCESS; } - - // - // Here we decide which Serial device to enable in PCI bus - // - if (IS_PCI_16550SERIAL (&Pci)) { - // - // Add them to ConOut, ConIn, ErrOut. - // - DEBUG ((DEBUG_INFO, "Found PCI 16550 SERIAL device\n")); - PreparePciSerialDevicePath (Handle); - return EFI_SUCCESS; - } } =20 // @@ -481,6 +382,41 @@ DetectAndPreparePlatformPciDevicePath ( return Status; } =20 +/** + For every Serial Io instance, add it to ConOut, ConIn, ErrOut. + + @param[in] Handle - The Serial Io device handle + @param[in] Instance - The instance of the SerialIo protocol + @param[in] Context - The context of the callback + + @retval EFI_STATUS - Callback function failed. + +**/ +EFI_STATUS +EFIAPI +AddDevicePathForOneSerialIoInstance ( + IN EFI_HANDLE Handle, + IN VOID *Instance, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + DevicePath =3D NULL; + Status =3D gBS->HandleProtocol ( + Handle, + &gEfiDevicePathProtocolGuid, + (VOID *)&DevicePath + ); + DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOC= OL *)&gTerminalTypeDeviceNode); + + EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL); + EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL); + EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL); + return Status; +} + /** Do platform specific PCI Device check and add them to ConOut, ConIn, Err= Out =20 @@ -505,6 +441,12 @@ DetectAndPreparePlatformPciDevicePaths ( NULL ); =20 + VisitAllInstancesOfProtocol ( + &gEfiSerialIoProtocolGuid, + AddDevicePathForOneSerialIoInstance, + NULL + ); + Status =3D VisitAllInstancesOfProtocol ( &gEfiPciIoProtocolGuid, DetectAndPreparePlatformPciDevicePath, @@ -558,11 +500,6 @@ PlatformConsoleInit ( VOID ) { - gUartDeviceNode.BaudRate =3D PcdGet64 (PcdUartDefaultBaudRate); - gUartDeviceNode.DataBits =3D PcdGet8 (PcdUartDefaultDataBits); - gUartDeviceNode.Parity =3D PcdGet8 (PcdUartDefaultParity); - gUartDeviceNode.StopBits =3D PcdGet8 (PcdUartDefaultStopBits); - ConnectRootBridge (); =20 // diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.= h b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.h index a13f4b8b59..2c7d21cc84 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.h +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.h @@ -21,7 +21,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =20 #define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS= _BRIDGE_ISA_PDECODE, 0) -#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS= _SERIAL, PCI_IF_16550) =20 // // Type definitions --=20 2.32.0.windows.2 -=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 (#89638): https://edk2.groups.io/g/devel/message/89638 Mute This Topic: https://groups.io/mt/91007798/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- From nobody Sun May 19 04:05:41 2024 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+89639+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+89639+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1652166690; cv=none; d=zohomail.com; s=zohoarc; b=f7ucb+vj7T35MxZkW8ZOGkX6oh82zfEyNNOy9q2s913v58/YbLrajES2UxpzC6IDulwxJn92adLE9oBt13Hwjbk8fv2A3jgeIR0KK6yIKB0MhZjh5YWh/uCMhwrmWtPwLadUeYBc51MK0SntCL0N2TAc9mbFCSyxWnjXM4keBHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652166690; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ClMgsiFnhu1GuZoUYWSxi/prqHMB3v/wH3W3c93aeKw=; b=ItSNKc7pyR+le2wFbWPDSh7JJUe2Yelv+hTzPFp8xFk5psvCbuRIBYPCzeX0A3B2trhwooo8JQUpubiyLSLNf7r0qa0dePdIA08LKqVRnIJfBGqe1aLeTxbDHHbPtqiV4NM6JPOhEzL4TRrnUvPfdVr7/CRQBqnHmF4poYbcA1w= 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+89639+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 1652166690821622.8584070164063; Tue, 10 May 2022 00:11:30 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Za4UYY1788612xseRDHkyPu0; Tue, 10 May 2022 00:11:30 -0700 X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.6679.1652166681383551366 for ; Tue, 10 May 2022 00:11:29 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10342"; a="268127965" X-IronPort-AV: E=Sophos;i="5.91,213,1647327600"; d="scan'208";a="268127965" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2022 00:11:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,213,1647327600"; d="scan'208";a="696953493" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.158]) by orsmga004.jf.intel.com with ESMTP; 10 May 2022 00:11:27 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Sean Rhodes Subject: [edk2-devel] [PATCH 3/3] UefiPayloadPkg: Connect all root bridge in PlatformBootManagerBeforeConsole Date: Tue, 10 May 2022 15:11:11 +0800 Message-Id: <5090af6605c3ae9e1ea3c6ebd2e1e5f6c870dac0.1652166437.git.zhiguang.liu@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhiguang.liu@intel.com X-Gm-Message-State: tuaNpm65cbmgEak8LEK2dsnOx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1652166690; bh=vtddZq3T7Zeh4+dN/b1VVm4gikWovZBdezefFCa3YIo=; h=Cc:Date:From:Reply-To:Subject:To; b=U/j5jKAz5JP6+AaaBVWsDKWjqOzRoYqRCJJvJr5LetUxQZuLpK/Ihxv/0CT6nB9cE3I 5phOuYbLfYiVYP5L74x9UNRd2/umoSs4/zdfszxsvVbBCNhAxLPyRpqoy462HAd+2wa/p ICQtz98KBdMlyLVuLjdye16w9Pk7njHHvaM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1652166691853100013 Content-Type: text/plain; charset="utf-8" Some ConIn or ConOut device may not in the first root bridge, so connect all root bridge before detect ConIn and ConOut device. Cc: Guo Dong Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Cc: Sean Rhodes Signed-off-by: Zhiguang Liu --- .../PlatformBootManagerLib.inf | 1 + .../PlatformBootManagerLib/PlatformConsole.c | 52 ++++++------------- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf index acf2880d22..9f58c460cd 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf @@ -61,6 +61,7 @@ gEfiSmmAccess2ProtocolGuid gUniversalPayloadPlatformBootManagerOverrideProtocolGuid gEfiSerialIoProtocolGuid + gEfiPciRootBridgeIoProtocolGuid =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.= c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c index 5e1c77d866..e4a9f5f0f9 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c @@ -38,9 +38,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent 0 \ } =20 -#define gPciRootBridge \ - PNPID_DEVICE_PATH_NODE(0x0A03) - #define gPnp16550ComPort \ PNPID_DEVICE_PATH_NODE(0x0501) =20 @@ -64,19 +61,6 @@ ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode =3D gPn= pPs2Keyboard; ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode =3D gPnp16550ComPort; VENDOR_DEVICE_PATH gTerminalTypeDeviceNode =3D gPcAnsiTerminal; =20 -// -// Predefined platform root bridge -// -PLATFORM_ROOT_BRIDGE_DEVICE_PATH gPlatformRootBridge0 =3D { - gPciRootBridge, - gEndEntire -}; - -EFI_DEVICE_PATH_PROTOCOL *gPlatformRootBridges[] =3D { - (EFI_DEVICE_PATH_PROTOCOL *)&gPlatformRootBridge0, - NULL -}; - BOOLEAN mDetectDisplayOnly; =20 /** @@ -456,32 +440,26 @@ DetectAndPreparePlatformPciDevicePaths ( } =20 /** - The function will connect root bridge + The function will connect one root bridge =20 - @return EFI_SUCCESS Connect RootBridge successfully. + @param[in] Handle - The root bridge handle + @param[in] Instance - The instance of the root bridge + @param[in] Context - The context of the callback + + @return EFI_SUCCESS Connect RootBridge successfully. =20 **/ EFI_STATUS -ConnectRootBridge ( - VOID +EFIAPI +ConnectOneRootBridge ( + IN EFI_HANDLE Handle, + IN VOID *Instance, + IN VOID *Context ) { EFI_STATUS Status; - EFI_HANDLE RootHandle; - - // - // Make all the PCI_IO protocols on PCI Seg 0 show up - // - Status =3D gBS->LocateDevicePath ( - &gEfiDevicePathProtocolGuid, - &gPlatformRootBridges[0], - &RootHandle - ); - if (EFI_ERROR (Status)) { - return Status; - } =20 - Status =3D gBS->ConnectController (RootHandle, NULL, NULL, FALSE); + Status =3D gBS->ConnectController (Handle, NULL, NULL, FALSE); if (EFI_ERROR (Status)) { return Status; } @@ -500,7 +478,11 @@ PlatformConsoleInit ( VOID ) { - ConnectRootBridge (); + VisitAllInstancesOfProtocol ( + &gEfiPciRootBridgeIoProtocolGuid, + ConnectOneRootBridge, + NULL + ); =20 // // Do platform specific PCI Device check and add them to ConOut, ConIn, = ErrOut --=20 2.32.0.windows.2 -=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 (#89639): https://edk2.groups.io/g/devel/message/89639 Mute This Topic: https://groups.io/mt/91007799/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-