XenevaOS
Loading...
Searching...
No Matches
hwdev.h
Go to the documentation of this file.
1
19#ifndef __HWDEV_H__
20#define __HWDEV_H__
21
22#include <stdint.h>
23
24#define HWDEV_IOC_PCI_OPEN 0x4801 /* on /dev/hwdev; arg: HwdevPciOpen */
25#define HWDEV_IOC_CFG_READ 0x4802 /* on a handle; arg: HwdevCfg */
26#define HWDEV_IOC_CFG_WRITE 0x4803 /* on a handle; arg: HwdevCfg */
27#define HWDEV_IOC_BAR_INFO 0x4804 /* on a handle; arg: HwdevBar */
28#define HWDEV_IOC_MAP_BAR 0x4805 /* on a handle; arg: HwdevMap */
29#define HWDEV_IOC_DMA_ALLOC 0x4806 /* on a handle; arg: HwdevDma */
30#define HWDEV_IOC_IRQ_SETUP 0x4807 /* on a handle; arg: HwdevIrq */
31#define HWDEV_IOC_IRQ_WAIT 0x4808 /* on a handle; arg: HwdevIrqWait */
32#define HWDEV_IOC_IRQ_ACK 0x4809 /* on a handle; arg: HwdevIrqAck */
33
34#define HWDEV_OK 0
35#define HWDEV_E_PERM -1 /* caller is not a driver process / lacks the right */
36#define HWDEV_E_NODEV -2 /* no such PCI function */
37#define HWDEV_E_BUSY -3 /* owned by an in-kernel driver or another process */
38#define HWDEV_E_INVAL -4 /* bad argument, out-of-range, or forbidden offset */
39#define HWDEV_E_NOMEM -5
40
41#define HWDEV_BAR_MEM 0x1
42#define HWDEV_BAR_IO 0x2
43#define HWDEV_BAR_64BIT 0x4
44
45/* instance selects the Nth function with that vendor/device id (0 = first), for
46 * machines with several identical devices, such as a virtio keyboard and tablet */
47typedef struct { uint16_t vendor; uint16_t device; int32_t handle; uint32_t instance; uint32_t reserved; } HwdevPciOpen;
48typedef struct { uint32_t offset; uint32_t size; uint32_t value; } HwdevCfg; /* size 1, 2 or 4 */
50typedef struct { uint32_t bar; uint32_t reserved; uint64_t offset; uint64_t length; uint64_t uaddr; } HwdevMap;
51typedef struct { uint64_t length; uint64_t uaddr; uint64_t phys; } HwdevDma;
52
53/* Interrupts. IRQ_SETUP points the device's MSI/MSI-X at a kernel-allocated
54 * interrupt; every vector the device uses then arrives as the same interrupt,
55 * so the driver assigns MSI-X vector index 0 to its queues. IRQ_WAIT sleeps
56 * until an interrupt arrives or timeout_ms passes (a short timeout bounds any
57 * lost wakeup); its own return value is not reliable after a sleep, so read
58 * the result with IRQ_ACK, which returns and clears the pending count. */
59typedef struct { uint32_t spi; uint32_t reserved; } HwdevIrq;
60typedef struct { uint32_t timeout_ms; uint32_t reserved; } HwdevIrqWait;
61typedef struct { uint32_t pending; uint32_t reserved; uint64_t total; } HwdevIrqAck;
62
63#endif
uint8_t flags
Definition virtio.h:0
int int32_t
Definition acefiex.h:160
unsigned int uint32_t
Definition acefiex.h:163
COMPILER_DEPENDENT_UINT64 uint64_t
Definition acefiex.h:165
unsigned short int uint16_t
Definition acefiex.h:162
uint16_t vendor
Definition devhw.c:88
size_t size
Definition drm_bridge.h:1299
size_t size_t offset
Definition drm_bridge.h:1299
struct i915_user_extension base
Definition i915_drm.h:0
char phys[]
Definition hwdev.h:49
uint32_t bar
Definition hwdev.h:49
Definition hwdev.h:48
uint32_t offset
Definition hwdev.h:48
Definition hwdev.h:51
uint64_t length
Definition hwdev.h:51
Definition hwdev.h:61
uint32_t pending
Definition hwdev.h:61
Definition hwdev.h:60
uint32_t reserved
Definition hwdev.h:60
Definition hwdev.h:59
uint32_t reserved
Definition hwdev.h:59
Definition hwdev.h:50
uint32_t bar
Definition hwdev.h:50
Definition hwdev.h:47
uint16_t device
Definition hwdev.h:47