]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/LsiScsiDxe: Probe PCI devices and look for LsiScsi
authorGary Lin <glin@suse.com>
Fri, 17 Jul 2020 06:11:23 +0000 (14:11 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 17 Jul 2020 20:51:55 +0000 (20:51 +0000)
Implement LsiScsiControllerSupported() to probe the PCI ID and look for
LSI 53C895A.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200717061130.8881-5-glin@suse.com>

OvmfPkg/Include/IndustryStandard/LsiScsi.h [new file with mode: 0644]
OvmfPkg/LsiScsiDxe/LsiScsi.c
OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf

diff --git a/OvmfPkg/Include/IndustryStandard/LsiScsi.h b/OvmfPkg/Include/IndustryStandard/LsiScsi.h
new file mode 100644 (file)
index 0000000..c09e864
--- /dev/null
@@ -0,0 +1,20 @@
+/** @file\r
+\r
+  Macros and type definitions for LSI 53C895A SCSI devices.\r
+\r
+  Copyright (C) 2020, SUSE LLC.\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef _LSI_SCSI_H_\r
+#define _LSI_SCSI_H_\r
+\r
+//\r
+// Device ID\r
+//\r
+#define LSI_LOGIC_PCI_VENDOR_ID   0x1000\r
+#define LSI_53C895A_PCI_DEVICE_ID 0x0012\r
+\r
+#endif // _LSI_SCSI_H_\r
index 62daa3ab99bf2cfdd2eb495b9423dc2dd28525a2..5bca85bd75eb3f9a9d57d713c1725de7464b57d8 100644 (file)
@@ -9,7 +9,12 @@
 \r
 **/\r
 \r
+#include <IndustryStandard/LsiScsi.h>\r
+#include <IndustryStandard/Pci.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiLib.h>\r
+#include <Protocol/PciIo.h>\r
+#include <Protocol/PciRootBridgeIo.h>\r
 #include <Uefi/UefiSpec.h>\r
 \r
 #include "LsiScsi.h"\r
@@ -31,7 +36,48 @@ LsiScsiControllerSupported (
   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_53C895A_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
 EFI_STATUS\r
index 5cb15c4565492fd348f6a6b1bffcf5a5dcb88598..7ce11fcc6a03ea3dc5d2fdd4de93295b4e12544f 100644 (file)
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
+  OvmfPkg/OvmfPkg.dec\r
 \r
 [LibraryClasses]\r
+  BaseLib\r
+  UefiBootServicesTableLib\r
   UefiDriverEntryPoint\r
   UefiLib\r
+\r
+[Protocols]\r
+  gEfiPciIoProtocolGuid                  ## TO_START\r