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.web12.15170.1585152466673745343 for ; Wed, 25 Mar 2020 09:07:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=RzgpFRoJ; spf=pass (domain: oracle.com, ip: 156.151.31.85, mailfrom: liran.alon@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 02PG4HQF133100; Wed, 25 Mar 2020 16:07:46 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=xj3T41VhkePxrG7phZWC+EHeRD9tqpfQEIH6WTcuOpk=; b=RzgpFRoJf3gHDs9EQKBO52DXdH6gWkNjtmrtlK0gFDTJAzzr1Jrof/pI2+bz+AbjfTEK /I8nSQteHorlesjdZmzBJ4YliLy4rmmaaDIlXNFopVOLDHmhqrwIS2p9QlsZVzGFPrOm oCN+aDpsLZmR0fImwaZJtu6v4FEne99Bwl6vRzkHgMOAnBFzFMqO0wO8BkL/+Tuf6ta2 FmRVfPBo2xo2fE+J/O1u3kTlzCJ0eF5McFX+BQ5zr2GHk1yVWnBQ1y4+GDczU5lIgtDG DeV/n1kpHjVNM5JSEFEDnQsRO3CzIaWto2VAEYTm0GRSdd1lD0KN4fdr3p+BDBh091jl Sw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 3005kv9pft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2020 16:07:46 +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 02PG2WZ1084028; Wed, 25 Mar 2020 16:07:46 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2yxw4rrudr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2020 16:07:45 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02PG7i3T011780; Wed, 25 Mar 2020 16:07:44 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Mar 2020 09:07:44 -0700 From: "Liran Alon" To: devel@edk2.groups.io, lersek@redhat.com Cc: nikita.leshchenko@oracle.com, aaron.young@oracle.com, jordan.l.justen@intel.com, ard.biesheuvel@linaro.org, Liran Alon Subject: [PATCH v2 04/17] OvmfPkg/PvScsiDxe: Probe PCI devices and look for PvScsi Date: Wed, 25 Mar 2020 18:09:52 +0200 Message-Id: <20200325161005.16743-5-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200325161005.16743-1-liran.alon@oracle.com> References: <20200325161005.16743-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9571 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003250128 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9571 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 phishscore=0 suspectscore=0 impostorscore=0 spamscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003250128 Content-Transfer-Encoding: 8bit PvScsiControllerSupported() is called on handles passed in by the ConnectController() boot service and if the handle is the PVSCSI controller, the function would return success. A success return value will attach our driver to the device. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon --- OvmfPkg/Include/IndustryStandard/PvScsi.h | 21 ++++++++++ OvmfPkg/PvScsiDxe/PvScsi.c | 49 ++++++++++++++++++++++- OvmfPkg/PvScsiDxe/PvScsiDxe.inf | 5 +++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 OvmfPkg/Include/IndustryStandard/PvScsi.h diff --git a/OvmfPkg/Include/IndustryStandard/PvScsi.h b/OvmfPkg/Include/IndustryStandard/PvScsi.h new file mode 100644 index 000000000000..004c0af84989 --- /dev/null +++ b/OvmfPkg/Include/IndustryStandard/PvScsi.h @@ -0,0 +1,21 @@ +/** @file + + VMware PVSCSI Device specific type and macro definitions. + + Copyright (C) 2020, Oracle and/or its affiliates. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __PVSCSI_H_ +#define __PVSCSI_H_ + +// +// Device offsets and constants +// + +#define PCI_VENDOR_ID_VMWARE (0x15ad) +#define PCI_DEVICE_ID_VMWARE_PVSCSI (0x07c0) + +#endif // __PVSCSI_H_ diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index 51b03f709040..9923a31d25d7 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -9,7 +9,11 @@ **/ +#include +#include +#include #include +#include #include // @@ -31,7 +35,50 @@ PvScsiDriverBindingSupported ( 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 != PCI_VENDOR_ID_VMWARE) || + (Pci.Hdr.DeviceId != PCI_DEVICE_ID_VMWARE_PVSCSI)) { + Status = EFI_UNSUPPORTED; + goto Done; + } + + Status = EFI_SUCCESS; + +Done: + gBS->CloseProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, + ControllerHandle + ); + + return Status; } STATIC diff --git a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf b/OvmfPkg/PvScsiDxe/PvScsiDxe.inf index d1d0e963f96d..c1f0663832ed 100644 --- a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf +++ b/OvmfPkg/PvScsiDxe/PvScsiDxe.inf @@ -22,7 +22,12 @@ [Packages] MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec [LibraryClasses] + UefiBootServicesTableLib UefiDriverEntryPoint UefiLib + +[Protocols] + gEfiPciIoProtocolGuid ## TO_START -- 2.20.1