From: "Zhiguang Liu" <zhiguang.liu@intel.com>
To: devel@edk2.groups.io
Cc: Guo Dong <guo.dong@intel.com>, Ray Ni <ray.ni@intel.com>,
Maurice Ma <maurice.ma@intel.com>,
Benjamin You <benjamin.you@intel.com>,
Sean Rhodes <sean@starlabs.systems>
Subject: [PATCH 1/3] UefiPayloadPkg: Simplify code logic
Date: Tue, 10 May 2022 15:11:09 +0800 [thread overview]
Message-ID: <2ce68964b1dc683b505e765cdf96b262f66f051c.1652166437.git.zhiguang.liu@intel.com> (raw)
In-Reply-To: <cover.1652166437.git.zhiguang.liu@intel.com>
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 <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
.../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 (
}
/**
- For every PCI instance execute a callback function.
+ Do platform specific PCI Device check and add them to
+ ConOut, ConIn, ErrOut.
- @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
- @retval EFI_STATUS - Callback function failed.
+ @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.
+ @retval EFI_STATUS - PCI Device check or Console variable update fail.
**/
EFI_STATUS
EFIAPI
-VisitingAPciInstance (
+DetectAndPreparePlatformPciDevicePath (
IN EFI_HANDLE Handle,
IN VOID *Instance,
IN VOID *Context
@@ -424,56 +426,6 @@ VisitingAPciInstance (
return Status;
}
- 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 successfully.
- @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 = 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 == 0x8086)
+ if ((IS_PCI_LPC (&Pci)) ||
+ ((IS_PCI_ISA_PDECODE (&Pci)) &&
+ (Pci.Hdr.VendorId == 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 = DetectDisplayOnly;
EfiBootManagerUpdateConsoleVariable (
@@ -551,7 +505,12 @@ DetectAndPreparePlatformPciDevicePaths (
NULL
);
- return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
+ Status = VisitAllInstancesOfProtocol (
+ &gEfiPciIoProtocolGuid,
+ DetectAndPreparePlatformPciDevicePath,
+ NULL
+ );
+ return Status;
}
/**
--
2.32.0.windows.2
next prev parent reply other threads:[~2022-05-10 7:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-10 7:11 [PATCH 0/3] UefiPayloadPkg: Enhance the logic to add ConIn and ConOut Zhiguang Liu
2022-05-10 7:11 ` Zhiguang Liu [this message]
2022-05-10 7:39 ` [PATCH 1/3] UefiPayloadPkg: Simplify code logic Ni, Ray
2022-05-11 1:48 ` Zhiguang Liu
2022-05-10 7:11 ` [PATCH 2/3] UefiPayloadPkg: Add Serial IO device path according to related protocol Zhiguang Liu
2022-05-10 7:11 ` [PATCH 3/3] UefiPayloadPkg: Connect all root bridge in PlatformBootManagerBeforeConsole Zhiguang Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2ce68964b1dc683b505e765cdf96b262f66f051c.1652166437.git.zhiguang.liu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox