From nobody Sat Feb 7 05:53:12 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+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-