Rusty Russell | d7e28ff | 2007-07-19 01:49:23 -0700 | [diff] [blame] | 1 | #ifndef _ASM_LGUEST_USER |
| 2 | #define _ASM_LGUEST_USER |
| 3 | /* Everything the "lguest" userspace program needs to know. */ |
Rusty Russell | b45d8cb | 2007-10-22 10:56:24 +1000 | [diff] [blame] | 4 | #include <linux/types.h> |
Rusty Russell | d7e28ff | 2007-07-19 01:49:23 -0700 | [diff] [blame] | 5 | /* They can register up to 32 arrays of lguest_dma. */ |
| 6 | #define LGUEST_MAX_DMA 32 |
| 7 | /* At most we can dma 16 lguest_dma in one op. */ |
| 8 | #define LGUEST_MAX_DMA_SECTIONS 16 |
| 9 | |
| 10 | /* How many devices? Assume each one wants up to two dma arrays per device. */ |
| 11 | #define LGUEST_MAX_DEVICES (LGUEST_MAX_DMA/2) |
| 12 | |
Rusty Russell | d7e28ff | 2007-07-19 01:49:23 -0700 | [diff] [blame] | 13 | /* Where the Host expects the Guest to SEND_DMA console output to. */ |
| 14 | #define LGUEST_CONSOLE_DMA_KEY 0 |
| 15 | |
Rusty Russell | e2c9784 | 2007-07-26 10:41:03 -0700 | [diff] [blame] | 16 | /*D:010 |
| 17 | * Drivers |
| 18 | * |
| 19 | * The Guest needs devices to do anything useful. Since we don't let it touch |
| 20 | * real devices (think of the damage it could do!) we provide virtual devices. |
| 21 | * We could emulate a PCI bus with various devices on it, but that is a fairly |
| 22 | * complex burden for the Host and suboptimal for the Guest, so we have our own |
| 23 | * "lguest" bus and simple drivers. |
| 24 | * |
| 25 | * Devices are described by an array of LGUEST_MAX_DEVICES of these structs, |
| 26 | * placed by the Launcher just above the top of physical memory: |
| 27 | */ |
Rusty Russell | d7e28ff | 2007-07-19 01:49:23 -0700 | [diff] [blame] | 28 | struct lguest_device_desc { |
Rusty Russell | e2c9784 | 2007-07-26 10:41:03 -0700 | [diff] [blame] | 29 | /* The device type: console, network, disk etc. */ |
Rusty Russell | b45d8cb | 2007-10-22 10:56:24 +1000 | [diff] [blame] | 30 | __u16 type; |
Rusty Russell | d7e28ff | 2007-07-19 01:49:23 -0700 | [diff] [blame] | 31 | #define LGUEST_DEVICE_T_CONSOLE 1 |
| 32 | #define LGUEST_DEVICE_T_NET 2 |
| 33 | #define LGUEST_DEVICE_T_BLOCK 3 |
| 34 | |
Rusty Russell | e2c9784 | 2007-07-26 10:41:03 -0700 | [diff] [blame] | 35 | /* The specific features of this device: these depends on device type |
| 36 | * except for LGUEST_DEVICE_F_RANDOMNESS. */ |
Rusty Russell | b45d8cb | 2007-10-22 10:56:24 +1000 | [diff] [blame] | 37 | __u16 features; |
Rusty Russell | d7e28ff | 2007-07-19 01:49:23 -0700 | [diff] [blame] | 38 | #define LGUEST_NET_F_NOCSUM 0x4000 /* Don't bother checksumming */ |
| 39 | #define LGUEST_DEVICE_F_RANDOMNESS 0x8000 /* IRQ is fairly random */ |
| 40 | |
Rusty Russell | e2c9784 | 2007-07-26 10:41:03 -0700 | [diff] [blame] | 41 | /* This is how the Guest reports status of the device: the Host can set |
| 42 | * LGUEST_DEVICE_S_REMOVED to indicate removal, but the rest are only |
| 43 | * ever manipulated by the Guest, and only ever set. */ |
Rusty Russell | b45d8cb | 2007-10-22 10:56:24 +1000 | [diff] [blame] | 44 | __u16 status; |
Rusty Russell | d7e28ff | 2007-07-19 01:49:23 -0700 | [diff] [blame] | 45 | /* 256 and above are device specific. */ |
| 46 | #define LGUEST_DEVICE_S_ACKNOWLEDGE 1 /* We have seen device. */ |
| 47 | #define LGUEST_DEVICE_S_DRIVER 2 /* We have found a driver */ |
| 48 | #define LGUEST_DEVICE_S_DRIVER_OK 4 /* Driver says OK! */ |
| 49 | #define LGUEST_DEVICE_S_REMOVED 8 /* Device has gone away. */ |
| 50 | #define LGUEST_DEVICE_S_REMOVED_ACK 16 /* Driver has been told. */ |
| 51 | #define LGUEST_DEVICE_S_FAILED 128 /* Something actually failed */ |
| 52 | |
Rusty Russell | e2c9784 | 2007-07-26 10:41:03 -0700 | [diff] [blame] | 53 | /* Each device exists somewhere in Guest physical memory, over some |
| 54 | * number of pages. */ |
Rusty Russell | b45d8cb | 2007-10-22 10:56:24 +1000 | [diff] [blame] | 55 | __u16 num_pages; |
| 56 | __u32 pfn; |
Rusty Russell | d7e28ff | 2007-07-19 01:49:23 -0700 | [diff] [blame] | 57 | }; |
Rusty Russell | e2c9784 | 2007-07-26 10:41:03 -0700 | [diff] [blame] | 58 | /*:*/ |
Rusty Russell | d7e28ff | 2007-07-19 01:49:23 -0700 | [diff] [blame] | 59 | |
| 60 | /* Write command first word is a request. */ |
| 61 | enum lguest_req |
| 62 | { |
| 63 | LHREQ_INITIALIZE, /* + pfnlimit, pgdir, start, pageoffset */ |
Rusty Russell | 1504527 | 2007-10-22 11:24:10 +1000 | [diff] [blame^] | 64 | LHREQ_GETDMA, /* No longer used */ |
Rusty Russell | d7e28ff | 2007-07-19 01:49:23 -0700 | [diff] [blame] | 65 | LHREQ_IRQ, /* + irq */ |
| 66 | LHREQ_BREAK, /* + on/off flag (on blocks until someone does off) */ |
| 67 | }; |
| 68 | #endif /* _ASM_LGUEST_USER */ |