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

Go to the source code of this file.

Functions

STATIC EFI_STATUS Virtio10Transfer (IN EFI_PCI_IO_PROTOCOL *PciIo, IN VIRTIO_1_0_CONFIG *Config, IN BOOLEAN Write, IN UINTN FieldOffset, IN UINTN FieldSize, IN OUT VOID *Buffer)
 
STATIC EFI_STATUS GetBarType (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, OUT VIRTIO_1_0_BAR_TYPE *BarType)
 
STATIC EFI_STATUS ParseCapabilities (IN OUT VIRTIO_1_0_DEV *Device)
 
STATIC VOID UpdateAttributes (IN VIRTIO_1_0_CONFIG *Config, IN OUT UINT64 *Attributes)
 
STATIC EFI_STATUS EFIAPI Virtio10GetDeviceFeatures (IN VIRTIO_DEVICE_PROTOCOL *This, OUT UINT64 *DeviceFeatures)
 
STATIC EFI_STATUS EFIAPI Virtio10SetGuestFeatures (IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT64 Features)
 
STATIC EFI_STATUS EFIAPI Virtio10SetQueueAddress (IN VIRTIO_DEVICE_PROTOCOL *This, IN VRING *Ring, IN UINT64 RingBaseShift)
 
STATIC EFI_STATUS EFIAPI Virtio10SetQueueSel (IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT16 Index)
 
STATIC EFI_STATUS EFIAPI Virtio10SetQueueNotify (IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT16 Index)
 
STATIC EFI_STATUS EFIAPI Virtio10SetQueueAlign (IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT32 Alignment)
 
STATIC EFI_STATUS EFIAPI Virtio10SetPageSize (IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT32 PageSize)
 
STATIC EFI_STATUS EFIAPI Virtio10GetQueueNumMax (IN VIRTIO_DEVICE_PROTOCOL *This, OUT UINT16 *QueueNumMax)
 
STATIC EFI_STATUS EFIAPI Virtio10SetQueueNum (IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT16 QueueSize)
 
STATIC EFI_STATUS EFIAPI Virtio10GetDeviceStatus (IN VIRTIO_DEVICE_PROTOCOL *This, OUT UINT8 *DeviceStatus)
 
STATIC EFI_STATUS EFIAPI Virtio10SetDeviceStatus (IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT8 DeviceStatus)
 
STATIC EFI_STATUS EFIAPI Virtio10WriteDevice (IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN FieldOffset, IN UINTN FieldSize, IN UINT64 Value)
 
STATIC EFI_STATUS EFIAPI Virtio10ReadDevice (IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN FieldOffset, IN UINTN FieldSize, IN UINTN BufferSize, OUT VOID *Buffer)
 
STATIC EFI_STATUS EFIAPI Virtio10AllocateSharedPages (IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN Pages, IN OUT VOID **HostAddress)
 
STATIC VOID EFIAPI Virtio10FreeSharedPages (IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN Pages, IN VOID *HostAddress)
 
STATIC EFI_STATUS EFIAPI Virtio10MapSharedBuffer (IN VIRTIO_DEVICE_PROTOCOL *This, IN VIRTIO_MAP_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
 
STATIC EFI_STATUS EFIAPI Virtio10UnmapSharedBuffer (IN VIRTIO_DEVICE_PROTOCOL *This, IN VOID *Mapping)
 
STATIC EFI_STATUS EFIAPI Virtio10BindingSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
STATIC EFI_STATUS EFIAPI Virtio10BindingStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
STATIC EFI_STATUS EFIAPI Virtio10BindingStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
STATIC EFI_STATUS EFIAPI Virtio10GetDriverName (IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
 
STATIC EFI_STATUS EFIAPI Virtio10GetDeviceName (IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_HANDLE ChildHandle, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
 
EFI_STATUS EFIAPI Virtio10EntryPoint (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

STATIC CONST VIRTIO_DEVICE_PROTOCOL mVirtIoTemplate
 
STATIC EFI_DRIVER_BINDING_PROTOCOL mDriverBinding
 
STATIC EFI_UNICODE_STRING_TABLE mDriverNameTable []
 
STATIC EFI_COMPONENT_NAME_PROTOCOL mComponentName
 
STATIC EFI_COMPONENT_NAME2_PROTOCOL mComponentName2
 

Detailed Description

A non-transitional driver for VirtIo 1.0 PCI devices.

Copyright (C) 2016, Red Hat, Inc. Copyright (C) 2017, AMD Inc, All rights reserved.

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

Definition in file Virtio10.c.

Function Documentation

◆ GetBarType()

STATIC EFI_STATUS GetBarType ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  BarIndex,
OUT VIRTIO_1_0_BAR_TYPE *  BarType 
)

Determine if a PCI BAR is IO or MMIO.

Parameters
[in]PciIoThe EFI_PCI_IO_PROTOCOL instance that represents the device.
[in]BarIndexThe number of the BAR whose type the caller is interested in.
[out]BarTypeOn output, a VIRTIO_1_0_BAR_TYPE value that gives the type of the BAR.
Return values
EFI_SUCCESSThe BAR type has been recognized and stored in BarType.
EFI_UNSUPPORTEDThe BAR type couldn't be identified.
Returns
Error codes from EFI_PCI_IO_PROTOCOL.GetBarAttributes().

Definition at line 147 of file Virtio10.c.

◆ ParseCapabilities()

STATIC EFI_STATUS ParseCapabilities ( IN OUT VIRTIO_1_0_DEV Device)

Definition at line 207 of file Virtio10.c.

◆ UpdateAttributes()

STATIC VOID UpdateAttributes ( IN VIRTIO_1_0_CONFIG Config,
IN OUT UINT64 *  Attributes 
)

Accumulate the BAR type of a virtio-1.0 register block into a UINT64 attribute map, such that the latter is suitable for enabling IO / MMIO decoding with EFI_PCI_IO_PROTOCOL.Attributes().

Parameters
[in]ConfigThe "fat pointer" structure that identifies the register block. It is allowed for the register block not to exist.
[in,out]AttributesOn output, if the register block exists, EFI_PCI_IO_ATTRIBUTE_MEMORY or EFI_PCI_IO_ATTRIBUTE_IO is OR-ed into Attributes, according to the register block's BAR type.

Definition at line 358 of file Virtio10.c.

◆ Virtio10AllocateSharedPages()

STATIC EFI_STATUS EFIAPI Virtio10AllocateSharedPages ( IN VIRTIO_DEVICE_PROTOCOL This,
IN UINTN  Pages,
IN OUT VOID **  HostAddress 
)

Definition at line 845 of file Virtio10.c.

◆ Virtio10BindingStart()

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

Definition at line 1058 of file Virtio10.c.

◆ Virtio10BindingStop()

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

Definition at line 1169 of file Virtio10.c.

◆ Virtio10BindingSupported()

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

Definition at line 983 of file Virtio10.c.

◆ Virtio10EntryPoint()

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

Definition at line 1295 of file Virtio10.c.

◆ Virtio10FreeSharedPages()

STATIC VOID EFIAPI Virtio10FreeSharedPages ( IN VIRTIO_DEVICE_PROTOCOL This,
IN UINTN  Pages,
IN VOID *  HostAddress 
)

Definition at line 870 of file Virtio10.c.

◆ Virtio10GetDeviceFeatures()

STATIC EFI_STATUS EFIAPI Virtio10GetDeviceFeatures ( IN VIRTIO_DEVICE_PROTOCOL This,
OUT UINT64 *  DeviceFeatures 
)

Definition at line 377 of file Virtio10.c.

◆ Virtio10GetDeviceName()

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

Definition at line 1264 of file Virtio10.c.

◆ Virtio10GetDeviceStatus()

STATIC EFI_STATUS EFIAPI Virtio10GetDeviceStatus ( IN VIRTIO_DEVICE_PROTOCOL This,
OUT UINT8 *  DeviceStatus 
)

Definition at line 740 of file Virtio10.c.

◆ Virtio10GetDriverName()

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

Definition at line 1246 of file Virtio10.c.

◆ Virtio10GetQueueNumMax()

STATIC EFI_STATUS EFIAPI Virtio10GetQueueNumMax ( IN VIRTIO_DEVICE_PROTOCOL This,
OUT UINT16 *  QueueNumMax 
)

Definition at line 691 of file Virtio10.c.

◆ Virtio10MapSharedBuffer()

STATIC EFI_STATUS EFIAPI Virtio10MapSharedBuffer ( IN VIRTIO_DEVICE_PROTOCOL This,
IN VIRTIO_MAP_OPERATION  Operation,
IN VOID *  HostAddress,
IN OUT UINTN NumberOfBytes,
OUT EFI_PHYSICAL_ADDRESS DeviceAddress,
OUT VOID **  Mapping 
)

Definition at line 890 of file Virtio10.c.

◆ Virtio10ReadDevice()

STATIC EFI_STATUS EFIAPI Virtio10ReadDevice ( IN VIRTIO_DEVICE_PROTOCOL This,
IN UINTN  FieldOffset,
IN UINTN  FieldSize,
IN UINTN  BufferSize,
OUT VOID *  Buffer 
)

Definition at line 814 of file Virtio10.c.

◆ Virtio10SetDeviceStatus()

STATIC EFI_STATUS EFIAPI Virtio10SetDeviceStatus ( IN VIRTIO_DEVICE_PROTOCOL This,
IN UINT8  DeviceStatus 
)

Definition at line 764 of file Virtio10.c.

◆ Virtio10SetGuestFeatures()

STATIC EFI_STATUS EFIAPI Virtio10SetGuestFeatures ( IN VIRTIO_DEVICE_PROTOCOL This,
IN UINT64  Features 
)

Definition at line 429 of file Virtio10.c.

◆ Virtio10SetPageSize()

STATIC EFI_STATUS EFIAPI Virtio10SetPageSize ( IN VIRTIO_DEVICE_PROTOCOL This,
IN UINT32  PageSize 
)

Definition at line 680 of file Virtio10.c.

◆ Virtio10SetQueueAddress()

STATIC EFI_STATUS EFIAPI Virtio10SetQueueAddress ( IN VIRTIO_DEVICE_PROTOCOL This,
IN VRING Ring,
IN UINT64  RingBaseShift 
)

Definition at line 483 of file Virtio10.c.

◆ Virtio10SetQueueAlign()

STATIC EFI_STATUS EFIAPI Virtio10SetQueueAlign ( IN VIRTIO_DEVICE_PROTOCOL This,
IN UINT32  Alignment 
)

Definition at line 669 of file Virtio10.c.

◆ Virtio10SetQueueNotify()

STATIC EFI_STATUS EFIAPI Virtio10SetQueueNotify ( IN VIRTIO_DEVICE_PROTOCOL This,
IN UINT16  Index 
)

Definition at line 577 of file Virtio10.c.

◆ Virtio10SetQueueNum()

STATIC EFI_STATUS EFIAPI Virtio10SetQueueNum ( IN VIRTIO_DEVICE_PROTOCOL This,
IN UINT16  QueueSize 
)

Definition at line 715 of file Virtio10.c.

◆ Virtio10SetQueueSel()

STATIC EFI_STATUS EFIAPI Virtio10SetQueueSel ( IN VIRTIO_DEVICE_PROTOCOL This,
IN UINT16  Index 
)

Definition at line 553 of file Virtio10.c.

◆ Virtio10Transfer()

STATIC EFI_STATUS Virtio10Transfer ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN VIRTIO_1_0_CONFIG Config,
IN BOOLEAN  Write,
IN UINTN  FieldOffset,
IN UINTN  FieldSize,
IN OUT VOID *  Buffer 
)

Transfer data between the caller and a register in a virtio-1.0 register block.

Parameters
[in]PciIoThe EFI_PCI_IO_PROTOCOL instance that represents the device.
[in]ConfigThe "fat pointer" structure that identifies the register block to access.
[in]WriteTRUE if the register should be written, FALSE if the register should be read.
[in]FieldOffsetThe offset of the register within the register block.
[in]FieldSizeThe size of the register within the register block. Can be one of 1, 2, 4 and 8. Accesses to 8-byte registers are broken up into two 4-byte accesses.
[in,out]BufferWhen Write is TRUE, the register is written with data from Buffer. When Write is FALSE, the caller receives the register value into Buffer.
Return values
EFI_SUCCESSRegister access successful.
EFI_INVALID_PARAMETERThe register block pointed-to by Config doesn't exist; or FieldOffset and FieldSize would overflow the register block; or FieldSize is invalid.
Returns
Error codes from EFI_PCI_IO_PROTOCOL.(Io|Mem).(Read|Write) member functions.

Definition at line 67 of file Virtio10.c.

◆ Virtio10UnmapSharedBuffer()

STATIC EFI_STATUS EFIAPI Virtio10UnmapSharedBuffer ( IN VIRTIO_DEVICE_PROTOCOL This,
IN VOID *  Mapping 
)

Definition at line 936 of file Virtio10.c.

◆ Virtio10WriteDevice()

STATIC EFI_STATUS EFIAPI Virtio10WriteDevice ( IN VIRTIO_DEVICE_PROTOCOL This,
IN UINTN  FieldOffset,
IN UINTN  FieldSize,
IN UINT64  Value 
)

Definition at line 788 of file Virtio10.c.

Variable Documentation

◆ mComponentName

Initial value:
= {
&Virtio10GetDriverName,
&Virtio10GetDeviceName,
"eng"
}

Definition at line 1241 of file Virtio10.c.

◆ mComponentName2

Initial value:
= {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)&Virtio10GetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)&Virtio10GetDeviceName,
"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 1283 of file Virtio10.c.

◆ mDriverBinding

Initial value:
= {
&Virtio10BindingSupported,
&Virtio10BindingStart,
&Virtio10BindingStop,
0x10,
NULL,
}
#define NULL
Definition: Base.h:319

Definition at line 1220 of file Virtio10.c.

◆ mDriverNameTable

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

Definition at line 1235 of file Virtio10.c.

◆ mVirtIoTemplate

Initial value:
= {
VIRTIO_SPEC_REVISION (1, 0, 0),
0,
Virtio10GetDeviceFeatures,
Virtio10SetGuestFeatures,
Virtio10SetQueueAddress,
Virtio10SetQueueSel,
Virtio10SetQueueNotify,
Virtio10SetQueueAlign,
Virtio10SetPageSize,
Virtio10GetQueueNumMax,
Virtio10SetQueueNum,
Virtio10GetDeviceStatus,
Virtio10SetDeviceStatus,
Virtio10WriteDevice,
Virtio10ReadDevice,
Virtio10AllocateSharedPages,
Virtio10FreeSharedPages,
Virtio10MapSharedBuffer,
Virtio10UnmapSharedBuffer
}

Definition at line 954 of file Virtio10.c.