The MptScsiControllerSupported function is called for every handle that appears on the system and if the handle is the lsi53c1030 controller the function would return success. A successful return value will attach our driver to the device.
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Nikita Leshenko <nikita.leshche...@oracle.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.w...@oracle.com> Reviewed-by: Aaron Young <aaron.yo...@oracle.com> Reviewed-by: Liran Alon <liran.a...@oracle.com> --- OvmfPkg/MptScsiDxe/MptScsi.c | 55 ++++++++++++++++++++++++++++++- OvmfPkg/MptScsiDxe/MptScsiDxe.inf | 5 +++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c index 38cdda1abe..57a17ca0cb 100644 --- a/OvmfPkg/MptScsiDxe/MptScsi.c +++ b/OvmfPkg/MptScsiDxe/MptScsi.c @@ -15,7 +15,20 @@ **/ +#include <IndustryStandard/Pci.h> +#include <Library/DebugLib.h> #include <Library/UefiLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Protocol/PciIo.h> + +// +// Device offsets and constants +// + +#define LSI_LOGIC_PCI_VENDOR_ID 0x1000 +#define LSI_53C1030_PCI_DEVICE_ID 0x0030 +#define LSI_SAS1068_PCI_DEVICE_ID 0x0054 +#define LSI_SAS1068E_PCI_DEVICE_ID 0x0058 // // Driver Binding @@ -30,7 +43,46 @@ MptScsiControllerSupported ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ) { - return EFI_UNSUPPORTED; + EFI_STATUS Status; + EFI_PCI_IO_PROTOCOL *PciIo = NULL; + PCI_TYPE00 Pci; + + Status = gBS->OpenProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + (VOID **) &PciIo, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = PciIo->Pci.Read ( + PciIo, + EfiPciIoWidthUint32, + 0, sizeof (Pci) / sizeof (UINT32), + &Pci); + if (EFI_ERROR (Status)) { + goto Done; + } + + if (Pci.Hdr.VendorId == LSI_LOGIC_PCI_VENDOR_ID + && (Pci.Hdr.DeviceId == LSI_53C1030_PCI_DEVICE_ID + || Pci.Hdr.DeviceId == LSI_SAS1068_PCI_DEVICE_ID + || Pci.Hdr.DeviceId == LSI_SAS1068E_PCI_DEVICE_ID)) { + Status = EFI_SUCCESS; + } else { + Status = EFI_UNSUPPORTED; + } + +Done: + gBS->CloseProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, + ControllerHandle); + return Status; } STATIC @@ -42,6 +94,7 @@ MptScsiControllerStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ) { + DEBUG ((EFI_D_INFO, "Attempted to start MptScsi\n")); return EFI_UNSUPPORTED; } diff --git a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf index 8a780a661e..3608cecaab 100644 --- a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf +++ b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf @@ -30,5 +30,10 @@ OvmfPkg/OvmfPkg.dec [LibraryClasses] + DebugLib + UefiBootServicesTableLib UefiDriverEntryPoint UefiLib + +[Protocols] + gEfiPciIoProtocolGuid ## TO_START \ No newline at end of file -- 2.20.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel