Modules/InitRD - Fix input path for externals
[tpg/acess2.git] / KernelLand / Modules / Libraries / VirtIO / include / virtio_hw.h
1 /*
2  * Acess2 VirtIO Common
3  * - By John Hodge (thePowersGang)
4  *
5  * virtio_hw.h
6  * - VirtIO Hardware Header
7  *
8  * Reference: LinuxKernel:/Documentation/virtual/virtio-spec.txt
9  */
10 #ifndef _VIRTIO__VIRTIO_HW_H_
11 #define _VIRTIO__VIRTIO_HW_H_
12
13 //#if _MODULE_NAME_ != "VirtIOCommon"
14 //#error "This header is a VirtIO internal"
15 //#endif
16
17 #if 0
18 typedef struct sVirtIO_Header   tVirtIO_Header;
19
20 struct sVirtIO_Header
21 {
22         volatile Uint32 DeviceFeatures; // R
23         volatile Uint32 GuestFeatures;  // RW
24         Uint32  QueueAddress;   // RW
25         volatile Uint16 QueueSize;      // R
26         volatile Uint16 QueueSelect;    // RW
27         volatile Uint16 QueueNotify;    // RW
28         volatile Uint8  DeviceStatus;   // RW
29         volatile Uint8  ISRStatus;      // R
30 };
31 #endif
32 enum eVirtIO_IOAddrs
33 {
34         VIRTIO_REG_DEVFEAT      = 0x00, // R
35         VIRTIO_REG_GUESTFEAT    = 0x04, // RW
36         VIRTIO_REG_QUEUEADDR    = 0x08, // RW
37         VIRTIO_REG_QUEUESIZE    = 0x0C, // R
38         VIRTIO_REG_QUEUESELECT  = 0x0E, // RW
39         VIRTIO_REG_QUEUENOTIFY  = 0x10, // RW
40         VIRTIO_REG_DEVSTS       = 0x12, // RW
41         VIRTIO_REG_ISRSTS       = 0x13, // R
42
43         VIRTIO_REG_DEVSPEC_0    = 0x14, 
44
45         VIRTIO_REG_MSIX_CONFIGV = 0x14, // RW
46         VIRTIO_REG_MSIX_QUEUEV  = 0x16, // RW
47         
48         VIRTIO_REG_DEVSPEC_1    = 0x18,
49 };
50
51 enum eVirtIO_DeviceStatuses
52 {
53         VIRTIO_DEVSTS_RESET       = 0x00,       // Reset device
54         VIRTIO_DEVSTS_ACKNOWLEDGE = 0x01,       // Acknowledged device
55         VIRTIO_DEVSTS_DRIVER      = 0x02,       // Driver avaliable
56         VIRTIO_DEVSTS_DRIVER_OK   = 0x04,       // Driver initialised
57         VIRTIO_DEVSTS_FAILED      = 0x80,       // Something went wrong
58 };
59
60 enum eVirtIO_ISRBits
61 {
62         VIRTIO_ISR_QUEUE        = 0x01,
63 };
64
65 // VirtIO Ring Structure
66 // +0           : Ring descriptors (given by tVirtIO_Header::QueueSize)
67 // +QS*16       : Avaliable ring
68 // +PAD[4096]   : Used ring
69
70 #define VRING_AVAIL_F_NO_INTERRUPT      0x1
71
72 struct sVirtIO_AvailRing
73 {
74         // [0]: Disable IRQ on descriptor use
75         Uint16  Flags;
76         Uint16  Idx;
77         Uint16  Ring[]; // tVirtIO_Header::QueueSize entries
78         //Uint16        UsedEvent;
79 };
80
81 struct sVirtIO_UsedRing
82 {
83         // [0]: Do not notify when descriptors added
84         Uint16  Flags;
85         Uint16  Idx;
86         struct {
87                 Uint32  ID;
88                 Uint32  Len;
89         } Ring[];
90         // Uint16       AvailEvent;
91 };
92
93 #define VRING_DESC_F_NEXT       0x1
94 #define VRING_DESC_F_WRITE      0x2
95 #define VRING_DESC_F_INDIRECT   0x4
96
97 struct sVirtIO_RingDesc
98 {
99         Uint64  Addr;
100         Uint32  Len;
101         // [0]: Continue using the `Next` field
102         // [1]: Write-only (insead of Read-only)
103         // [2]: Indirect buffer (list of buffer descriptors)
104         Uint16  Flags;
105         Uint16  Next;   // Index
106 };
107
108 #endif
109

UCC git Repository :: git.ucc.asn.au