mirror of https://github.com/acidanthera/audk.git
OvmfPkg: Virtio10Dxe: non-transitional driver for virtio-1.0 PCI devices
This driver implements the VIRTIO_DEVICE_PROTOCOL for non-transitional PCI devices, based on the virtio-1.0 specification (csprd05). Non-transitional means that it only binds QEMU's virtio-xxx-pci devices that receive the ",disable-legacy=on,disable-modern=off" properties on the QEMU command line. These devices have distinct PCI Device IDs from those that are bound by VirtioPciDeviceDxe. The central abstraction of this driver is the VIRTIO_1_0_CONFIG type. It is practically a "fat pointer" to a register block. The pointed-to register block - may or may not exist (the latter being mostly useful for virtio-1.0 devices that have no device-specific registers), - lives in one of the device's BARs, - lives in an IO or MMIO BAR, - lives at an offset relative to the BAR start, - has its size also maintained. Such VIRTIO_1_0_CONFIG "fat pointers" (i.e., the locations of the register blocks) are parsed from vendor capabilities that reside in the device's standard PCI capabilities list (in PCI config space). Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Acked-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
parent
c6e2d064ab
commit
9399f68ae3
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,56 @@
|
||||||
|
/** @file
|
||||||
|
Private definitions of the VirtIo 1.0 driver.
|
||||||
|
|
||||||
|
Copyright (C) 2016, Red Hat, Inc.
|
||||||
|
|
||||||
|
This program and the accompanying materials are licensed and made available
|
||||||
|
under the terms and conditions of the BSD License which accompanies this
|
||||||
|
distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
|
||||||
|
WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _VIRTIO_1_0_DXE_H_
|
||||||
|
#define _VIRTIO_1_0_DXE_H_
|
||||||
|
|
||||||
|
#include <Protocol/PciIo.h>
|
||||||
|
#include <Protocol/VirtioDevice.h>
|
||||||
|
|
||||||
|
#define VIRTIO_1_0_SIGNATURE SIGNATURE_32 ('V', 'I', 'O', '1')
|
||||||
|
|
||||||
|
//
|
||||||
|
// Type of the PCI BAR that contains a VirtIo 1.0 config structure.
|
||||||
|
//
|
||||||
|
typedef enum {
|
||||||
|
Virtio10BarTypeMem,
|
||||||
|
Virtio10BarTypeIo
|
||||||
|
} VIRTIO_1_0_BAR_TYPE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// The type below defines the access to a VirtIo 1.0 config structure.
|
||||||
|
//
|
||||||
|
typedef struct {
|
||||||
|
BOOLEAN Exists; // The device exposes this structure
|
||||||
|
VIRTIO_1_0_BAR_TYPE BarType;
|
||||||
|
UINT8 Bar;
|
||||||
|
UINT32 Offset; // Offset into BAR where structure starts
|
||||||
|
UINT32 Length; // Length of structure in BAR.
|
||||||
|
} VIRTIO_1_0_CONFIG;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT32 Signature;
|
||||||
|
VIRTIO_DEVICE_PROTOCOL VirtIo;
|
||||||
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
|
UINT64 OriginalPciAttributes;
|
||||||
|
VIRTIO_1_0_CONFIG CommonConfig; // Common settings
|
||||||
|
VIRTIO_1_0_CONFIG NotifyConfig; // Notifications
|
||||||
|
UINT32 NotifyOffsetMultiplier;
|
||||||
|
VIRTIO_1_0_CONFIG SpecificConfig; // Device specific settings
|
||||||
|
} VIRTIO_1_0_DEV;
|
||||||
|
|
||||||
|
#define VIRTIO_1_0_FROM_VIRTIO_DEVICE(Device) \
|
||||||
|
CR (Device, VIRTIO_1_0_DEV, VirtIo, VIRTIO_1_0_SIGNATURE)
|
||||||
|
|
||||||
|
#endif // _VIRTIO_1_0_DXE_H_
|
|
@ -0,0 +1,40 @@
|
||||||
|
## @file
|
||||||
|
# A non-transitional driver for VirtIo 1.0 PCI devices.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2016, Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are licensed and made available
|
||||||
|
# under the terms and conditions of the BSD License which accompanies this
|
||||||
|
# distribution. The full text of the license may be found at
|
||||||
|
# http://opensource.org/licenses/bsd-license.php
|
||||||
|
#
|
||||||
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = Virtio10
|
||||||
|
FILE_GUID = 0170F60C-1D40-4651-956D-F0BD9879D527
|
||||||
|
MODULE_TYPE = UEFI_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = Virtio10EntryPoint
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
Virtio10.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
OvmfPkg/OvmfPkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
DebugLib
|
||||||
|
MemoryAllocationLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiDriverEntryPoint
|
||||||
|
UefiLib
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiPciIoProtocolGuid ## TO_START
|
||||||
|
gVirtioDeviceProtocolGuid ## BY_START
|
Loading…
Reference in New Issue