On 03/16/20 16:01, Liran Alon wrote: > 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 <nikita.leshche...@oracle.com> > Signed-off-by: Liran Alon <liran.a...@oracle.com> > --- > 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 <IndustryStandard/Pci.h> > +#include <IndustryStandard/PvScsi.h> > +#include <Library/UefiBootServicesTableLib.h> > #include <Library/UefiLib.h> > +#include <Protocol/PciIo.h> > > // > // 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),
(1) Please insert a space character before each opening parenthesis. > + &Pci > + ); > + if (EFI_ERROR (Status)) { > + goto Done; (2) Wrong indentation. > + } > + > + if ((Pci.Hdr.VendorId != PCI_VENDOR_ID_VMWARE) || > + (Pci.Hdr.DeviceId != PCI_DEVICE_ID_VMWARE_PVSCSI)) { > + Status = EFI_UNSUPPORTED; > + goto Done; (3) Wrong indentation. > + } > + > + 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 > With (1) through (3) addressed: Reviewed-by: Laszlo Ersek <ler...@redhat.com> Thanks Laszlo -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56147): https://edk2.groups.io/g/devel/message/56147 Mute This Topic: https://groups.io/mt/72001275/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-