blob: 697104da91f11e159851c0698ff45dd0a1f5b618 [file] [log] [blame]
Rusty Russell73344922007-10-25 14:12:20 +10001#ifndef _LINUX_LGUEST_LAUNCHER
2#define _LINUX_LGUEST_LAUNCHER
Rusty Russelld7e28ff2007-07-19 01:49:23 -07003/* 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
Rusty Russelle2c97842007-07-26 10:41:03 -07006/*D:010
7 * Drivers
8 *
9 * The Guest needs devices to do anything useful. Since we don't let it touch
10 * real devices (think of the damage it could do!) we provide virtual devices.
11 * We could emulate a PCI bus with various devices on it, but that is a fairly
12 * complex burden for the Host and suboptimal for the Guest, so we have our own
Rusty Russelle1e72962007-10-25 15:02:50 +100013 * simple lguest bus and we use "virtio" drivers. These drivers need a set of
14 * routines from us which will actually do the virtual I/O, but they handle all
15 * the net/block/console stuff themselves. This means that if we want to add
16 * a new device, we simply need to write a new virtio driver and create support
17 * for it in the Launcher: this code won't need to change.
Rusty Russelle2c97842007-07-26 10:41:03 -070018 *
Rusty Russell19f15372007-10-22 11:24:21 +100019 * Devices are described by a simplified ID, a status byte, and some "config"
20 * bytes which describe this device's configuration. This is placed by the
21 * Launcher just above the top of physical memory:
Rusty Russelle2c97842007-07-26 10:41:03 -070022 */
Rusty Russelld7e28ff2007-07-19 01:49:23 -070023struct lguest_device_desc {
Rusty Russell19f15372007-10-22 11:24:21 +100024 /* The device type: console, network, disk etc. Type 0 terminates. */
25 __u8 type;
26 /* The number of bytes of the config array. */
27 __u8 config_len;
28 /* A status byte, written by the Guest. */
29 __u8 status;
30 __u8 config[0];
31};
Rusty Russelld7e28ff2007-07-19 01:49:23 -070032
Rusty Russell19f15372007-10-22 11:24:21 +100033/*D:135 This is how we expect the device configuration field for a virtqueue
34 * (type VIRTIO_CONFIG_F_VIRTQUEUE) to be laid out: */
35struct lguest_vqconfig {
36 /* The number of entries in the virtio_ring */
37 __u16 num;
38 /* The interrupt we get when something happens. */
39 __u16 irq;
40 /* The page number of the virtio ring for this device. */
Rusty Russellb45d8cb2007-10-22 10:56:24 +100041 __u32 pfn;
Rusty Russelld7e28ff2007-07-19 01:49:23 -070042};
Rusty Russelle2c97842007-07-26 10:41:03 -070043/*:*/
Rusty Russelld7e28ff2007-07-19 01:49:23 -070044
45/* Write command first word is a request. */
46enum lguest_req
47{
Rusty Russell73344922007-10-25 14:12:20 +100048 LHREQ_INITIALIZE, /* + base, pfnlimit, pgdir, start */
Rusty Russell15045272007-10-22 11:24:10 +100049 LHREQ_GETDMA, /* No longer used */
Rusty Russelld7e28ff2007-07-19 01:49:23 -070050 LHREQ_IRQ, /* + irq */
51 LHREQ_BREAK, /* + on/off flag (on blocks until someone does off) */
52};
Rusty Russell73344922007-10-25 14:12:20 +100053#endif /* _LINUX_LGUEST_LAUNCHER */