mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 19:26:25 +00:00
lguest and virtio: cleanup struct definitions to Linux style.
I've been doing this for years, and akpm picked me up on it about 12 months ago. lguest partly serves as example code, so let's do it Right. Also, remove two unused fields in struct vblk_info in the example launcher. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Cc: Ingo Molnar <mingo@redhat.com>
This commit is contained in:
parent
a91d74a3c4
commit
1842f23c05
8 changed files with 19 additions and 44 deletions
|
@ -93,8 +93,7 @@ static int lguest_fd;
|
||||||
static unsigned int __thread cpu_id;
|
static unsigned int __thread cpu_id;
|
||||||
|
|
||||||
/* This is our list of devices. */
|
/* This is our list of devices. */
|
||||||
struct device_list
|
struct device_list {
|
||||||
{
|
|
||||||
/* Counter to assign interrupt numbers. */
|
/* Counter to assign interrupt numbers. */
|
||||||
unsigned int next_irq;
|
unsigned int next_irq;
|
||||||
|
|
||||||
|
@ -114,8 +113,7 @@ struct device_list
|
||||||
static struct device_list devices;
|
static struct device_list devices;
|
||||||
|
|
||||||
/* The device structure describes a single device. */
|
/* The device structure describes a single device. */
|
||||||
struct device
|
struct device {
|
||||||
{
|
|
||||||
/* The linked-list pointer. */
|
/* The linked-list pointer. */
|
||||||
struct device *next;
|
struct device *next;
|
||||||
|
|
||||||
|
@ -140,8 +138,7 @@ struct device
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The virtqueue structure describes a queue attached to a device. */
|
/* The virtqueue structure describes a queue attached to a device. */
|
||||||
struct virtqueue
|
struct virtqueue {
|
||||||
{
|
|
||||||
struct virtqueue *next;
|
struct virtqueue *next;
|
||||||
|
|
||||||
/* Which device owns me. */
|
/* Which device owns me. */
|
||||||
|
@ -779,8 +776,7 @@ static void add_used_and_trigger(struct virtqueue *vq, unsigned head, int len)
|
||||||
*
|
*
|
||||||
* We associate some data with the console for our exit hack.
|
* We associate some data with the console for our exit hack.
|
||||||
*/
|
*/
|
||||||
struct console_abort
|
struct console_abort {
|
||||||
{
|
|
||||||
/* How many times have they hit ^C? */
|
/* How many times have they hit ^C? */
|
||||||
int count;
|
int count;
|
||||||
/* When did they start? */
|
/* When did they start? */
|
||||||
|
@ -1570,20 +1566,13 @@ static void setup_tun_net(char *arg)
|
||||||
/*:*/
|
/*:*/
|
||||||
|
|
||||||
/* This hangs off device->priv. */
|
/* This hangs off device->priv. */
|
||||||
struct vblk_info
|
struct vblk_info {
|
||||||
{
|
|
||||||
/* The size of the file. */
|
/* The size of the file. */
|
||||||
off64_t len;
|
off64_t len;
|
||||||
|
|
||||||
/* The file descriptor for the file. */
|
/* The file descriptor for the file. */
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
/* IO thread listens on this file descriptor [0]. */
|
|
||||||
int workpipe[2];
|
|
||||||
|
|
||||||
/* IO thread writes to this file descriptor to mark it done, then
|
|
||||||
* Launcher triggers interrupt to Guest. */
|
|
||||||
int done_fd;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*L:210
|
/*L:210
|
||||||
|
|
|
@ -16,15 +16,13 @@
|
||||||
void free_pagetables(void);
|
void free_pagetables(void);
|
||||||
int init_pagetables(struct page **switcher_page, unsigned int pages);
|
int init_pagetables(struct page **switcher_page, unsigned int pages);
|
||||||
|
|
||||||
struct pgdir
|
struct pgdir {
|
||||||
{
|
|
||||||
unsigned long gpgdir;
|
unsigned long gpgdir;
|
||||||
pgd_t *pgdir;
|
pgd_t *pgdir;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* We have two pages shared with guests, per cpu. */
|
/* We have two pages shared with guests, per cpu. */
|
||||||
struct lguest_pages
|
struct lguest_pages {
|
||||||
{
|
|
||||||
/* This is the stack page mapped rw in guest */
|
/* This is the stack page mapped rw in guest */
|
||||||
char spare[PAGE_SIZE - sizeof(struct lguest_regs)];
|
char spare[PAGE_SIZE - sizeof(struct lguest_regs)];
|
||||||
struct lguest_regs regs;
|
struct lguest_regs regs;
|
||||||
|
@ -89,8 +87,7 @@ struct lg_eventfd_map {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The private info the thread maintains about the guest. */
|
/* The private info the thread maintains about the guest. */
|
||||||
struct lguest
|
struct lguest {
|
||||||
{
|
|
||||||
struct lguest_data __user *lguest_data;
|
struct lguest_data __user *lguest_data;
|
||||||
struct lg_cpu cpus[NR_CPUS];
|
struct lg_cpu cpus[NR_CPUS];
|
||||||
unsigned int nr_cpus;
|
unsigned int nr_cpus;
|
||||||
|
|
|
@ -207,8 +207,7 @@ static void lg_reset(struct virtio_device *vdev)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*D:140 This is the information we remember about each virtqueue. */
|
/*D:140 This is the information we remember about each virtqueue. */
|
||||||
struct lguest_vq_info
|
struct lguest_vq_info {
|
||||||
{
|
|
||||||
/* A copy of the information contained in the device config. */
|
/* A copy of the information contained in the device config. */
|
||||||
struct lguest_vqconfig config;
|
struct lguest_vqconfig config;
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
* lguest_data". Once the Guest's initialization hypercall tells the Host where
|
* lguest_data". Once the Guest's initialization hypercall tells the Host where
|
||||||
* this is, the Guest and Host both publish information in it.
|
* this is, the Guest and Host both publish information in it.
|
||||||
:*/
|
:*/
|
||||||
struct lguest_data
|
struct lguest_data {
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* 512 == enabled (same as eflags in normal hardware). The Guest
|
* 512 == enabled (same as eflags in normal hardware). The Guest
|
||||||
* changes interrupts so often that a hypercall is too slow.
|
* changes interrupts so often that a hypercall is too slow.
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
|
|
||||||
#define VIRTIO_BLK_ID_BYTES (sizeof(__u16[256])) /* IDENTIFY DATA */
|
#define VIRTIO_BLK_ID_BYTES (sizeof(__u16[256])) /* IDENTIFY DATA */
|
||||||
|
|
||||||
struct virtio_blk_config
|
struct virtio_blk_config {
|
||||||
{
|
|
||||||
/* The capacity (in 512-byte sectors). */
|
/* The capacity (in 512-byte sectors). */
|
||||||
__u64 capacity;
|
__u64 capacity;
|
||||||
/* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
|
/* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
|
||||||
|
@ -50,8 +49,7 @@ struct virtio_blk_config
|
||||||
#define VIRTIO_BLK_T_BARRIER 0x80000000
|
#define VIRTIO_BLK_T_BARRIER 0x80000000
|
||||||
|
|
||||||
/* This is the first element of the read scatter-gather list. */
|
/* This is the first element of the read scatter-gather list. */
|
||||||
struct virtio_blk_outhdr
|
struct virtio_blk_outhdr {
|
||||||
{
|
|
||||||
/* VIRTIO_BLK_T* */
|
/* VIRTIO_BLK_T* */
|
||||||
__u32 type;
|
__u32 type;
|
||||||
/* io priority. */
|
/* io priority. */
|
||||||
|
|
|
@ -79,8 +79,7 @@
|
||||||
* the dev->feature bits if it wants.
|
* the dev->feature bits if it wants.
|
||||||
*/
|
*/
|
||||||
typedef void vq_callback_t(struct virtqueue *);
|
typedef void vq_callback_t(struct virtqueue *);
|
||||||
struct virtio_config_ops
|
struct virtio_config_ops {
|
||||||
{
|
|
||||||
void (*get)(struct virtio_device *vdev, unsigned offset,
|
void (*get)(struct virtio_device *vdev, unsigned offset,
|
||||||
void *buf, unsigned len);
|
void *buf, unsigned len);
|
||||||
void (*set)(struct virtio_device *vdev, unsigned offset,
|
void (*set)(struct virtio_device *vdev, unsigned offset,
|
||||||
|
|
|
@ -31,8 +31,7 @@
|
||||||
|
|
||||||
#define VIRTIO_NET_S_LINK_UP 1 /* Link is up */
|
#define VIRTIO_NET_S_LINK_UP 1 /* Link is up */
|
||||||
|
|
||||||
struct virtio_net_config
|
struct virtio_net_config {
|
||||||
{
|
|
||||||
/* The config defining mac address (if VIRTIO_NET_F_MAC) */
|
/* The config defining mac address (if VIRTIO_NET_F_MAC) */
|
||||||
__u8 mac[6];
|
__u8 mac[6];
|
||||||
/* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */
|
/* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */
|
||||||
|
@ -41,8 +40,7 @@ struct virtio_net_config
|
||||||
|
|
||||||
/* This is the first element of the scatter-gather list. If you don't
|
/* This is the first element of the scatter-gather list. If you don't
|
||||||
* specify GSO or CSUM features, you can simply ignore the header. */
|
* specify GSO or CSUM features, you can simply ignore the header. */
|
||||||
struct virtio_net_hdr
|
struct virtio_net_hdr {
|
||||||
{
|
|
||||||
#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 // Use csum_start, csum_offset
|
#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 // Use csum_start, csum_offset
|
||||||
__u8 flags;
|
__u8 flags;
|
||||||
#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame
|
#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
#define VIRTIO_RING_F_INDIRECT_DESC 28
|
#define VIRTIO_RING_F_INDIRECT_DESC 28
|
||||||
|
|
||||||
/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */
|
/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */
|
||||||
struct vring_desc
|
struct vring_desc {
|
||||||
{
|
|
||||||
/* Address (guest-physical). */
|
/* Address (guest-physical). */
|
||||||
__u64 addr;
|
__u64 addr;
|
||||||
/* Length. */
|
/* Length. */
|
||||||
|
@ -42,24 +41,21 @@ struct vring_desc
|
||||||
__u16 next;
|
__u16 next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vring_avail
|
struct vring_avail {
|
||||||
{
|
|
||||||
__u16 flags;
|
__u16 flags;
|
||||||
__u16 idx;
|
__u16 idx;
|
||||||
__u16 ring[];
|
__u16 ring[];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* u32 is used here for ids for padding reasons. */
|
/* u32 is used here for ids for padding reasons. */
|
||||||
struct vring_used_elem
|
struct vring_used_elem {
|
||||||
{
|
|
||||||
/* Index of start of used descriptor chain. */
|
/* Index of start of used descriptor chain. */
|
||||||
__u32 id;
|
__u32 id;
|
||||||
/* Total length of the descriptor chain which was used (written to) */
|
/* Total length of the descriptor chain which was used (written to) */
|
||||||
__u32 len;
|
__u32 len;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vring_used
|
struct vring_used {
|
||||||
{
|
|
||||||
__u16 flags;
|
__u16 flags;
|
||||||
__u16 idx;
|
__u16 idx;
|
||||||
struct vring_used_elem ring[];
|
struct vring_used_elem ring[];
|
||||||
|
|
Loading…
Reference in a new issue