From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=RgKWk7DV; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: zhiguang.liu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652166683; x=1683702683; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=d8ScWBn87tjn+VHYx56oN1u1SUMhcVrbqOM0P8wDpuE=; b=RgKWk7DVgzBwdGhlThIgT4wdhnKlhwsyVJGUJShVv4k0Tl3uIt/HizRz +c/zQojfCOeZ40lrjBemHis1690b3Vc+DunDChF1KhkwW+yZyXcy/q0ED imFx/QbybeeM62GZsu5n61qXkU5E1efw2RBjvPm4ZLjxDrSt85F/2PHgO 5cSVLIfVblYBuzM6B6AlnWV2OTCbgmw6vjb9I1CCb3NAVkE8crsBZCS/c CbQ0roYiPMq5o/cbmIFr+Y+CUzO4ZGmm95FVhqsIVTBowxbrE1U5CowE6 DAGnwT/8pUkyP4CxU70vLg1z13JPav8V2WcfFDk91llv3UUShfmjboYY8 Q==; 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" 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" 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: [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> X-Mailer: git-send-email 2.32.0.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 ( }=0D =0D /**=0D - For every PCI instance execute a callback function.=0D + Do platform specific PCI Device check and add them to=0D + ConOut, ConIn, ErrOut.=0D =0D - @param[in] Handle - The PCI device handle=0D - @param[in] Instance - The instance of the PciIo protocol=0D - @param[in] Context - The context of the callback=0D + @param[in] Handle - Handle of PCI device instance=0D + @param[in] Instance - The instance of PCI device=0D + @param[in] Context - The context of the callback=0D =0D - @retval EFI_STATUS - Callback function failed.=0D + @retval EFI_SUCCESS - PCI Device check and Console variable update succe= ssfully.=0D + @retval EFI_STATUS - PCI Device check or Console variable update fail.=0D =0D **/=0D EFI_STATUS=0D EFIAPI=0D -VisitingAPciInstance (=0D +DetectAndPreparePlatformPciDevicePath (=0D IN EFI_HANDLE Handle,=0D IN VOID *Instance,=0D IN VOID *Context=0D @@ -424,56 +426,6 @@ VisitingAPciInstance ( return Status;=0D }=0D =0D - return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN)Context)(=0D - Handle,=0D - PciIo,=0D - &Pci=0D - );=0D -}=0D -=0D -/**=0D - For every PCI instance execute a callback function.=0D -=0D - @param[in] CallBackFunction - Callback function pointer=0D -=0D - @retval EFI_STATUS - Callback function failed.=0D -=0D -**/=0D -EFI_STATUS=0D -EFIAPI=0D -VisitAllPciInstances (=0D - IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction=0D - )=0D -{=0D - return VisitAllInstancesOfProtocol (=0D - &gEfiPciIoProtocolGuid,=0D - VisitingAPciInstance,=0D - (VOID *)(UINTN)CallBackFunction=0D - );=0D -}=0D -=0D -/**=0D - Do platform specific PCI Device check and add them to=0D - ConOut, ConIn, ErrOut.=0D -=0D - @param[in] Handle - Handle of PCI device instance=0D - @param[in] PciIo - PCI IO protocol instance=0D - @param[in] Pci - PCI Header register block=0D -=0D - @retval EFI_SUCCESS - PCI Device check and Console variable update succe= ssfully.=0D - @retval EFI_STATUS - PCI Device check or Console variable update fail.=0D -=0D -**/=0D -EFI_STATUS=0D -EFIAPI=0D -DetectAndPreparePlatformPciDevicePath (=0D - IN EFI_HANDLE Handle,=0D - IN EFI_PCI_IO_PROTOCOL *PciIo,=0D - IN PCI_TYPE00 *Pci=0D - )=0D -{=0D - EFI_STATUS Status;=0D -=0D Status =3D PciIo->Attributes (=0D PciIo,=0D EfiPciIoAttributeOperationEnable,=0D @@ -486,9 +438,9 @@ DetectAndPreparePlatformPciDevicePath ( //=0D // Here we decide whether it is LPC Bridge=0D //=0D - if ((IS_PCI_LPC (Pci)) ||=0D - ((IS_PCI_ISA_PDECODE (Pci)) &&=0D - (Pci->Hdr.VendorId =3D=3D 0x8086)=0D + if ((IS_PCI_LPC (&Pci)) ||=0D + ((IS_PCI_ISA_PDECODE (&Pci)) &&=0D + (Pci.Hdr.VendorId =3D=3D 0x8086)=0D )=0D )=0D {=0D @@ -504,7 +456,7 @@ DetectAndPreparePlatformPciDevicePath ( //=0D // Here we decide which Serial device to enable in PCI bus=0D //=0D - if (IS_PCI_16550SERIAL (Pci)) {=0D + if (IS_PCI_16550SERIAL (&Pci)) {=0D //=0D // Add them to ConOut, ConIn, ErrOut.=0D //=0D @@ -517,7 +469,7 @@ DetectAndPreparePlatformPciDevicePath ( //=0D // Enable all display devices=0D //=0D - if (IS_PCI_DISPLAY (Pci)) {=0D + if (IS_PCI_DISPLAY (&Pci)) {=0D //=0D // Add them to ConOut.=0D //=0D @@ -543,6 +495,8 @@ DetectAndPreparePlatformPciDevicePaths ( BOOLEAN DetectDisplayOnly=0D )=0D {=0D + EFI_STATUS Status;=0D +=0D mDetectDisplayOnly =3D DetectDisplayOnly;=0D =0D EfiBootManagerUpdateConsoleVariable (=0D @@ -551,7 +505,12 @@ DetectAndPreparePlatformPciDevicePaths ( NULL=0D );=0D =0D - return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);=0D + Status =3D VisitAllInstancesOfProtocol (=0D + &gEfiPciIoProtocolGuid,=0D + DetectAndPreparePlatformPciDevicePath,=0D + NULL=0D + );=0D + return Status;=0D }=0D =0D /**=0D --=20 2.32.0.windows.2