]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/MptScsiDxe: Probe PCI devices and look for MptScsi
authorNikita Leshenko <nikita.leshchenko@oracle.com>
Mon, 4 May 2020 21:05:59 +0000 (00:05 +0300)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 5 May 2020 20:43:02 +0000 (20:43 +0000)
The MptScsiControllerSupported function is called on handles passed in
by the ConnectController() boot service and if the handle is the
lsi53c1030 controller the function would return success. A successful
return value will attach our driver to the device.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390
Signed-off-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liran Alon <liran.alon@oracle.com>
Message-Id: <20200504210607.144434-5-nikita.leshchenko@oracle.com>

OvmfPkg/Include/IndustryStandard/FusionMptScsi.h [new file with mode: 0644]
OvmfPkg/MptScsiDxe/MptScsi.c
OvmfPkg/MptScsiDxe/MptScsiDxe.inf

diff --git a/OvmfPkg/Include/IndustryStandard/FusionMptScsi.h b/OvmfPkg/Include/IndustryStandard/FusionMptScsi.h
new file mode 100644 (file)
index 0000000..df9bdc2
--- /dev/null
@@ -0,0 +1,23 @@
+/** @file\r
+\r
+  Macros and type definitions for LSI Fusion MPT SCSI devices.\r
+\r
+  Copyright (C) 2020, Oracle and/or its affiliates.\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef __FUSION_MPT_SCSI_H__\r
+#define __FUSION_MPT_SCSI_H__\r
+\r
+//\r
+// Device offsets and constants\r
+//\r
+\r
+#define LSI_LOGIC_PCI_VENDOR_ID 0x1000\r
+#define LSI_53C1030_PCI_DEVICE_ID 0x0030\r
+#define LSI_SAS1068_PCI_DEVICE_ID 0x0054\r
+#define LSI_SAS1068E_PCI_DEVICE_ID 0x0058\r
+\r
+#endif // __FUSION_MPT_SCSI_H__\r
index 64949a80902282ad76a0a9515ea1c075892cc391..4e2f8f2296fbb5d98fffef9874e228cbea234917 100644 (file)
@@ -9,7 +9,11 @@
 \r
 **/\r
 \r
+#include <IndustryStandard/FusionMptScsi.h>\r
+#include <IndustryStandard/Pci.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 @@ MptScsiControllerSupported (
   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 == LSI_LOGIC_PCI_VENDOR_ID &&\r
+      (Pci.Hdr.DeviceId == LSI_53C1030_PCI_DEVICE_ID ||\r
+       Pci.Hdr.DeviceId == LSI_SAS1068_PCI_DEVICE_ID ||\r
+       Pci.Hdr.DeviceId == LSI_SAS1068E_PCI_DEVICE_ID)) {\r
+    Status = EFI_SUCCESS;\r
+  } else {\r
+    Status = EFI_UNSUPPORTED;\r
+  }\r
+\r
+Done:\r
+  gBS->CloseProtocol (\r
+         ControllerHandle,\r
+         &gEfiPciIoProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         ControllerHandle\r
+         );\r
+  return Status;\r
 }\r
 \r
 STATIC\r
index 53585068684f8b29aa852af9350abb498e503771..414b96e5a2483cbcd4241b24f2733a7ed4a1f89f 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