--- /dev/null
+/** @file\r
+\r
+ VMware PVSCSI Device specific type and macro definitions.\r
+\r
+ Copyright (C) 2020, Oracle and/or its affiliates.\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef __PVSCSI_H_\r
+#define __PVSCSI_H_\r
+\r
+//\r
+// Device offsets and constants\r
+//\r
+\r
+#define PCI_VENDOR_ID_VMWARE (0x15ad)\r
+#define PCI_DEVICE_ID_VMWARE_PVSCSI (0x07c0)\r
+\r
+#endif // __PVSCSI_H_\r
\r
**/\r
\r
+#include <IndustryStandard/Pci.h>\r
+#include <IndustryStandard/PvScsi.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
#include <Library/UefiLib.h>\r
+#include <Protocol/PciIo.h>\r
#include <Uefi/UefiSpec.h>\r
\r
//\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
)\r
{\r
- return EFI_UNSUPPORTED;\r
+ EFI_STATUS Status;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+ PCI_TYPE00 Pci;\r
+\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID **)&PciIo,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ Status = PciIo->Pci.Read (\r
+ PciIo,\r
+ EfiPciIoWidthUint32,\r
+ 0,\r
+ sizeof (Pci) / sizeof (UINT32),\r
+ &Pci\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+\r
+ if ((Pci.Hdr.VendorId != PCI_VENDOR_ID_VMWARE) ||\r
+ (Pci.Hdr.DeviceId != PCI_DEVICE_ID_VMWARE_PVSCSI)) {\r
+ Status = EFI_UNSUPPORTED;\r
+ goto Done;\r
+ }\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+Done:\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ &gEfiPciIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+\r
+ return Status;\r
}\r
\r
STATIC\r