From nobody Sat Apr 27 04:41:47 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+89703+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+89703+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1652352919; cv=none; d=zohomail.com; s=zohoarc; b=XO+Y96XgT5JQI2DjSWFhHAkwcp4sbvJ/HTwa6gZ2mA+oTO27+HjO/drZfdcEfnsmgw05M8Z83Omt5hXgljSYF82A3nZQmztzaQHdfVNlhl0SfXmM9OXkM4XoidvVVO90YyAPMeXUZw0VNnZx6CkjCstWzgAVywqJpbX3KTwm1i0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652352919; 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=kNRcGWPbHTEa7RIxa7vS5AB7n8ZGtV8YbReBr8zX9ZU=; b=IHE01RVtXEVVBU5OrFIo8UdhYTGr2vls8TmH8DL97HwYNa5emFsimhbXXCbMVKPJLVav6d+PzxKPfDQreWW+D686LMxCW8nqnZjYUtY13ahf+eb0yvGOFFAOrv54/c0PBtZgSNUpvAPP6SoGmcmJkbIZek1G+mRHK9v7RHk2eJw= 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+89703+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 16523529195313.7464746992606024; Thu, 12 May 2022 03:55:19 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id So4QYY1788612xxg8KfBKsKA; Thu, 12 May 2022 03:55:18 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web08.2661.1652352917194448306 for ; Thu, 12 May 2022 03:55:18 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10344"; a="270094638" X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="270094638" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 03:55:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="566627450" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.158]) by orsmga007.jf.intel.com with ESMTP; 12 May 2022 03:55:14 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Sean Rhodes Subject: [edk2-devel] [PATCH v2 1/3] UefiPayloadPkg: Simplify code logic Date: Thu, 12 May 2022 18:54:57 +0800 Message-Id: <395134d6b7eae24441d404aa3e10ab391afcd049.1652351830.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: dyvRlIN6ISUmsTsd5eSM6oH1x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1652352918; bh=3ZKEOv0tmKEDhGymjwnCI/bjYSOB5AshDlOazzXj9Qw=; h=Cc:Date:From:Reply-To:Subject:To; b=RoToC5GOfvFMLurQw2oUg2meW43S2pMI1mMfnd+rFuhUw/h5g3V0lQne+Wz3/2Jj/NF J+Sx3mihYdWSf9ISJ7ZWQNF3vSVz/by3hv89SOreyd3Z0aozqMNVrTwCG+bZ9xeVNaDro fzWNxpBm3LdUPLw0rEIUhfJI7Sj9c0O+bfY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1652352920445100001 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, and unused parameters. Change the PROTOCOL_INSTANCE_CALLBACK to SIMPLE_PROTOCOL_INSTANCE_CALLBACK because the former is also defined in OvmfPkg. Rename it to avoid confusion. Cc: Guo Dong Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Cc: Sean Rhodes Signed-off-by: Zhiguang Liu Reviewed-by: Guo Dong --- .../PlatformBootManagerLib/PlatformConsole.c | 93 +++++-------------- .../PlatformBootManagerLib/PlatformConsole.h | 5 +- 2 files changed, 25 insertions(+), 73 deletions(-) diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.= c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c index bfaf89e74c..75aafebccd 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.c @@ -333,7 +333,6 @@ PreparePciSerialDevicePath ( =20 @param[in] Id - The protocol GUID for callback @param[in] CallBackFunction - The callback function - @param[in] Context - The context of the callback =20 @retval EFI_STATUS - Callback function failed. =20 @@ -341,9 +340,8 @@ PreparePciSerialDevicePath ( EFI_STATUS EFIAPI VisitAllInstancesOfProtocol ( - IN EFI_GUID *Id, - IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction, - IN VOID *Context + IN EFI_GUID *Id, + IN SIMPLE_PROTOCOL_INSTANCE_CALLBACK CallBackFunction ) { EFI_STATUS Status; @@ -376,8 +374,7 @@ VisitAllInstancesOfProtocol ( =20 Status =3D (*CallBackFunction)( HandleBuffer[Index], - Instance, - Context + Instance ); } =20 @@ -387,21 +384,21 @@ 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 =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 + IN VOID *Instance ) { EFI_STATUS Status; @@ -424,56 +421,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 +433,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 +451,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 +464,7 @@ DetectAndPreparePlatformPciDevicePath ( // // Enable all display devices // - if (IS_PCI_DISPLAY (Pci)) { + if (IS_PCI_DISPLAY (&Pci)) { // // Add them to ConOut. // @@ -543,6 +490,8 @@ DetectAndPreparePlatformPciDevicePaths ( BOOLEAN DetectDisplayOnly ) { + EFI_STATUS Status; + mDetectDisplayOnly =3D DetectDisplayOnly; =20 EfiBootManagerUpdateConsoleVariable ( @@ -551,7 +500,11 @@ DetectAndPreparePlatformPciDevicePaths ( NULL ); =20 - return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath); + Status =3D VisitAllInstancesOfProtocol ( + &gEfiPciIoProtocolGuid, + DetectAndPreparePlatformPciDevicePath + ); + return Status; } =20 /** diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.= h b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.h index a13f4b8b59..3713c21c45 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.h +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformConsole.h @@ -37,10 +37,9 @@ typedef struct { =20 typedef EFI_STATUS -(EFIAPI *PROTOCOL_INSTANCE_CALLBACK)( +(EFIAPI *SIMPLE_PROTOCOL_INSTANCE_CALLBACK)( IN EFI_HANDLE Handle, - IN VOID *Instance, - IN VOID *Context + IN VOID *Instance ); =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 (#89703): https://edk2.groups.io/g/devel/message/89703 Mute This Topic: https://groups.io/mt/91055222/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 Sat Apr 27 04:41:47 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+89704+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+89704+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1652352920; cv=none; d=zohomail.com; s=zohoarc; b=MxNs/QOQza7XVWiROdnC5cBpWKu3XTMFoWuStXl2d3loM/5sG5s4A3YB10K5n3tdLSYqf4d/cE2vg7g7gUlIFWm+ztW5yh2J0LGfbGSwf/D9XmAogyt0tWFDOAmMDrf8gRrESWwl7xv83sf5xohkflMrD+fx0/LoqBDLycUIt9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652352920; 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=AyCp4tLBjNYNjy0Yrji8EQwLqbRK6hvwVCMOE2O3hvY=; b=iNP5h4V/Ibe0M3JexLrWu8dh+LhBScqLd+MPwQKb/lNWcdhKnIGGtBFL0AkJ/KpNplGxzn1dXdY44s4iiY8UUE5IRoNUmU8oZW0+7m6nSbraCXK257lntxxbhfsfxl1jxruidomIVL08IT3YqInLnX1bJwDXzaccQcQnRkW0YN8= 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+89704+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 1652352920735908.4000797105916; Thu, 12 May 2022 03:55:20 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vh5fYY1788612xka6UO1xIGV; Thu, 12 May 2022 03:55:20 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web08.2661.1652352917194448306 for ; Thu, 12 May 2022 03:55:19 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10344"; a="270094643" X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="270094643" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 03:55:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="566627458" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.158]) by orsmga007.jf.intel.com with ESMTP; 12 May 2022 03:55:16 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Sean Rhodes Subject: [edk2-devel] [PATCH v2 2/3] UefiPayloadPkg: Add Serial IO device path according to related protocol Date: Thu, 12 May 2022 18:54:58 +0800 Message-Id: <03aeca65da52907434e14d1f9fbd1c0651874257.1652351830.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: YOm7gFW6v86ED4KkKz022Vq3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1652352920; bh=kexVWa1N2n63WcrWUCx2Ea9CYi+kGSKrriLkq+gyrP8=; h=Cc:Date:From:Reply-To:Subject:To; b=HTsmwBp1bQnjQOkEmtLIk5SfkxjKlrm99qfx0gSjsAqVYU3OkP1UOyP7NiiXBbIoPvD SDgKXi6BCR9obtYs+bCS9SgyaYlC/K5vMK8sU+6oIbxX3VHNzw0uXFDfch6wYQaizn8jp ps6a0Wa7m1BEWgf+8BGC2ZZTrEEyaeX6IsA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1652352922496100008 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 Reviewed-by: Guo Dong --- .../PlatformBootManagerLib.inf | 1 + .../PlatformBootManagerLib/PlatformConsole.c | 146 +++++------------- .../PlatformBootManagerLib/PlatformConsole.h | 1 - 3 files changed, 41 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 75aafebccd..5aece6636f 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 @@ -447,18 +360,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 // @@ -476,6 +377,39 @@ 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 + + @retval EFI_STATUS - Callback function failed. + +**/ +EFI_STATUS +EFIAPI +AddDevicePathForOneSerialIoInstance ( + IN EFI_HANDLE Handle, + IN VOID *Instance + ) +{ + 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 @@ -500,6 +434,11 @@ DetectAndPreparePlatformPciDevicePaths ( NULL ); =20 + VisitAllInstancesOfProtocol ( + &gEfiSerialIoProtocolGuid, + AddDevicePathForOneSerialIoInstance + ); + Status =3D VisitAllInstancesOfProtocol ( &gEfiPciIoProtocolGuid, DetectAndPreparePlatformPciDevicePath @@ -552,11 +491,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 3713c21c45..6889c897ad 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 (#89704): https://edk2.groups.io/g/devel/message/89704 Mute This Topic: https://groups.io/mt/91055223/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 Sat Apr 27 04:41:47 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+89705+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+89705+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1652352922; cv=none; d=zohomail.com; s=zohoarc; b=kOb8VQ45IeLpRw9RjsheaAYI/y1Yw5lIj1tAWyu2B48WBrFEr6xZNvxgcobYRRX+gsOi1lPLWb6ABCFzPDs2qjbjeAjmGEVmI3b0qLESHdcMsFO9pR1oIefbPUF4ain3940dmvOtrSy3rKT4o6lq+kGR4CMY75nHgJxUptqWcqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652352922; 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=KVt1+JojcPEDm8oaJAnftJwcWNKs5rPpdPqi1Fy3buU=; b=Kh2WX1vmJr49WX8f7JAkQ/QbxB4oBMMaW00y4zjn0pPH3BiePTM1Dsd6yeDtBB0vMy+i7PIKi8Z3btw2i2/QZxh6CJ/qsZHR8vhSemasylvhjto2o6yfb5GhwxMzQVDOOdXm1KYD8kLLM+vH11nTBK/ZvDGHg4zIjeF/HUBV/rg= 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+89705+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 1652352922003227.14124033393432; Thu, 12 May 2022 03:55:22 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id HxIyYY1788612xCbJyApGDq2; Thu, 12 May 2022 03:55:21 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web08.2661.1652352917194448306 for ; Thu, 12 May 2022 03:55:21 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10344"; a="270094666" X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="270094666" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 03:55:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="566627463" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.158]) by orsmga007.jf.intel.com with ESMTP; 12 May 2022 03:55:18 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Sean Rhodes Subject: [edk2-devel] [PATCH v2 3/3] UefiPayloadPkg: Connect all root bridge in PlatformBootManagerBeforeConsole Date: Thu, 12 May 2022 18:54:59 +0800 Message-Id: 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: 6B7v5MRZVS3upTEV2NUvc4v4x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1652352921; bh=9cXnJMyKaoqneR4FyjltIzxKfHypFTwLAcuve2umTuU=; h=Cc:Date:From:Reply-To:Subject:To; b=j05zym/kf5UUlNeJTnTJuueU9a3OSKsAAcmr/2KLVY0oTn0q3bFAL/Nwij7sORboYPV qJLHu3AECbiKdjoPkKJjc3A/dTEtGgspc7yDfacqL84SBy5P2KFUgFJZb62qDRSkYvcrb W94eKnFbzOyylgir+1kqJeZFhIg8+JCoHww= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1652352922472100007 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 Reviewed-by: Guo Dong --- .../PlatformBootManagerLib.inf | 1 + .../PlatformBootManagerLib/PlatformConsole.c | 49 ++++++------------- 2 files changed, 15 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 5aece6636f..e92d12e991 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 /** @@ -447,32 +431,24 @@ 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 + + @return EFI_SUCCESS Connect RootBridge successfully. =20 **/ EFI_STATUS -ConnectRootBridge ( - VOID +EFIAPI +ConnectOneRootBridge ( + IN EFI_HANDLE Handle, + IN VOID *Instance ) { EFI_STATUS Status; - EFI_HANDLE RootHandle; =20 - // - // 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; - } - - Status =3D gBS->ConnectController (RootHandle, NULL, NULL, FALSE); + Status =3D gBS->ConnectController (Handle, NULL, NULL, FALSE); if (EFI_ERROR (Status)) { return Status; } @@ -491,7 +467,10 @@ PlatformConsoleInit ( VOID ) { - ConnectRootBridge (); + VisitAllInstancesOfProtocol ( + &gEfiPciRootBridgeIoProtocolGuid, + ConnectOneRootBridge + ); =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 (#89705): https://edk2.groups.io/g/devel/message/89705 Mute This Topic: https://groups.io/mt/91055224/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-