public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1 0/1] UefiPayloadPkg: Scan for PCI devices
@ 2020-07-16 11:10 Marcello Sylvester Bauer
  2020-07-16 11:10 ` [PATCH v1 1/1] UefiPayloadPkg: Scan for PCI devices after end of DXE Marcello Sylvester Bauer
  0 siblings, 1 reply; 3+ messages in thread
From: Marcello Sylvester Bauer @ 2020-07-16 11:10 UTC (permalink / raw)
  To: devel

Scan for PCI devices after end of DXE.
This allows EFI applications to iterate over those devices.
An example is iPXE.efi that requires those devices to be present.

Branch: https://github.com/9elements/edk2-1/tree/UefiPayloadPkg-PCI_scan
PR: https://github.com/tianocore/edk2/pull/800

Patrick Rudolph (1):
  UefiPayloadPkg: Scan for PCI devices after end of DXE

 UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  1 +
 UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c      | 76 ++++++++++++++++++++
 2 files changed, 77 insertions(+)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v1 1/1] UefiPayloadPkg: Scan for PCI devices after end of DXE
  2020-07-16 11:10 [PATCH v1 0/1] UefiPayloadPkg: Scan for PCI devices Marcello Sylvester Bauer
@ 2020-07-16 11:10 ` Marcello Sylvester Bauer
  2020-09-08 21:27   ` [edk2-devel] " Guo Dong
  0 siblings, 1 reply; 3+ messages in thread
From: Marcello Sylvester Bauer @ 2020-07-16 11:10 UTC (permalink / raw)
  To: devel
  Cc: Patrick Rudolph, Christian Walter, Maurice Ma, Nate DeSimone,
	Star Zeng

From: Patrick Rudolph <patrick.rudolph@9elements.com>

This allows EFI applications to iterate over those devices.
An example is iPXE.efi that requires those devices to be present.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Marcello Sylvester Bauer <marcello.bauer@9elements.com>
Cc: Patrick Rudolph <patrick.rudolph@9elements.com>
Cc: Christian Walter <christian.walter@9elements.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
---
 UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  1 +
 UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c      | 76 ++++++++++++++++++++
 2 files changed, 77 insertions(+)

diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 1f5a0bcad038..a7c6bc2d6440 100644
--- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -57,6 +57,7 @@ [Protocols]
   gEfiBootLogoProtocolGuid        ## CONSUMES
   gEfiDxeSmmReadyToLockProtocolGuid
   gEfiSmmAccess2ProtocolGuid
+  gEfiPciRootBridgeIoProtocolGuid               ## CONSUMES
 
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index c5c6af0abcb2..ff7df53231ce 100644
--- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
@@ -138,6 +138,79 @@ PlatformRegisterFvBootOption (
   }
 }
 
+STATIC
+EFI_STATUS
+VisitAllInstancesOfProtocol (
+  IN EFI_GUID                    *Id,
+  IN PROTOCOL_INSTANCE_CALLBACK  CallBackFunction,
+  IN VOID                        *Context
+  )
+{
+  EFI_STATUS                Status;
+  UINTN                     HandleCount;
+  EFI_HANDLE                *HandleBuffer;
+  UINTN                     Index;
+  VOID                      *Instance;
+
+  //
+  // Start to check all the PciIo to find all possible device
+  //
+  HandleCount = 0;
+  HandleBuffer = NULL;
+  Status = gBS->LocateHandleBuffer (
+                  ByProtocol,
+                  Id,
+                  NULL,
+                  &HandleCount,
+                  &HandleBuffer
+                  );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  for (Index = 0; Index < HandleCount; Index++) {
+    Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);
+    if (EFI_ERROR (Status)) {
+      continue;
+    }
+
+    Status = (*CallBackFunction) (
+               HandleBuffer[Index],
+               Instance,
+               Context
+               );
+  }
+
+  gBS->FreePool (HandleBuffer);
+
+  return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+EFIAPI
+ConnectRootBridge (
+  IN EFI_HANDLE  RootBridgeHandle,
+  IN VOID        *Instance,
+  IN VOID        *Context
+  )
+{
+  EFI_STATUS Status;
+
+  //
+  // Make the PCI bus driver connect the root bridge, non-recursively. This
+  // will produce a number of child handles with PciIo on them.
+  //
+  Status = gBS->ConnectController (
+                  RootBridgeHandle, // ControllerHandle
+                  NULL,             // DriverImageHandle
+                  NULL,             // RemainingDevicePath -- produce all
+                                    //   children
+                  FALSE             // Recursive
+                  );
+  return Status;
+}
+
 /**
   Do the platform specific action before the console is connected.
 
@@ -157,6 +230,9 @@ PlatformBootManagerBeforeConsole (
   EFI_INPUT_KEY                Down;
   EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
 
+  VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid,
+    ConnectRootBridge, NULL);
+
   PlatformConsoleInit ();
 
   //
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [PATCH v1 1/1] UefiPayloadPkg: Scan for PCI devices after end of DXE
  2020-07-16 11:10 ` [PATCH v1 1/1] UefiPayloadPkg: Scan for PCI devices after end of DXE Marcello Sylvester Bauer
@ 2020-09-08 21:27   ` Guo Dong
  0 siblings, 0 replies; 3+ messages in thread
From: Guo Dong @ 2020-09-08 21:27 UTC (permalink / raw)
  To: devel@edk2.groups.io, marcello.bauer@9elements.com
  Cc: Patrick Rudolph, Christian Walter, Ma, Maurice,
	Desimone, Nathaniel L, Zeng, Star


Please CC all UefiPayloadPkg maintainers or the patch might be filtered.

Only trusted console devices would be connected in order to support TCG physical presence before ReadyToLock.  Instead of connect all PCI devices in PlatformBootManagerBeforeConsole (), please check why PlatformBootManagerAfterConsole() could not meet the requirement since all other PCI devices are expected to be connected using EfiBootManagerConnectAll ().

Thanks,
Guo

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Marcello
> Sylvester Bauer
> Sent: Thursday, July 16, 2020 4:10 AM
> To: devel@edk2.groups.io
> Cc: Patrick Rudolph <patrick.rudolph@9elements.com>; Christian Walter
> <christian.walter@9elements.com>; Ma, Maurice <maurice.ma@intel.com>;
> Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Zeng, Star
> <star.zeng@intel.com>
> Subject: [edk2-devel] [PATCH v1 1/1] UefiPayloadPkg: Scan for PCI devices after
> end of DXE
> 
> From: Patrick Rudolph <patrick.rudolph@9elements.com>
> 
> This allows EFI applications to iterate over those devices.
> An example is iPXE.efi that requires those devices to be present.
> 
> Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
> Signed-off-by: Marcello Sylvester Bauer <marcello.bauer@9elements.com>
> Cc: Patrick Rudolph <patrick.rudolph@9elements.com>
> Cc: Christian Walter <christian.walter@9elements.com>
> Cc: Maurice Ma <maurice.ma@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> ---
> 
> UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> |  1 +
>  UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> | 76 ++++++++++++++++++++
>  2 files changed, 77 insertions(+)
> 
> diff --git
> a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.i
> nf
> b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.i
> nf
> index 1f5a0bcad038..a7c6bc2d6440 100644
> ---
> a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.i
> nf
> +++
> b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.i
> nf
> @@ -57,6 +57,7 @@ [Protocols]
>    gEfiBootLogoProtocolGuid        ## CONSUMES
> 
>    gEfiDxeSmmReadyToLockProtocolGuid
> 
>    gEfiSmmAccess2ProtocolGuid
> 
> +  gEfiPciRootBridgeIoProtocolGuid               ## CONSUMES
> 
> 
> 
>  [Pcd]
> 
>    gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
> 
> diff --git
> a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> index c5c6af0abcb2..ff7df53231ce 100644
> ---
> a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> +++
> b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> @@ -138,6 +138,79 @@ PlatformRegisterFvBootOption (
>    }
> 
>  }
> 
> 
> 
> +STATIC
> 
> +EFI_STATUS
> 
> +VisitAllInstancesOfProtocol (
> 
> +  IN EFI_GUID                    *Id,
> 
> +  IN PROTOCOL_INSTANCE_CALLBACK  CallBackFunction,
> 
> +  IN VOID                        *Context
> 
> +  )
> 
> +{
> 
> +  EFI_STATUS                Status;
> 
> +  UINTN                     HandleCount;
> 
> +  EFI_HANDLE                *HandleBuffer;
> 
> +  UINTN                     Index;
> 
> +  VOID                      *Instance;
> 
> +
> 
> +  //
> 
> +  // Start to check all the PciIo to find all possible device
> 
> +  //
> 
> +  HandleCount = 0;
> 
> +  HandleBuffer = NULL;
> 
> +  Status = gBS->LocateHandleBuffer (
> 
> +                  ByProtocol,
> 
> +                  Id,
> 
> +                  NULL,
> 
> +                  &HandleCount,
> 
> +                  &HandleBuffer
> 
> +                  );
> 
> +  if (EFI_ERROR (Status)) {
> 
> +    return Status;
> 
> +  }
> 
> +
> 
> +  for (Index = 0; Index < HandleCount; Index++) {
> 
> +    Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);
> 
> +    if (EFI_ERROR (Status)) {
> 
> +      continue;
> 
> +    }
> 
> +
> 
> +    Status = (*CallBackFunction) (
> 
> +               HandleBuffer[Index],
> 
> +               Instance,
> 
> +               Context
> 
> +               );
> 
> +  }
> 
> +
> 
> +  gBS->FreePool (HandleBuffer);
> 
> +
> 
> +  return EFI_SUCCESS;
> 
> +}
> 
> +
> 
> +STATIC
> 
> +EFI_STATUS
> 
> +EFIAPI
> 
> +ConnectRootBridge (
> 
> +  IN EFI_HANDLE  RootBridgeHandle,
> 
> +  IN VOID        *Instance,
> 
> +  IN VOID        *Context
> 
> +  )
> 
> +{
> 
> +  EFI_STATUS Status;
> 
> +
> 
> +  //
> 
> +  // Make the PCI bus driver connect the root bridge, non-recursively. This
> 
> +  // will produce a number of child handles with PciIo on them.
> 
> +  //
> 
> +  Status = gBS->ConnectController (
> 
> +                  RootBridgeHandle, // ControllerHandle
> 
> +                  NULL,             // DriverImageHandle
> 
> +                  NULL,             // RemainingDevicePath -- produce all
> 
> +                                    //   children
> 
> +                  FALSE             // Recursive
> 
> +                  );
> 
> +  return Status;
> 
> +}
> 
> +
> 
>  /**
> 
>    Do the platform specific action before the console is connected.
> 
> 
> 
> @@ -157,6 +230,9 @@ PlatformBootManagerBeforeConsole (
>    EFI_INPUT_KEY                Down;
> 
>    EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
> 
> 
> 
> +  VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid,
> 
> +    ConnectRootBridge, NULL);
> 
> +
> 
>    PlatformConsoleInit ();
> 
> 
> 
>    //
> 
> --
> 2.27.0
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> 
> View/Reply Online (#62679): https://edk2.groups.io/g/devel/message/62679
> Mute This Topic: https://groups.io/mt/75539006/1781375
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub  [guo.dong@intel.com]
> -=-=-=-=-=-=


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-08 21:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-16 11:10 [PATCH v1 0/1] UefiPayloadPkg: Scan for PCI devices Marcello Sylvester Bauer
2020-07-16 11:10 ` [PATCH v1 1/1] UefiPayloadPkg: Scan for PCI devices after end of DXE Marcello Sylvester Bauer
2020-09-08 21:27   ` [edk2-devel] " Guo Dong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox