From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web09.16646.1583349730046816353 for ; Wed, 04 Mar 2020 11:22:10 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=AjJ25pC5; spf=pass (domain: oracle.com, ip: 141.146.126.78, mailfrom: nikita.leshchenko@oracle.com) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 024Iw6Lc027799; Wed, 4 Mar 2020 19:22:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=gr6X7udUsWFrVEbxB2M8Ngoam3yYLHHyTz/84rqm3G0=; b=AjJ25pC5r5DC9AFZyvRKtJ5iqSqhmreCabp7PgIhsghWFrXFX4kn8hDHMndWp8hGVm/8 sLREHVllYe0xs98UQOyqHFXosyZXqTMmo6P5IIdLr7qAs/YP0bxVBEvDLwIk+wGAOySl wRkWZrNyviXXiNlJWFt+6saTeltulwIjn+zcgNPBnu4RK/nXJPnUH8CrpnhWpNJ6wXSw +1Fos77cj8qzdYgGGY+N2ghpLNYL51NuVM2PZe1bBSJxJxobcbhMdkMNlmPiP174CX+r +Uo2PvXMUvnyu69sIp9fC1IUOPudfTuaMOgSPu3tvSwZlVp6j/oUbEQM048BTPz8Vumr vg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2yffwr0e2w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Mar 2020 19:22:09 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 024JElhr145054; Wed, 4 Mar 2020 19:22:08 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2yg1eqkmft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Mar 2020 19:22:08 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 024JM7sF006672; Wed, 4 Mar 2020 19:22:07 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 04 Mar 2020 11:22:07 -0800 From: "Nikita Leshenko" To: devel@edk2.groups.io Cc: Nikita Leshenko , liran.alon@oracle.com, aaron.young@oracle.com, jordan.l.justen@intel.com, lersek@redhat.com, ard.biesheuvel@linaro.org Subject: [PATCH v3 04/13] OvmfPkg/MptScsiDxe: Probe PCI devices and look for MptScsi Date: Wed, 4 Mar 2020 21:22:48 +0200 Message-Id: <20200304192257.96736-5-nikita.leshchenko@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200304192257.96736-1-nikita.leshchenko@oracle.com> References: <20200304192257.96736-1-nikita.leshchenko@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9550 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003040126 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9550 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 spamscore=0 impostorscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 phishscore=0 clxscore=1015 bulkscore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003040126 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Laszlo Ersek --- .../Include/IndustryStandard/FusionMptScsi.h | 29 +++++++++++ OvmfPkg/MptScsiDxe/MptScsi.c | 49 ++++++++++++++++++- OvmfPkg/MptScsiDxe/MptScsiDxe.inf | 5 ++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 OvmfPkg/Include/IndustryStandard/FusionMptScsi.h diff --git a/OvmfPkg/Include/IndustryStandard/FusionMptScsi.h b/OvmfPkg/Include/IndustryStandard/FusionMptScsi.h new file mode 100644 index 000000000000..1bd65ed40b1c --- /dev/null +++ b/OvmfPkg/Include/IndustryStandard/FusionMptScsi.h @@ -0,0 +1,29 @@ +/** @file + + Macros and type definitions for LSI Fusion MPT SCSI devices. + + Copyright (C) 2020, Oracle and/or its affiliates. + + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#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__ diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c index 2961c3df3c45..07f8fe267fc2 100644 --- a/OvmfPkg/MptScsiDxe/MptScsi.c +++ b/OvmfPkg/MptScsiDxe/MptScsi.c @@ -15,7 +15,11 @@ **/ +#include +#include +#include #include +#include // // Higher versions will be used before lower, 0x10-0xffffffef is the version @@ -36,7 +40,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 diff --git a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf index cf072a0b2e75..105af20f325f 100644 --- a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf +++ b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf @@ -27,7 +27,12 @@ [Sources] [Packages] MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec [LibraryClasses] + UefiBootServicesTableLib UefiDriverEntryPoint UefiLib + +[Protocols] + gEfiPciIoProtocolGuid ## TO_START -- 2.20.1