OvmfPkg/MptScsiDxe: Probe PCI devices and look for MptScsi

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>
This commit is contained in:
Nikita Leshenko 2020-05-05 00:05:59 +03:00 committed by mergify[bot]
parent be7fcaa1c9
commit f47074425d
3 changed files with 76 additions and 1 deletions

View File

@ -0,0 +1,23 @@
/** @file
Macros and type definitions for LSI Fusion MPT SCSI devices.
Copyright (C) 2020, Oracle and/or its affiliates.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef __FUSION_MPT_SCSI_H__
#define __FUSION_MPT_SCSI_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
#endif // __FUSION_MPT_SCSI_H__

View File

@ -9,7 +9,11 @@
**/
#include <IndustryStandard/FusionMptScsi.h>
#include <IndustryStandard/Pci.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Protocol/PciIo.h>
#include <Uefi/UefiSpec.h>
//
@ -31,7 +35,50 @@ MptScsiControllerSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
return EFI_UNSUPPORTED;
EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
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

View File

@ -21,7 +21,12 @@
[Packages]
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec
[LibraryClasses]
UefiBootServicesTableLib
UefiDriverEntryPoint
UefiLib
[Protocols]
gEfiPciIoProtocolGuid ## TO_START