1 #ifndef _PALACIOS_HOST_DEV_USER_H_
2 #define _PALACIOS_HOST_DEV_USER_H_
5 * Palacios Host Device Interface + User-space interface
6 * (c) Peter Dinda, 2011
11 /* Connect using a V3_VM_HOST_DEV_CONNECT on the VM, which will return an fd */
12 /* to detemine whether a host request is available, poll the fd for read */
14 /* make a request for reading/writing guest or injecting irq */
15 /* the arguemnt is a pointer to a palacios_host_dev_user_op struct */
16 /* return is negative on error, positive to indicate bytes read/written or irq injected*/
17 #define V3_HOST_DEV_USER_REQUEST_PUSH_IOCTL (10244+2)
19 /* find out the size of the current host request, if one is pending */
20 /* you find out if one is pending by read poll/select on the fd */
21 /* the argument is a pointer to a uint64_t that will give the total size */
22 /* ioctl returns 1 if a request is ready, 0 if there is no request */
23 /* -EFAULT if there is a an error */
24 #define V3_HOST_DEV_HOST_REQUEST_SIZE_IOCTL (10244+3)
26 /* get the current host request, if one is available */
27 /* the argument is a pointer to a palacios_host_dev_host_request_response */
28 /* of the needed size */
29 /* ioctl returns 1 if a request is ready+copied, 0 if there is no request */
30 /* -EFAULT if there is a an error */
31 #define V3_HOST_DEV_HOST_REQUEST_PULL_IOCTL (10244+4)
33 /* write back the response to the previously pulled host request */
34 /* the argument is a pointer to a palacios_host_dev_host_request_response */
35 #define V3_HOST_DEV_USER_RESPONSE_PUSH_IOCTL (10244+5)
44 struct palacios_host_dev_user_op {
45 #define PALACIOS_HOST_DEV_USER_REQUEST_READ_GUEST 1
46 #define PALACIOS_HOST_DEV_USER_REQUEST_WRITE_GUEST 2
47 #define PALACIOS_HOST_DEV_USER_REQUEST_IRQ_RAISE_GUEST 3
48 #define PALACIOS_HOST_DEV_USER_REQUEST_IRQ_LOWER_GUEST 4
49 uint32_t type; // type of operation (from the #defs above)
50 void *gpa; // physical address in guest to read or write
51 void USER *data; // user address of data that will be read or written
52 uint64_t len; // number of bytes to move
54 uint8_t irq; // irq to inject
58 struct palacios_host_dev_host_request_response {
59 // data_len must remain the first field in this structure
60 uint64_t data_len; // size of the structure + occupied data
61 uint64_t len; // size of the structure in total
62 #define PALACIOS_HOST_DEV_HOST_REQUEST_READ_IO 1
63 #define PALACIOS_HOST_DEV_HOST_REQUEST_WRITE_IO 2
64 #define PALACIOS_HOST_DEV_HOST_REQUEST_READ_MEM 3
65 #define PALACIOS_HOST_DEV_HOST_REQUEST_WRITE_MEM 4
66 #define PALACIOS_HOST_DEV_HOST_REQUEST_READ_CONF 5
67 #define PALACIOS_HOST_DEV_HOST_REQUEST_WRITE_CONF 6
68 uint32_t type; // one of the types given above
69 uint16_t port; // port number, for IO
70 void *gpa; // physical address in the guest for memory ops
71 uint64_t conf_addr; // address in the configuration for configuration ops
73 uint64_t op_len; // response: bytes read/written to the device
74 // request: bytes to read/write
76 uint8_t data[0]; // data (if any)