26 VirtioPciGetDeviceFeatures,
27 VirtioPciSetGuestFeatures,
28 VirtioPciSetQueueAddress,
30 VirtioPciSetQueueNotify,
31 VirtioPciSetQueueAlignment,
33 VirtioPciGetQueueSize,
34 VirtioPciSetQueueSize,
35 VirtioPciGetDeviceStatus,
36 VirtioPciSetDeviceStatus,
39 VirtioPciAllocateSharedPages,
40 VirtioPciFreeSharedPages,
41 VirtioPciMapSharedBuffer,
42 VirtioPciUnmapSharedBuffer,
81 ASSERT (FieldSize == BufferSize);
88 Width = EfiPciIoWidthUint8;
92 Width = EfiPciIoWidthUint16;
112 Width = EfiPciIoWidthUint32;
117 return EFI_INVALID_PARAMETER;
120 return PciIo->Io.
Read (
168 Width = EfiPciIoWidthUint8;
172 Width = EfiPciIoWidthUint16;
192 Width = EfiPciIoWidthUint32;
197 return EFI_INVALID_PARAMETER;
200 return PciIo->Io.
Write (
253 Status =
gBS->OpenProtocol (
255 &gEfiPciIoProtocolGuid,
257 This->DriverBindingHandle,
260 EFI_OPEN_PROTOCOL_BY_DRIVER
263 if (EFI_ERROR (Status)) {
270 Status = PciIo->Pci.
Read (
276 sizeof Pci /
sizeof (UINT32),
284 if ((Pci.Hdr.VendorId == VIRTIO_VENDOR_ID) &&
285 (Pci.Hdr.DeviceId >= 0x1000) &&
286 (Pci.Hdr.DeviceId <= 0x103F) &&
287 (Pci.Hdr.RevisionID == 0x00))
291 Status = EFI_UNSUPPORTED;
301 &gEfiPciIoProtocolGuid,
302 This->DriverBindingHandle,
336 ASSERT (Device !=
NULL);
337 PciIo = Device->PciIo;
338 ASSERT (PciIo !=
NULL);
341 Status = PciIo->Pci.
Read (
347 sizeof (Pci) /
sizeof (UINT32),
350 if (EFI_ERROR (Status)) {
358 &Device->VirtioDevice,
359 &mDeviceProtocolTemplate,
366 Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5);
367 Device->VirtioDevice.SubSystemDeviceId = Pci.Device.SubsystemID;
373 Device->DeviceSpecificConfigurationOffset =
374 VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI;
439 if (Device ==
NULL) {
440 return EFI_OUT_OF_RESOURCES;
443 Status =
gBS->OpenProtocol (
445 &gEfiPciIoProtocolGuid,
446 (VOID **)&Device->PciIo,
447 This->DriverBindingHandle,
449 EFI_OPEN_PROTOCOL_BY_DRIVER
451 if (EFI_ERROR (Status)) {
466 Status = Device->PciIo->Attributes (
470 &Device->OriginalPciAttributes
472 if (EFI_ERROR (Status)) {
476 Status = Device->PciIo->Attributes (
483 if (EFI_ERROR (Status)) {
492 if (EFI_ERROR (Status)) {
493 goto RestorePciAttributes;
500 Device->Signature = VIRTIO_PCI_DEVICE_SIGNATURE;
501 Status =
gBS->InstallProtocolInterface (
503 &gVirtioDeviceProtocolGuid,
505 &Device->VirtioDevice
507 if (EFI_ERROR (Status)) {
517 Device->PciIo->Attributes (
520 Device->OriginalPciAttributes,
527 &gEfiPciIoProtocolGuid,
528 This->DriverBindingHandle,
577 Status =
gBS->OpenProtocol (
579 &gVirtioDeviceProtocolGuid,
580 (VOID **)&VirtioDevice,
581 This->DriverBindingHandle,
583 EFI_OPEN_PROTOCOL_GET_PROTOCOL
585 if (EFI_ERROR (Status)) {
589 Device = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (VirtioDevice);
594 Status =
gBS->UninstallProtocolInterface (
596 &gVirtioDeviceProtocolGuid,
597 &Device->VirtioDevice
599 if (EFI_ERROR (Status)) {
605 Device->PciIo->Attributes (
608 Device->OriginalPciAttributes,
612 Status =
gBS->CloseProtocol (
614 &gEfiPciIoProtocolGuid,
615 This->DriverBindingHandle,
648 {
"eng;en", L
"Virtio PCI Driver" },
657VirtioPciGetDriverName (
660 OUT CHAR16 **DriverName
665 This->SupportedLanguages,
668 (BOOLEAN)(This == &gComponentName)
674VirtioPciGetDeviceName (
679 OUT CHAR16 **ControllerName
682 return EFI_UNSUPPORTED;
687 &VirtioPciGetDriverName,
688 &VirtioPciGetDeviceName,
704VirtioPciDeviceEntryPoint (
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS(EFIAPI * EFI_COMPONENT_NAME2_GET_DRIVER_NAME)(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
EFI_STATUS(EFIAPI * EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_PCI_IO_PROTOCOL_WIDTH
@ EfiPciIoAttributeOperationGet
@ EfiPciIoAttributeOperationEnable
@ EfiPciIoAttributeOperationSet
#define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER
Enable the DMA bit in the PCI Config Header.
#define EFI_PCI_IO_ATTRIBUTE_IO
Enable the I/O decode bit in the PCI Config Header.
EFI_STATUS EFIAPI LookupUnicodeString2(IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable, OUT CHAR16 **UnicodeString, IN BOOLEAN Iso639Language)
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
STATIC EFI_STATUS EFIAPI VirtioPciDeviceBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
STATIC VOID EFIAPI VirtioPciUninit(IN OUT VIRTIO_PCI_DEVICE *Device)
EFI_STATUS EFIAPI VirtioPciIoRead(IN VIRTIO_PCI_DEVICE *Dev, IN UINTN FieldOffset, IN UINTN FieldSize, IN UINTN BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI VirtioPciIoWrite(IN VIRTIO_PCI_DEVICE *Dev, IN UINTN FieldOffset, IN UINTN FieldSize, IN UINT64 Value)
STATIC EFI_STATUS EFIAPI VirtioPciInit(IN OUT VIRTIO_PCI_DEVICE *Device)
STATIC EFI_STATUS EFIAPI VirtioPciDeviceBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
STATIC EFI_STATUS EFIAPI VirtioPciDeviceBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI VirtioPciDeviceWrite(IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN FieldOffset, IN UINTN FieldSize, IN UINT64 Value)
EFI_STATUS EFIAPI VirtioPciDeviceRead(IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN FieldOffset, IN UINTN FieldSize, IN UINTN BufferSize, OUT VOID *Buffer)
EFI_PCI_IO_PROTOCOL_IO_MEM Write
EFI_PCI_IO_PROTOCOL_IO_MEM Read
EFI_PCI_IO_PROTOCOL_CONFIG Read