TianoCore EDK2 master
Loading...
Searching...
No Matches
VirtioPciDevice.c File Reference

Go to the source code of this file.

Functions

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 VirtioPciDeviceBindingSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
STATIC EFI_STATUS EFIAPI VirtioPciInit (IN OUT VIRTIO_PCI_DEVICE *Device)
 
STATIC VOID EFIAPI VirtioPciUninit (IN OUT VIRTIO_PCI_DEVICE *Device)
 
STATIC EFI_STATUS EFIAPI VirtioPciDeviceBindingStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
STATIC EFI_STATUS EFIAPI VirtioPciDeviceBindingStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
EFI_STATUS EFIAPI VirtioPciGetDriverName (IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
 
EFI_STATUS EFIAPI VirtioPciGetDeviceName (IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_HANDLE ChildHandle, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
 
EFI_STATUS EFIAPI VirtioPciDeviceEntryPoint (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

STATIC VIRTIO_DEVICE_PROTOCOL mDeviceProtocolTemplate
 
STATIC EFI_DRIVER_BINDING_PROTOCOL gDriverBinding
 
STATIC EFI_UNICODE_STRING_TABLE mDriverNameTable []
 
STATIC EFI_COMPONENT_NAME_PROTOCOL gComponentName
 
STATIC EFI_COMPONENT_NAME2_PROTOCOL gComponentName2
 

Detailed Description

This driver produces Virtio Device Protocol instances for Virtio PCI devices.

Copyright (C) 2012, Red Hat, Inc. Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
Copyright (C) 2013, ARM Ltd. Copyright (C) 2017, AMD Inc, All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file VirtioPciDevice.c.

Function Documentation

◆ VirtioPciDeviceBindingStart()

STATIC EFI_STATUS EFIAPI VirtioPciDeviceBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  DeviceHandle,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

After we've pronounced support for a specific device in DriverBindingSupported(), we start managing said device (passed in by the Driver Execution Environment) with the following service.

See DriverBindingSupported() for specification references.

Parameters
[in]ThisThe EFI_DRIVER_BINDING_PROTOCOL object incorporating this driver (independently of any device).
[in]DeviceHandleThe supported device to drive.
[in]RemainingDevicePathRelevant only for bus drivers, ignored.
Return values
EFI_SUCCESSDriver instance has been created and initialized for the virtio-pci device, it is now accessible via VIRTIO_DEVICE_PROTOCOL.
EFI_OUT_OF_RESOURCESMemory allocation failed.
Returns
Error codes from the OpenProtocol() boot service, the PciIo protocol, VirtioPciInit(), or the InstallProtocolInterface() boot service.

Definition at line 429 of file VirtioPciDevice.c.

◆ VirtioPciDeviceBindingStop()

STATIC EFI_STATUS EFIAPI VirtioPciDeviceBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  DeviceHandle,
IN UINTN  NumberOfChildren,
IN EFI_HANDLE ChildHandleBuffer 
)

Stop driving the Virtio PCI device

Parameters
[in]ThisThe EFI_DRIVER_BINDING_PROTOCOL object incorporating this driver (independently of any device).
[in]DeviceHandleStop driving this device.
[in]NumberOfChildrenSince this function belongs to a device driver only (as opposed to a bus driver), the caller environment sets NumberOfChildren to zero, and we ignore it.
[in]ChildHandleBufferIgnored (corresponding to NumberOfChildren).
Return values
EFI_SUCCESSDriver instance has been stopped and the PCI configuration attributes have been restored.
Returns
Error codes from the OpenProtocol() or CloseProtocol(), UninstallProtocolInterface() boot services.

Definition at line 566 of file VirtioPciDevice.c.

◆ VirtioPciDeviceBindingSupported()

STATIC EFI_STATUS EFIAPI VirtioPciDeviceBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  DeviceHandle,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Device probe function for this driver.

The DXE core calls this function for any given device in order to see if the driver can drive the device.

Parameters
[in]ThisThe EFI_DRIVER_BINDING_PROTOCOL object incorporating this driver (independently of any device).
[in]DeviceHandleThe device to probe.
[in]RemainingDevicePathRelevant only for bus drivers, ignored.
Return values
EFI_SUCCESSThe driver supports the device being probed.
EFI_UNSUPPORTEDBased on virtio-pci discovery, we do not support the device.
Returns
Error codes from the OpenProtocol() boot service or the PciIo protocol.

Definition at line 238 of file VirtioPciDevice.c.

◆ VirtioPciDeviceEntryPoint()

EFI_STATUS EFIAPI VirtioPciDeviceEntryPoint ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Definition at line 704 of file VirtioPciDevice.c.

◆ VirtioPciGetDeviceName()

EFI_STATUS EFIAPI VirtioPciGetDeviceName ( IN EFI_COMPONENT_NAME_PROTOCOL This,
IN EFI_HANDLE  DeviceHandle,
IN EFI_HANDLE  ChildHandle,
IN CHAR8 *  Language,
OUT CHAR16 **  ControllerName 
)

Definition at line 674 of file VirtioPciDevice.c.

◆ VirtioPciGetDriverName()

EFI_STATUS EFIAPI VirtioPciGetDriverName ( IN EFI_COMPONENT_NAME_PROTOCOL This,
IN CHAR8 *  Language,
OUT CHAR16 **  DriverName 
)

Definition at line 657 of file VirtioPciDevice.c.

◆ VirtioPciInit()

STATIC EFI_STATUS EFIAPI VirtioPciInit ( IN OUT VIRTIO_PCI_DEVICE Device)

Initialize the VirtIo PCI Device

Parameters
[in,out]DevThe driver instance to configure. The caller is responsible for Device->PciIo's validity (ie. working IO access to the underlying virtio-pci device).
Return values
EFI_SUCCESSSetup complete.
EFI_UNSUPPORTEDThe underlying IO device doesn't support the provided address offset and read size.
Returns
Error codes from PciIo->Pci.Read().

Definition at line 328 of file VirtioPciDevice.c.

◆ VirtioPciIoRead()

EFI_STATUS EFIAPI VirtioPciIoRead ( IN VIRTIO_PCI_DEVICE Dev,
IN UINTN  FieldOffset,
IN UINTN  FieldSize,
IN UINTN  BufferSize,
OUT VOID *  Buffer 
)

Read a word from Region 0 of the device specified by PciIo.

Region 0 must be an iomem region. This is an internal function for the PCI implementation of the protocol.

Parameters
[in]DevVirtio PCI device.
[in]FieldOffsetSource offset.
[in]FieldSizeSource field size, must be in { 1, 2, 4, 8 }.
[in]BufferSizeNumber of bytes available in the target buffer. Must equal FieldSize.
[out]BufferTarget buffer.
Returns
Status code returned by PciIo->Io.Read().

Definition at line 69 of file VirtioPciDevice.c.

◆ VirtioPciIoWrite()

EFI_STATUS EFIAPI VirtioPciIoWrite ( IN VIRTIO_PCI_DEVICE Dev,
IN UINTN  FieldOffset,
IN UINTN  FieldSize,
IN UINT64  Value 
)

Write a word into Region 0 of the device specified by PciIo.

Region 0 must be an iomem region. This is an internal function for the PCI implementation of the protocol.

Parameters
[in]DevVirtio PCI device.
[in]FieldOffsetDestination offset.
[in]FieldSizeDestination field size, must be in { 1, 2, 4, 8 }.
[in]ValueLittle endian value to write, converted to UINT64. The least significant FieldSize bytes will be used.
Returns
Status code returned by PciIo->Io.Write().

Definition at line 152 of file VirtioPciDevice.c.

◆ VirtioPciUninit()

STATIC VOID EFIAPI VirtioPciUninit ( IN OUT VIRTIO_PCI_DEVICE Device)

Uninitialize the internals of a virtio-pci device that has been successfully set up with VirtioPciInit().

Parameters
[in,out]DevThe device to clean up.

Definition at line 390 of file VirtioPciDevice.c.

Variable Documentation

◆ gComponentName

Initial value:
= {
&VirtioPciGetDriverName,
&VirtioPciGetDeviceName,
"eng"
}

Definition at line 653 of file VirtioPciDevice.c.

◆ gComponentName2

Initial value:
= {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)&VirtioPciGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)&VirtioPciGetDeviceName,
"en"
}
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)

Definition at line 693 of file VirtioPciDevice.c.

◆ gDriverBinding

Initial value:
= {
0x10,
NULL,
}
#define NULL
Definition: Base.h:319
STATIC EFI_STATUS EFIAPI VirtioPciDeviceBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
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)

Definition at line 629 of file VirtioPciDevice.c.

◆ mDeviceProtocolTemplate

STATIC VIRTIO_DEVICE_PROTOCOL mDeviceProtocolTemplate
Initial value:
= {
0,
0,
VirtioPciGetDeviceFeatures,
VirtioPciSetGuestFeatures,
VirtioPciSetQueueAddress,
VirtioPciSetQueueSel,
VirtioPciSetQueueNotify,
VirtioPciSetQueueAlignment,
VirtioPciSetPageSize,
VirtioPciGetQueueSize,
VirtioPciSetQueueSize,
VirtioPciGetDeviceStatus,
VirtioPciSetDeviceStatus,
VirtioPciAllocateSharedPages,
VirtioPciFreeSharedPages,
VirtioPciMapSharedBuffer,
VirtioPciUnmapSharedBuffer,
}
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)

Definition at line 23 of file VirtioPciDevice.c.

◆ mDriverNameTable

STATIC EFI_UNICODE_STRING_TABLE mDriverNameTable[]
Initial value:
= {
{ "eng;en", L"Virtio PCI Driver" },
{ NULL, NULL }
}

Definition at line 647 of file VirtioPciDevice.c.