1 | /** @file
|
---|
2 | Definitions from the VirtIo 1.0 specification (csprd05).
|
---|
3 |
|
---|
4 | Copyright (C) 2016, Red Hat, Inc.
|
---|
5 | Copyright (C) 2017, AMD, Inc.
|
---|
6 |
|
---|
7 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #ifndef _VIRTIO_1_0_H_
|
---|
11 | #define _VIRTIO_1_0_H_
|
---|
12 |
|
---|
13 | #include <IndustryStandard/Pci23.h>
|
---|
14 | #include <IndustryStandard/Virtio095.h>
|
---|
15 |
|
---|
16 | //
|
---|
17 | // Subsystem Device IDs (to be) introduced in VirtIo 1.0
|
---|
18 | //
|
---|
19 | #define VIRTIO_SUBSYSTEM_GPU_DEVICE 16
|
---|
20 | //
|
---|
21 | // Subsystem Device IDs from the VirtIo spec at git commit 87fa6b5d8155;
|
---|
22 | // <https://github.com/oasis-tcs/virtio-spec/tree/87fa6b5d8155>.
|
---|
23 | //
|
---|
24 | #define VIRTIO_SUBSYSTEM_FILESYSTEM 26
|
---|
25 |
|
---|
26 | //
|
---|
27 | // Structures for parsing the VirtIo 1.0 specific PCI capabilities from the
|
---|
28 | // config space
|
---|
29 | //
|
---|
30 | #pragma pack (1)
|
---|
31 | typedef struct {
|
---|
32 | EFI_PCI_CAPABILITY_VENDOR_HDR VendorHdr;
|
---|
33 | UINT8 ConfigType; // Identifies the specific VirtIo 1.0 config structure
|
---|
34 | UINT8 Bar; // The BAR that contains the structure
|
---|
35 | UINT8 Padding[3];
|
---|
36 | UINT32 Offset; // Offset within Bar until the start of the structure
|
---|
37 | UINT32 Length; // Length of the structure
|
---|
38 | } VIRTIO_PCI_CAP;
|
---|
39 | #pragma pack ()
|
---|
40 |
|
---|
41 | //
|
---|
42 | // Values for the VIRTIO_PCI_CAP.ConfigType field
|
---|
43 | //
|
---|
44 | #define VIRTIO_PCI_CAP_COMMON_CFG 1 // Common configuration
|
---|
45 | #define VIRTIO_PCI_CAP_NOTIFY_CFG 2 // Notifications
|
---|
46 | #define VIRTIO_PCI_CAP_DEVICE_CFG 4 // Device specific configuration
|
---|
47 |
|
---|
48 | //
|
---|
49 | // Structure pointed-to by Bar and Offset in VIRTIO_PCI_CAP when ConfigType is
|
---|
50 | // VIRTIO_PCI_CAP_COMMON_CFG
|
---|
51 | //
|
---|
52 | #pragma pack (1)
|
---|
53 | typedef struct {
|
---|
54 | UINT32 DeviceFeatureSelect;
|
---|
55 | UINT32 DeviceFeature;
|
---|
56 | UINT32 DriverFeatureSelect;
|
---|
57 | UINT32 DriverFeature;
|
---|
58 | UINT16 MsixConfig;
|
---|
59 | UINT16 NumQueues;
|
---|
60 | UINT8 DeviceStatus;
|
---|
61 | UINT8 ConfigGeneration;
|
---|
62 | UINT16 QueueSelect;
|
---|
63 | UINT16 QueueSize;
|
---|
64 | UINT16 QueueMsixVector;
|
---|
65 | UINT16 QueueEnable;
|
---|
66 | UINT16 QueueNotifyOff;
|
---|
67 | UINT64 QueueDesc;
|
---|
68 | UINT64 QueueAvail;
|
---|
69 | UINT64 QueueUsed;
|
---|
70 | } VIRTIO_PCI_COMMON_CFG;
|
---|
71 | #pragma pack ()
|
---|
72 |
|
---|
73 | //
|
---|
74 | // VirtIo 1.0 device status bits
|
---|
75 | //
|
---|
76 | #define VSTAT_FEATURES_OK BIT3
|
---|
77 |
|
---|
78 | //
|
---|
79 | // VirtIo 1.0 reserved (device-independent) feature bits
|
---|
80 | //
|
---|
81 | #define VIRTIO_F_VERSION_1 BIT32
|
---|
82 | #define VIRTIO_F_IOMMU_PLATFORM BIT33
|
---|
83 |
|
---|
84 | //
|
---|
85 | // MMIO VirtIo Header Offsets
|
---|
86 | //
|
---|
87 | #define VIRTIO_MMIO_OFFSET_QUEUE_READY 0x44
|
---|
88 | #define VIRTIO_MMIO_OFFSET_QUEUE_DESC_LO 0x80
|
---|
89 | #define VIRTIO_MMIO_OFFSET_QUEUE_DESC_HI 0x84
|
---|
90 | #define VIRTIO_MMIO_OFFSET_QUEUE_AVAIL_LO 0x90
|
---|
91 | #define VIRTIO_MMIO_OFFSET_QUEUE_AVAIL_HI 0x94
|
---|
92 | #define VIRTIO_MMIO_OFFSET_QUEUE_USED_LO 0xa0
|
---|
93 | #define VIRTIO_MMIO_OFFSET_QUEUE_USED_HI 0xa4
|
---|
94 | #define VIRTIO_MMIO_OFFSET_CONFIG_GENERATION 0xfc
|
---|
95 |
|
---|
96 | #endif // _VIRTIO_1_0_H_
|
---|