diff options
author | Laszlo Ersek <lersek@redhat.com> | 2020-12-16 22:10:38 +0100 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2020-12-21 17:16:23 +0000 |
commit | 5ab6a0e1c8e94f94a9d3e7cd081161beb334758f (patch) | |
tree | bd7e2b2fc75aea0105a13bb7d9f5b282746a8db4 /OvmfPkg/VirtioFsDxe/DriverBinding.c | |
parent | c06635ea3f4b7b52054fe5d5b5e0cda3b594d2f5 (diff) | |
download | edk2-5ab6a0e1c8e94f94a9d3e7cd081161beb334758f.tar.gz |
OvmfPkg: introduce VirtioFsDxe
The purpose of the driver is to ease file exchange (file sharing) between
the guest firmware and the virtualization host. The driver is supposed to
interoperate with QEMU's "virtiofsd" (Virtio Filesystem Daemon).
References:
- https://virtio-fs.gitlab.io/
- https://libvirt.org/kbase/virtiofs.html
VirtioFsDxe will bind virtio-fs devices, and produce
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL instances on them.
In the longer term, assuming QEMU will create "bootorder" fw_cfg file
entries for virtio-fs devices, booting guest OSes from host-side
directories should become possible (dependent on the matching
QemuBootOrderLib enhancement).
Add the skeleton of the driver. Install EFI_DRIVER_BINDING_PROTOCOL with
stub member functions. Install EFI_COMPONENT_NAME2_PROTOCOL with final
member functions. This suffices for the DRIVERS command in the UEFI Shell
to list the driver with a human-readable name.
The file permission model is described immediately in the INF file as a
comment block, for future reference.
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3097
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20201216211125.19496-2-lersek@redhat.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Diffstat (limited to 'OvmfPkg/VirtioFsDxe/DriverBinding.c')
-rw-r--r-- | OvmfPkg/VirtioFsDxe/DriverBinding.c | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/OvmfPkg/VirtioFsDxe/DriverBinding.c b/OvmfPkg/VirtioFsDxe/DriverBinding.c new file mode 100644 index 0000000000..ac0a6330f0 --- /dev/null +++ b/OvmfPkg/VirtioFsDxe/DriverBinding.c @@ -0,0 +1,112 @@ +/** @file
+ Provide EFI_SIMPLE_FILE_SYSTEM_PROTOCOL instances on virtio-fs devices.
+
+ Copyright (C) 2020, Red Hat, Inc.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Library/BaseLib.h> // AsciiStrCmp()
+#include <Library/UefiBootServicesTableLib.h> // gBS
+#include <Protocol/ComponentName2.h> // EFI_COMPONENT_NAME2_PROTOCOL
+#include <Protocol/DriverBinding.h> // EFI_DRIVER_BINDING_PROTOCOL
+
+//
+// UEFI Driver Model protocol instances.
+//
+STATIC EFI_DRIVER_BINDING_PROTOCOL mDriverBinding;
+STATIC EFI_COMPONENT_NAME2_PROTOCOL mComponentName2;
+
+//
+// UEFI Driver Model protocol member functions.
+//
+EFI_STATUS
+EFIAPI
+VirtioFsBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioFsBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ return EFI_DEVICE_ERROR;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioFsBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ )
+{
+ return EFI_DEVICE_ERROR;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioFsGetDriverName (
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ )
+{
+ if (AsciiStrCmp (Language, "en") != 0) {
+ return EFI_UNSUPPORTED;
+ }
+ *DriverName = L"Virtio Filesystem Driver";
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioFsGetControllerName (
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+//
+// Entry point of this driver.
+//
+EFI_STATUS
+EFIAPI
+VirtioFsEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ mDriverBinding.Supported = VirtioFsBindingSupported;
+ mDriverBinding.Start = VirtioFsBindingStart;
+ mDriverBinding.Stop = VirtioFsBindingStop;
+ mDriverBinding.Version = 0x10;
+ mDriverBinding.ImageHandle = ImageHandle;
+ mDriverBinding.DriverBindingHandle = ImageHandle;
+
+ mComponentName2.GetDriverName = VirtioFsGetDriverName;
+ mComponentName2.GetControllerName = VirtioFsGetControllerName;
+ mComponentName2.SupportedLanguages = "en";
+
+ Status = gBS->InstallMultipleProtocolInterfaces (&ImageHandle,
+ &gEfiDriverBindingProtocolGuid, &mDriverBinding,
+ &gEfiComponentName2ProtocolGuid, &mComponentName2, NULL);
+ return Status;
+}
|