From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web11.69796.1584370940227839170 for ; Mon, 16 Mar 2020 08:02:20 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=hpktT1vO; spf=pass (domain: oracle.com, ip: 156.151.31.86, mailfrom: liran.alon@oracle.com) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02GEqjQH088869; Mon, 16 Mar 2020 15:02:19 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=SXGfvDObeq1sAq/Omq0bXl/FZ2B8+t6avkm6PAcxeXs=; b=hpktT1vOQdTEyvq19ag3R0TdwXN26l08XP9/R2zwQ7WTmYYEmvkfjRm+H+gAGVsm3VCi SNhedVAxPAbZAIVUva/BzI1+0xQlQl9b86YTDG86hY7MI2PyEQOH/78TyOsYyZSCkW7s xPAJTxwnM8JbzKiN/KTBVszU3aXoQaNbR9WDuAD5/WDmx5JEKJzhrukLWaAYF98mGIOj VMXGSKHg3ZHCjukrSoamzd+1100pbTUWwv15KaIOvitJjvY3y2doyFh71yyw9CtG+Yyw 7va3h/DPX+I7vf8Qvdg8FIxRHYdMJLDUl7KftPY6wqEZPK7p7towrKOy/SZi31IzhMTA aA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2yrppqyfvw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Mar 2020 15:02:17 +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 02GEqQvY048514; Mon, 16 Mar 2020 15:00:17 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2ys8rcmqf5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Mar 2020 15:00:15 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02GF0DnC008765; Mon, 16 Mar 2020 15:00:13 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 16 Mar 2020 08:00:13 -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 04/17] OvmfPkg/PvScsiDxe: Probe PCI devices and look for PvScsi Date: Mon, 16 Mar 2020 17:01:00 +0200 Message-Id: <20200316150113.104630-5-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316150113.104630-1-liran.alon@oracle.com> References: <20200316150113.104630-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9561 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 phishscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003160072 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9561 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003160072 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: Nikita Leshenko Signed-off-by: Liran Alon --- OvmfPkg/Include/IndustryStandard/PvScsi.h | 21 ++++++++++ OvmfPkg/PvScsiDxe/PvScsi.c | 49 ++++++++++++++++++++++- OvmfPkg/PvScsiDxe/PvScsi.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 0c81e645de08..f1fffe962233 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -9,7 +9,11 @@ **/ +#include +#include +#include #include +#include // // Higher versions will be used before lower, 0x10-0xffffffef is the version @@ -30,7 +34,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/PvScsi.inf b/OvmfPkg/PvScsiDxe/PvScsi.inf index d1d0e963f96d..c1f0663832ed 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.inf +++ b/OvmfPkg/PvScsiDxe/PvScsi.inf @@ -22,7 +22,12 @@ [Packages] MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec [LibraryClasses] + UefiBootServicesTableLib UefiDriverEntryPoint UefiLib + +[Protocols] + gEfiPciIoProtocolGuid ## TO_START -- 2.20.1