blob: 5ec04a225e4fb8880d4726c3bc2c14337f27c884 [file] [log] [blame]
Rusty Russelld7e28ff2007-07-19 01:49:23 -07001#ifndef _ASM_LGUEST_USER
2#define _ASM_LGUEST_USER
3/* Everything the "lguest" userspace program needs to know. */
Rusty Russellb45d8cb2007-10-22 10:56:24 +10004#include <linux/types.h>
Rusty Russelld7e28ff2007-07-19 01:49:23 -07005/* 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 Russelld7e28ff2007-07-19 01:49:23 -070013/* Where the Host expects the Guest to SEND_DMA console output to. */
14#define LGUEST_CONSOLE_DMA_KEY 0
15
Rusty Russelle2c97842007-07-26 10:41:03 -070016/*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 Russelld7e28ff2007-07-19 01:49:23 -070028struct lguest_device_desc {
Rusty Russelle2c97842007-07-26 10:41:03 -070029 /* The device type: console, network, disk etc. */
Rusty Russellb45d8cb2007-10-22 10:56:24 +100030 __u16 type;
Rusty Russelld7e28ff2007-07-19 01:49:23 -070031#define LGUEST_DEVICE_T_CONSOLE 1
32#define LGUEST_DEVICE_T_NET 2
33#define LGUEST_DEVICE_T_BLOCK 3
34
Rusty Russelle2c97842007-07-26 10:41:03 -070035 /* The specific features of this device: these depends on device type
36 * except for LGUEST_DEVICE_F_RANDOMNESS. */
Rusty Russellb45d8cb2007-10-22 10:56:24 +100037 __u16 features;
Rusty Russelld7e28ff2007-07-19 01:49:23 -070038#define LGUEST_NET_F_NOCSUM 0x4000 /* Don't bother checksumming */
39#define LGUEST_DEVICE_F_RANDOMNESS 0x8000 /* IRQ is fairly random */
40
Rusty Russelle2c97842007-07-26 10:41:03 -070041 /* 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 Russellb45d8cb2007-10-22 10:56:24 +100044 __u16 status;
Rusty Russelld7e28ff2007-07-19 01:49:23 -070045/* 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 Russelle2c97842007-07-26 10:41:03 -070053 /* Each device exists somewhere in Guest physical memory, over some
54 * number of pages. */
Rusty Russellb45d8cb2007-10-22 10:56:24 +100055 __u16 num_pages;
56 __u32 pfn;
Rusty Russelld7e28ff2007-07-19 01:49:23 -070057};
Rusty Russelle2c97842007-07-26 10:41:03 -070058/*:*/
Rusty Russelld7e28ff2007-07-19 01:49:23 -070059
60/* Write command first word is a request. */
61enum lguest_req
62{
63 LHREQ_INITIALIZE, /* + pfnlimit, pgdir, start, pageoffset */
Rusty Russell15045272007-10-22 11:24:10 +100064 LHREQ_GETDMA, /* No longer used */
Rusty Russelld7e28ff2007-07-19 01:49:23 -070065 LHREQ_IRQ, /* + irq */
66 LHREQ_BREAK, /* + on/off flag (on blocks until someone does off) */
67};
68#endif /* _ASM_LGUEST_USER */