public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/1] OvmfPkg/PlatformBootManagerLib: setup virtio-mmio devices.
@ 2023-07-06 15:31 Gerd Hoffmann
  2023-09-07 13:51 ` [edk2-devel] " Ard Biesheuvel
  0 siblings, 1 reply; 2+ messages in thread
From: Gerd Hoffmann @ 2023-07-06 15:31 UTC (permalink / raw)
  To: devel
  Cc: Marc-André Lureau, Gerd Hoffmann, Julien Grall,
	Anthony Perard, Ard Biesheuvel, Jordan Justen, Stefan Berger,
	Jiewen Yao

Add DetectAndPreparePlatformVirtioDevicePath() helper function
to setup virtio-mmio devices.  Start with virtio-serial support.

This makes virtio console usable with microvm.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 .../PlatformBootManagerLib.inf                |  1 +
 .../PlatformBootManagerLib/BdsPlatform.c      | 31 +++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 6b396eac7daf..c6ffc1ed9ed5 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -75,6 +75,7 @@ [Pcd.IA32, Pcd.X64]
 [Protocols]
   gEfiDecompressProtocolGuid
   gEfiPciRootBridgeIoProtocolGuid
+  gVirtioDeviceProtocolGuid
   gEfiS3SaveStateProtocolGuid                   # PROTOCOL SOMETIMES_CONSUMED
   gEfiDxeSmmReadyToLockProtocolGuid             # PROTOCOL SOMETIMES_PRODUCED
   gEfiLoadedImageProtocolGuid                   # PROTOCOL SOMETIMES_PRODUCED
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index 8dc2bbf97371..88c39df4aea9 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -10,6 +10,7 @@
 #include <Guid/RootBridgesConnectedEventGroup.h>
 #include <Guid/SerialPortLibVendor.h>
 #include <Protocol/FirmwareVolume2.h>
+#include <Protocol/VirtioDevice.h>
 #include <Library/PlatformBmPrintScLib.h>
 #include <Library/Tcg2PhysicalPresenceLib.h>
 #include <Library/XenPlatformLib.h>
@@ -1236,6 +1237,30 @@ DetectAndPreparePlatformPciDevicePath (
   return Status;
 }
 
+EFI_STATUS
+EFIAPI
+DetectAndPreparePlatformVirtioDevicePath (
+  IN EFI_HANDLE  Handle,
+  IN VOID        *Instance,
+  IN VOID        *Context
+  )
+{
+  VIRTIO_DEVICE_PROTOCOL  *VirtIo = (VIRTIO_DEVICE_PROTOCOL *)Instance;
+
+  DEBUG ((DEBUG_INFO, "%a:%d: id %d\n", __func__, __LINE__, VirtIo->SubSystemDeviceId));
+
+  switch (VirtIo->SubSystemDeviceId) {
+    case 3:
+      PrepareVirtioSerialDevicePath (Handle);
+      break;
+    default:
+      /* nothing */
+      break;
+  }
+
+  return EFI_SUCCESS;
+}
+
 /**
   Connect the predefined platform default console device.
 
@@ -1256,6 +1281,12 @@ PlatformInitializeConsole (
   //
   VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
 
+  VisitAllInstancesOfProtocol (
+    &gVirtioDeviceProtocolGuid,
+    DetectAndPreparePlatformVirtioDevicePath,
+    NULL
+    );
+
   PrepareMicrovmDevicePath ();
 
   //
-- 
2.41.0


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

* Re: [edk2-devel] [PATCH 1/1] OvmfPkg/PlatformBootManagerLib: setup virtio-mmio devices.
  2023-07-06 15:31 [PATCH 1/1] OvmfPkg/PlatformBootManagerLib: setup virtio-mmio devices Gerd Hoffmann
@ 2023-09-07 13:51 ` Ard Biesheuvel
  0 siblings, 0 replies; 2+ messages in thread
From: Ard Biesheuvel @ 2023-09-07 13:51 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: devel, Marc-André Lureau, Julien Grall, Anthony Perard,
	Ard Biesheuvel, Jordan Justen, Stefan Berger, Jiewen Yao

On Thu, 6 Jul 2023 at 17:31, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Add DetectAndPreparePlatformVirtioDevicePath() helper function
> to setup virtio-mmio devices.  Start with virtio-serial support.
>
> This makes virtio console usable with microvm.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Acked-by: Ard Biesheuvel <ardb@kernel.org>

I'll queue this up

> ---
>  .../PlatformBootManagerLib.inf                |  1 +
>  .../PlatformBootManagerLib/BdsPlatform.c      | 31 +++++++++++++++++++
>  2 files changed, 32 insertions(+)
>
> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> index 6b396eac7daf..c6ffc1ed9ed5 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> @@ -75,6 +75,7 @@ [Pcd.IA32, Pcd.X64]
>  [Protocols]
>    gEfiDecompressProtocolGuid
>    gEfiPciRootBridgeIoProtocolGuid
> +  gVirtioDeviceProtocolGuid
>    gEfiS3SaveStateProtocolGuid                   # PROTOCOL SOMETIMES_CONSUMED
>    gEfiDxeSmmReadyToLockProtocolGuid             # PROTOCOL SOMETIMES_PRODUCED
>    gEfiLoadedImageProtocolGuid                   # PROTOCOL SOMETIMES_PRODUCED
> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> index 8dc2bbf97371..88c39df4aea9 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> @@ -10,6 +10,7 @@
>  #include <Guid/RootBridgesConnectedEventGroup.h>
>  #include <Guid/SerialPortLibVendor.h>
>  #include <Protocol/FirmwareVolume2.h>
> +#include <Protocol/VirtioDevice.h>
>  #include <Library/PlatformBmPrintScLib.h>
>  #include <Library/Tcg2PhysicalPresenceLib.h>
>  #include <Library/XenPlatformLib.h>
> @@ -1236,6 +1237,30 @@ DetectAndPreparePlatformPciDevicePath (
>    return Status;
>  }
>
> +EFI_STATUS
> +EFIAPI
> +DetectAndPreparePlatformVirtioDevicePath (
> +  IN EFI_HANDLE  Handle,
> +  IN VOID        *Instance,
> +  IN VOID        *Context
> +  )
> +{
> +  VIRTIO_DEVICE_PROTOCOL  *VirtIo = (VIRTIO_DEVICE_PROTOCOL *)Instance;
> +
> +  DEBUG ((DEBUG_INFO, "%a:%d: id %d\n", __func__, __LINE__, VirtIo->SubSystemDeviceId));
> +
> +  switch (VirtIo->SubSystemDeviceId) {
> +    case 3:
> +      PrepareVirtioSerialDevicePath (Handle);
> +      break;
> +    default:
> +      /* nothing */
> +      break;
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
>  /**
>    Connect the predefined platform default console device.
>
> @@ -1256,6 +1281,12 @@ PlatformInitializeConsole (
>    //
>    VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
>
> +  VisitAllInstancesOfProtocol (
> +    &gVirtioDeviceProtocolGuid,
> +    DetectAndPreparePlatformVirtioDevicePath,
> +    NULL
> +    );
> +
>    PrepareMicrovmDevicePath ();
>
>    //
> --
> 2.41.0
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108390): https://edk2.groups.io/g/devel/message/108390
Mute This Topic: https://groups.io/mt/99987954/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



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

end of thread, other threads:[~2023-09-07 13:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-06 15:31 [PATCH 1/1] OvmfPkg/PlatformBootManagerLib: setup virtio-mmio devices Gerd Hoffmann
2023-09-07 13:51 ` [edk2-devel] " Ard Biesheuvel

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