From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by mx.groups.io with SMTP id smtpd.web10.2010.1587750983783420620 for ; Fri, 24 Apr 2020 10:56:23 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=v7u7m5iN; spf=pass (domain: oracle.com, ip: 156.151.31.85, mailfrom: nikita.leshchenko@oracle.com) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03OHr2NW032967; Fri, 24 Apr 2020 17:56:20 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=pzB2VRBIqETqPGQ2noGJTfLVbrLBF3J/G0scGwOXMK8=; b=v7u7m5iNMge9UxpZDBQzrR1ht0pxZwH18Dt0UjM34gifJkLvXe7l/N5hL+B/56PwszAN Sv8OkIew0zDXnqN+YJul5A7q0ivYp4AbF/NLemwv7m3/5VHUMA+7TuqZqwAjRbgYitR7 edbM0kG/BA+gkzox8RACqDlwKPQl2kZeahL3QUf7WVGJZfNCd3/HqoJgp+5zeIewqe3p pnOdm0me2Oxpu5ruX+3CHsCWOfmxv9Q9L9vae0JWBqc1bzvEBSht4mR8Ljyk2/sbUgBd 8gHE7JwmpZs2uv9nVT+ifG3oXPajSBVJTreZDS6hiv0rKt1A9jP/LemPvgtDsXK7n2xr vw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 30k7qe87n6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Apr 2020 17:56:20 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03OHlewc078330; Fri, 24 Apr 2020 17:56:20 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 30k7qxk6me-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Apr 2020 17:56:20 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03OHuJ5L029078; Fri, 24 Apr 2020 17:56:19 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 24 Apr 2020 10:56:19 -0700 From: "Nikita Leshenko" To: devel@edk2.groups.io Cc: Nikita Leshenko , liran.alon@oracle.com, aaron.young@oracle.com, Jordan Justen , Laszlo Ersek , Ard Biesheuvel Subject: [PATCH v5 04/12] OvmfPkg/MptScsiDxe: Probe PCI devices and look for MptScsi Date: Fri, 24 Apr 2020 20:59:19 +0300 Message-Id: <20200424175927.41210-5-nikita.leshchenko@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424175927.41210-1-nikita.leshchenko@oracle.com> References: <20200424175927.41210-1-nikita.leshchenko@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9601 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004240136 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9601 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 phishscore=0 impostorscore=0 mlxscore=0 clxscore=1015 malwarescore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004240136 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 Reviewed-by: Liran Alon --- .../Include/IndustryStandard/FusionMptScsi.h | 23 +++++++++ OvmfPkg/MptScsiDxe/MptScsi.c | 49 ++++++++++++++++++- OvmfPkg/MptScsiDxe/MptScsiDxe.inf | 5 ++ 3 files changed, 76 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..df9bdc2f0348 --- /dev/null +++ b/OvmfPkg/Include/IndustryStandard/FusionMptScsi.h @@ -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__ diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c index 64949a809022..4e2f8f2296fb 100644 --- a/OvmfPkg/MptScsiDxe/MptScsi.c +++ b/OvmfPkg/MptScsiDxe/MptScsi.c @@ -9,7 +9,11 @@ **/ +#include +#include +#include #include +#include #include // @@ -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 diff --git a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf index 53585068684f..414b96e5a248 100644 --- a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf +++ b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf @@ -21,7 +21,12 @@ [Sources] [Packages] MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec [LibraryClasses] + UefiBootServicesTableLib UefiDriverEntryPoint UefiLib + +[Protocols] + gEfiPciIoProtocolGuid ## TO_START -- 2.20.1