2016-03-11 20:51:12 +01:00
|
|
|
/** @file
|
|
|
|
Definitions from the VirtIo 1.0 specification (csprd05).
|
|
|
|
|
|
|
|
Copyright (C) 2016, Red Hat, Inc.
|
2017-08-25 12:37:46 +02:00
|
|
|
Copyright (C) 2017, AMD, Inc.
|
2016-03-11 20:51:12 +01:00
|
|
|
|
2019-04-04 01:06:33 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2016-03-11 20:51:12 +01:00
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef _VIRTIO_1_0_H_
|
|
|
|
#define _VIRTIO_1_0_H_
|
|
|
|
|
2018-05-04 16:40:52 +02:00
|
|
|
#include <IndustryStandard/Pci23.h>
|
2016-03-11 20:51:12 +01:00
|
|
|
#include <IndustryStandard/Virtio095.h>
|
|
|
|
|
2016-08-15 16:26:29 +02:00
|
|
|
//
|
|
|
|
// Subsystem Device IDs (to be) introduced in VirtIo 1.0
|
|
|
|
//
|
|
|
|
#define VIRTIO_SUBSYSTEM_GPU_DEVICE 16
|
OvmfPkg/VirtioFsDxe: DriverBinding: open VirtioDevice, install SimpleFs
Complete the Supported, Start, and Stop member functions of
EFI_DRIVER_BINDING_PROTOCOL sufficiently for exercising the UEFI driver
model:
- bind virtio-fs devices,
- produce placeholder EFI_SIMPLE_FILE_SYSTEM_PROTOCOL instances on them.
On the "TO_START" (= Virtio) side, the VirtioFsBindingSupported() function
verifies the Virtio subsystem ID for the virtio-fs device (decimal 26 --
see
<https://github.com/oasis-tcs/virtio-spec/blob/87fa6b5d8155/virtio-fs.tex>).
Beyond that, no actual Virtio setup is performed for now. Those bits are
going to be implemented later in this series.
On the "BY_START" (= UEFI filesystem) side, the VirtioFsOpenVolume()
function -- which is the sole EFI_SIMPLE_FILE_SYSTEM_PROTOCOL member
function -- is a stub; it always returns EFI_NO_MEDIA, for now.
The "CONNECT", "DISCONNECT", and "MAP -R" UEFI Shell commands can be used
to test this patch.
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3097
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20201216211125.19496-4-lersek@redhat.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
2020-12-16 22:10:40 +01:00
|
|
|
//
|
|
|
|
// Subsystem Device IDs from the VirtIo spec at git commit 87fa6b5d8155;
|
|
|
|
// <https://github.com/oasis-tcs/virtio-spec/tree/87fa6b5d8155>.
|
|
|
|
//
|
|
|
|
#define VIRTIO_SUBSYSTEM_FILESYSTEM 26
|
2016-08-15 16:26:29 +02:00
|
|
|
|
2016-03-11 20:51:12 +01:00
|
|
|
//
|
|
|
|
// Structures for parsing the VirtIo 1.0 specific PCI capabilities from the
|
|
|
|
// config space
|
|
|
|
//
|
|
|
|
#pragma pack (1)
|
|
|
|
typedef struct {
|
2018-05-04 16:40:52 +02:00
|
|
|
EFI_PCI_CAPABILITY_VENDOR_HDR VendorHdr;
|
2016-03-11 20:51:12 +01:00
|
|
|
UINT8 ConfigType; // Identifies the specific VirtIo 1.0 config structure
|
|
|
|
UINT8 Bar; // The BAR that contains the structure
|
|
|
|
UINT8 Padding[3];
|
|
|
|
UINT32 Offset; // Offset within Bar until the start of the structure
|
|
|
|
UINT32 Length; // Length of the structure
|
|
|
|
} VIRTIO_PCI_CAP;
|
|
|
|
#pragma pack ()
|
|
|
|
|
|
|
|
//
|
|
|
|
// Values for the VIRTIO_PCI_CAP.ConfigType field
|
|
|
|
//
|
|
|
|
#define VIRTIO_PCI_CAP_COMMON_CFG 1 // Common configuration
|
|
|
|
#define VIRTIO_PCI_CAP_NOTIFY_CFG 2 // Notifications
|
|
|
|
#define VIRTIO_PCI_CAP_DEVICE_CFG 4 // Device specific configuration
|
|
|
|
|
|
|
|
//
|
|
|
|
// Structure pointed-to by Bar and Offset in VIRTIO_PCI_CAP when ConfigType is
|
|
|
|
// VIRTIO_PCI_CAP_COMMON_CFG
|
|
|
|
//
|
|
|
|
#pragma pack (1)
|
|
|
|
typedef struct {
|
|
|
|
UINT32 DeviceFeatureSelect;
|
|
|
|
UINT32 DeviceFeature;
|
|
|
|
UINT32 DriverFeatureSelect;
|
|
|
|
UINT32 DriverFeature;
|
|
|
|
UINT16 MsixConfig;
|
|
|
|
UINT16 NumQueues;
|
|
|
|
UINT8 DeviceStatus;
|
|
|
|
UINT8 ConfigGeneration;
|
|
|
|
UINT16 QueueSelect;
|
|
|
|
UINT16 QueueSize;
|
|
|
|
UINT16 QueueMsixVector;
|
|
|
|
UINT16 QueueEnable;
|
|
|
|
UINT16 QueueNotifyOff;
|
|
|
|
UINT64 QueueDesc;
|
|
|
|
UINT64 QueueAvail;
|
|
|
|
UINT64 QueueUsed;
|
|
|
|
} VIRTIO_PCI_COMMON_CFG;
|
|
|
|
#pragma pack ()
|
|
|
|
|
|
|
|
//
|
|
|
|
// VirtIo 1.0 device status bits
|
|
|
|
//
|
|
|
|
#define VSTAT_FEATURES_OK BIT3
|
|
|
|
|
|
|
|
//
|
|
|
|
// VirtIo 1.0 reserved (device-independent) feature bits
|
|
|
|
//
|
2017-08-25 12:37:46 +02:00
|
|
|
#define VIRTIO_F_VERSION_1 BIT32
|
|
|
|
#define VIRTIO_F_IOMMU_PLATFORM BIT33
|
2016-03-11 20:51:12 +01:00
|
|
|
|
2021-08-27 15:44:53 +02:00
|
|
|
//
|
|
|
|
// MMIO VirtIo Header Offsets
|
|
|
|
//
|
|
|
|
#define VIRTIO_MMIO_OFFSET_QUEUE_READY 0x44
|
|
|
|
#define VIRTIO_MMIO_OFFSET_QUEUE_DESC_LO 0x80
|
|
|
|
#define VIRTIO_MMIO_OFFSET_QUEUE_DESC_HI 0x84
|
|
|
|
#define VIRTIO_MMIO_OFFSET_QUEUE_AVAIL_LO 0x90
|
|
|
|
#define VIRTIO_MMIO_OFFSET_QUEUE_AVAIL_HI 0x94
|
|
|
|
#define VIRTIO_MMIO_OFFSET_QUEUE_USED_LO 0xa0
|
|
|
|
#define VIRTIO_MMIO_OFFSET_QUEUE_USED_HI 0xa4
|
|
|
|
#define VIRTIO_MMIO_OFFSET_CONFIG_GENERATION 0xfc
|
|
|
|
|
2016-03-11 20:51:12 +01:00
|
|
|
#endif // _VIRTIO_1_0_H_
|