]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/PvScsiDxe: Probe PCI devices and look for PvScsi
authorLiran Alon <liran.alon@oracle.com>
Sat, 28 Mar 2020 20:00:47 +0000 (23:00 +0300)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 30 Mar 2020 16:45:07 +0000 (16:45 +0000)
PvScsiControllerSupported() is called on handles passed in
by the ConnectController() boot service and if the handle is the
PVSCSI controller, the function would return success. A success
return value will attach our driver to the device.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2567
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Message-Id: <20200328200100.60786-5-liran.alon@oracle.com>
Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
OvmfPkg/Include/IndustryStandard/PvScsi.h [new file with mode: 0644]
OvmfPkg/PvScsiDxe/PvScsi.c
OvmfPkg/PvScsiDxe/PvScsiDxe.inf

diff --git a/OvmfPkg/Include/IndustryStandard/PvScsi.h b/OvmfPkg/Include/IndustryStandard/PvScsi.h
new file mode 100644 (file)
index 0000000..004c0af
--- /dev/null
@@ -0,0 +1,21 @@
+/** @file\r
+\r
+  VMware PVSCSI Device specific type and macro definitions.\r
+\r
+  Copyright (C) 2020, Oracle and/or its affiliates.\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef __PVSCSI_H_\r
+#define __PVSCSI_H_\r
+\r
+//\r
+// Device offsets and constants\r
+//\r
+\r
+#define PCI_VENDOR_ID_VMWARE            (0x15ad)\r
+#define PCI_DEVICE_ID_VMWARE_PVSCSI     (0x07c0)\r
+\r
+#endif // __PVSCSI_H_\r
index 51b03f709040895e92bcf922670350cab08a08b1..9923a31d25d7a12c520bbe37255fd9b32a09ccb8 100644 (file)
@@ -9,7 +9,11 @@
 \r
 **/\r
 \r
+#include <IndustryStandard/Pci.h>\r
+#include <IndustryStandard/PvScsi.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiLib.h>\r
+#include <Protocol/PciIo.h>\r
 #include <Uefi/UefiSpec.h>\r
 \r
 //\r
@@ -31,7 +35,50 @@ PvScsiDriverBindingSupported (
   IN EFI_DEVICE_PATH_PROTOCOL    *RemainingDevicePath OPTIONAL\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
+  EFI_STATUS          Status;\r
+  EFI_PCI_IO_PROTOCOL *PciIo;\r
+  PCI_TYPE00          Pci;\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiPciIoProtocolGuid,\r
+                  (VOID **)&PciIo,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Status = PciIo->Pci.Read (\r
+                        PciIo,\r
+                        EfiPciIoWidthUint32,\r
+                        0,\r
+                        sizeof (Pci) / sizeof (UINT32),\r
+                        &Pci\r
+                        );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  if ((Pci.Hdr.VendorId != PCI_VENDOR_ID_VMWARE) ||\r
+      (Pci.Hdr.DeviceId != PCI_DEVICE_ID_VMWARE_PVSCSI)) {\r
+    Status = EFI_UNSUPPORTED;\r
+    goto Done;\r
+  }\r
+\r
+  Status = EFI_SUCCESS;\r
+\r
+Done:\r
+  gBS->CloseProtocol (\r
+         ControllerHandle,\r
+         &gEfiPciIoProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         ControllerHandle\r
+         );\r
+\r
+  return Status;\r
 }\r
 \r
 STATIC\r
index d1d0e963f96df2f4d5ea8ca9846e0a56bb11cb8f..c1f0663832eda13e602bbb7e8eaf12c57fe480bc 100644 (file)
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
+  OvmfPkg/OvmfPkg.dec\r
 \r
 [LibraryClasses]\r
+  UefiBootServicesTableLib\r
   UefiDriverEntryPoint\r
   UefiLib\r
+\r
+[Protocols]\r
+  gEfiPciIoProtocolGuid        ## TO_START\r