From nobody Tue Nov 26 08:54:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56537+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56537+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425524; cv=none; d=zohomail.com; s=zohoarc; b=gAbDKl539wud2qpBiYO5qdJbrbbFVn7PWydECbDvDAj7EMSXZkPLfmtF0mEx1iurDh1dQWmyzWoSbdkfzCvv8FjJzbU3girM0GwXSoLg+8b98zfhm0BOqwyxaG4zM1k1w+asq1E8JTd3KC0PXt/p/ehiA+hqicbi2hjfQRGfmlk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425524; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ThkS/BX7guScfwrkKQL66Jm6D+cZYryqdwdyCWW3E08=; b=YODP3xajt0UlE1Xe6i0LKGYZOO8+RKJZIDt5aO38HdX9G+AoEc9DI9i06XuwpOP2aymMRi5omwRROrtPGcgAN6sSEOWa+5DdwNx6iLLVu0sk7sqU85L/znfu0BQLyj9Bq5Wh1aI2owUA/VxNjCguxakegCW7zAIBhV+HmrTkpdA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56537+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425524847238.59279415887238; Sat, 28 Mar 2020 12:58:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id HcLZYY1788612xQAzaORMzTl; Sat, 28 Mar 2020 12:58:44 -0700 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web12.14045.1585425523930958671 for ; Sat, 28 Mar 2020 12:58:44 -0700 X-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 02SJnMgp014025; Sat, 28 Mar 2020 19:58:43 GMT X-Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 301x0qsj88-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:43 +0000 X-Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SJo7Ye031409; Sat, 28 Mar 2020 19:58:42 GMT X-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 301vm90pyd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:42 +0000 X-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02SJwgb3016973; Sat, 28 Mar 2020 19:58:42 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:58:41 -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: [edk2-devel] [PATCH v3 04/17] OvmfPkg/PvScsiDxe: Probe PCI devices and look for PvScsi Date: Sat, 28 Mar 2020 23:00:47 +0300 Message-Id: <20200328200100.60786-5-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: qjPSFSxegzOS7dKM54so9SDGx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425524; bh=nEgT4Ww27s9SHjK10IaYVYZ/TddQGS9CsaJ2/4xapD8=; h=Cc:Date:From:Reply-To:Subject:To; b=GiP3WZFEMcNyid73hKENZg3iww17UD9fMPieVK9LG8splDdPAIsa/HyFQ32Hh/Jr9I/ HfiiP4QvvYgzZbPQkVuwMb8hcvlR7Dofy4rMY2/tTOmcM4Ik3bkeTVNVqscPuSdUrB0Wn yQpldvjKKgXtpUWP5tkMIT2IylNc+csAYPA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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=3D2567 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/In= dustryStandard/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 @@ =20 **/ =20 +#include +#include +#include #include +#include #include =20 // @@ -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 =3D gBS->OpenProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + (VOID **)&PciIo, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D PciIo->Pci.Read ( + PciIo, + EfiPciIoWidthUint32, + 0, + sizeof (Pci) / sizeof (UINT32), + &Pci + ); + if (EFI_ERROR (Status)) { + goto Done; + } + + if ((Pci.Hdr.VendorId !=3D PCI_VENDOR_ID_VMWARE) || + (Pci.Hdr.DeviceId !=3D PCI_DEVICE_ID_VMWARE_PVSCSI)) { + Status =3D EFI_UNSUPPORTED; + goto Done; + } + + Status =3D EFI_SUCCESS; + +Done: + gBS->CloseProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, + ControllerHandle + ); + + return Status; } =20 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 @@ =20 [Packages] MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec =20 [LibraryClasses] + UefiBootServicesTableLib UefiDriverEntryPoint UefiLib + +[Protocols] + gEfiPciIoProtocolGuid ## TO_START --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56537): https://edk2.groups.io/g/devel/message/56537 Mute This Topic: https://groups.io/mt/72617125/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-