aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-23 12:03:07 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-23 12:03:07 -0400
commit0d6810091cdbd05efeb31654c6a41a6cbdfdd2c8 (patch)
tree44d79f8133ea6acd791fe4f32188789c2c65da93 /include
parenta98ce5c6feead6bfedefabd46cb3d7f5be148d9a (diff)
parent43d33b21a03d3abcc8cbdeb4d52bc4568f822c5e (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-lguest
* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-lguest: (45 commits) Use "struct boot_params" in example launcher Loading bzImage directly. Revert lguest magic and use hook in head.S Update lguest documentation to reflect the new virtual block device name. generalize lgread_u32/lgwrite_u32. Example launcher handle guests not being ready for input Update example launcher for virtio Lguest support for Virtio Remove old lguest I/O infrrasructure. Remove old lguest bus and drivers. Virtio helper routines for a descriptor ringbuffer implementation Module autoprobing support for virtio drivers. Virtio console driver Block driver using virtio. Net driver using virtio Virtio interface Boot with virtual == physical to get closer to native Linux. Allow guest to specify syscall vector to use. Rename "cr3" to "gpgdir" to avoid x86-specific naming. Pagetables to use normal kernel types ...
Diffstat (limited to 'include')
-rw-r--r--include/asm-x86/Kbuild3
-rw-r--r--include/asm-x86/bootparam.h108
-rw-r--r--include/asm-x86/e820.h28
-rw-r--r--include/asm-x86/e820_32.h21
-rw-r--r--include/asm-x86/e820_64.h20
-rw-r--r--include/asm-x86/ist.h12
-rw-r--r--include/asm-x86/lguest.h86
-rw-r--r--include/asm-x86/lguest_hcall.h71
-rw-r--r--include/linux/Kbuild5
-rw-r--r--include/linux/apm_bios.h30
-rw-r--r--include/linux/edd.h137
-rw-r--r--include/linux/lguest.h80
-rw-r--r--include/linux/lguest_bus.h51
-rw-r--r--include/linux/lguest_launcher.h112
-rw-r--r--include/linux/mod_devicetable.h6
-rw-r--r--include/linux/screen_info.h81
-rw-r--r--include/linux/virtio.h110
-rw-r--r--include/linux/virtio_blk.h51
-rw-r--r--include/linux/virtio_config.h111
-rw-r--r--include/linux/virtio_console.h12
-rw-r--r--include/linux/virtio_net.h36
-rw-r--r--include/linux/virtio_ring.h119
-rw-r--r--include/video/Kbuild1
-rw-r--r--include/video/edid.h9
24 files changed, 867 insertions, 433 deletions
diff --git a/include/asm-x86/Kbuild b/include/asm-x86/Kbuild
index 559830ece755..5e3539c129b9 100644
--- a/include/asm-x86/Kbuild
+++ b/include/asm-x86/Kbuild
@@ -1,6 +1,7 @@
1include include/asm-generic/Kbuild.asm 1include include/asm-generic/Kbuild.asm
2 2
3header-y += boot.h 3header-y += boot.h
4header-y += bootparam.h
4header-y += debugreg.h 5header-y += debugreg.h
5header-y += ldt.h 6header-y += ldt.h
6header-y += msr-index.h 7header-y += msr-index.h
@@ -14,8 +15,10 @@ unifdef-y += a.out_32.h
14unifdef-y += a.out_64.h 15unifdef-y += a.out_64.h
15unifdef-y += byteorder_32.h 16unifdef-y += byteorder_32.h
16unifdef-y += byteorder_64.h 17unifdef-y += byteorder_64.h
18unifdef-y += e820.h
17unifdef-y += elf_32.h 19unifdef-y += elf_32.h
18unifdef-y += elf_64.h 20unifdef-y += elf_64.h
21unifdef-y += ist.h
19unifdef-y += mce.h 22unifdef-y += mce.h
20unifdef-y += msgbuf_32.h 23unifdef-y += msgbuf_32.h
21unifdef-y += msgbuf_64.h 24unifdef-y += msgbuf_64.h
diff --git a/include/asm-x86/bootparam.h b/include/asm-x86/bootparam.h
index dc031cf44633..19f3ddf2df4b 100644
--- a/include/asm-x86/bootparam.h
+++ b/include/asm-x86/bootparam.h
@@ -10,85 +10,85 @@
10#include <video/edid.h> 10#include <video/edid.h>
11 11
12struct setup_header { 12struct setup_header {
13 u8 setup_sects; 13 __u8 setup_sects;
14 u16 root_flags; 14 __u16 root_flags;
15 u32 syssize; 15 __u32 syssize;
16 u16 ram_size; 16 __u16 ram_size;
17#define RAMDISK_IMAGE_START_MASK 0x07FF 17#define RAMDISK_IMAGE_START_MASK 0x07FF
18#define RAMDISK_PROMPT_FLAG 0x8000 18#define RAMDISK_PROMPT_FLAG 0x8000
19#define RAMDISK_LOAD_FLAG 0x4000 19#define RAMDISK_LOAD_FLAG 0x4000
20 u16 vid_mode; 20 __u16 vid_mode;
21 u16 root_dev; 21 __u16 root_dev;
22 u16 boot_flag; 22 __u16 boot_flag;
23 u16 jump; 23 __u16 jump;
24 u32 header; 24 __u32 header;
25 u16 version; 25 __u16 version;
26 u32 realmode_swtch; 26 __u32 realmode_swtch;
27 u16 start_sys; 27 __u16 start_sys;
28 u16 kernel_version; 28 __u16 kernel_version;
29 u8 type_of_loader; 29 __u8 type_of_loader;
30 u8 loadflags; 30 __u8 loadflags;
31#define LOADED_HIGH (1<<0) 31#define LOADED_HIGH (1<<0)
32#define KEEP_SEGMENTS (1<<6) 32#define KEEP_SEGMENTS (1<<6)
33#define CAN_USE_HEAP (1<<7) 33#define CAN_USE_HEAP (1<<7)
34 u16 setup_move_size; 34 __u16 setup_move_size;
35 u32 code32_start; 35 __u32 code32_start;
36 u32 ramdisk_image; 36 __u32 ramdisk_image;
37 u32 ramdisk_size; 37 __u32 ramdisk_size;
38 u32 bootsect_kludge; 38 __u32 bootsect_kludge;
39 u16 heap_end_ptr; 39 __u16 heap_end_ptr;
40 u16 _pad1; 40 __u16 _pad1;
41 u32 cmd_line_ptr; 41 __u32 cmd_line_ptr;
42 u32 initrd_addr_max; 42 __u32 initrd_addr_max;
43 u32 kernel_alignment; 43 __u32 kernel_alignment;
44 u8 relocatable_kernel; 44 __u8 relocatable_kernel;
45 u8 _pad2[3]; 45 __u8 _pad2[3];
46 u32 cmdline_size; 46 __u32 cmdline_size;
47 u32 hardware_subarch; 47 __u32 hardware_subarch;
48 u64 hardware_subarch_data; 48 __u64 hardware_subarch_data;
49} __attribute__((packed)); 49} __attribute__((packed));
50 50
51struct sys_desc_table { 51struct sys_desc_table {
52 u16 length; 52 __u16 length;
53 u8 table[14]; 53 __u8 table[14];
54}; 54};
55 55
56struct efi_info { 56struct efi_info {
57 u32 _pad1; 57 __u32 _pad1;
58 u32 efi_systab; 58 __u32 efi_systab;
59 u32 efi_memdesc_size; 59 __u32 efi_memdesc_size;
60 u32 efi_memdesc_version; 60 __u32 efi_memdesc_version;
61 u32 efi_memmap; 61 __u32 efi_memmap;
62 u32 efi_memmap_size; 62 __u32 efi_memmap_size;
63 u32 _pad2[2]; 63 __u32 _pad2[2];
64}; 64};
65 65
66/* The so-called "zeropage" */ 66/* The so-called "zeropage" */
67struct boot_params { 67struct boot_params {
68 struct screen_info screen_info; /* 0x000 */ 68 struct screen_info screen_info; /* 0x000 */
69 struct apm_bios_info apm_bios_info; /* 0x040 */ 69 struct apm_bios_info apm_bios_info; /* 0x040 */
70 u8 _pad2[12]; /* 0x054 */ 70 __u8 _pad2[12]; /* 0x054 */
71 struct ist_info ist_info; /* 0x060 */ 71 struct ist_info ist_info; /* 0x060 */
72 u8 _pad3[16]; /* 0x070 */ 72 __u8 _pad3[16]; /* 0x070 */
73 u8 hd0_info[16]; /* obsolete! */ /* 0x080 */ 73 __u8 hd0_info[16]; /* obsolete! */ /* 0x080 */
74 u8 hd1_info[16]; /* obsolete! */ /* 0x090 */ 74 __u8 hd1_info[16]; /* obsolete! */ /* 0x090 */
75 struct sys_desc_table sys_desc_table; /* 0x0a0 */ 75 struct sys_desc_table sys_desc_table; /* 0x0a0 */
76 u8 _pad4[144]; /* 0x0b0 */ 76 __u8 _pad4[144]; /* 0x0b0 */
77 struct edid_info edid_info; /* 0x140 */ 77 struct edid_info edid_info; /* 0x140 */
78 struct efi_info efi_info; /* 0x1c0 */ 78 struct efi_info efi_info; /* 0x1c0 */
79 u32 alt_mem_k; /* 0x1e0 */ 79 __u32 alt_mem_k; /* 0x1e0 */
80 u32 scratch; /* Scratch field! */ /* 0x1e4 */ 80 __u32 scratch; /* Scratch field! */ /* 0x1e4 */
81 u8 e820_entries; /* 0x1e8 */ 81 __u8 e820_entries; /* 0x1e8 */
82 u8 eddbuf_entries; /* 0x1e9 */ 82 __u8 eddbuf_entries; /* 0x1e9 */
83 u8 edd_mbr_sig_buf_entries; /* 0x1ea */ 83 __u8 edd_mbr_sig_buf_entries; /* 0x1ea */
84 u8 _pad6[6]; /* 0x1eb */ 84 __u8 _pad6[6]; /* 0x1eb */
85 struct setup_header hdr; /* setup header */ /* 0x1f1 */ 85 struct setup_header hdr; /* setup header */ /* 0x1f1 */
86 u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)]; 86 __u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)];
87 u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */ 87 __u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */
88 struct e820entry e820_map[E820MAX]; /* 0x2d0 */ 88 struct e820entry e820_map[E820MAX]; /* 0x2d0 */
89 u8 _pad8[48]; /* 0xcd0 */ 89 __u8 _pad8[48]; /* 0xcd0 */
90 struct edd_info eddbuf[EDDMAXNR]; /* 0xd00 */ 90 struct edd_info eddbuf[EDDMAXNR]; /* 0xd00 */
91 u8 _pad9[276]; /* 0xeec */ 91 __u8 _pad9[276]; /* 0xeec */
92} __attribute__((packed)); 92} __attribute__((packed));
93 93
94#endif /* _ASM_BOOTPARAM_H */ 94#endif /* _ASM_BOOTPARAM_H */
diff --git a/include/asm-x86/e820.h b/include/asm-x86/e820.h
index 5d4d2183e5db..3e214f39fad3 100644
--- a/include/asm-x86/e820.h
+++ b/include/asm-x86/e820.h
@@ -1,5 +1,33 @@
1#ifndef __ASM_E820_H
2#define __ASM_E820_H
3#define E820MAP 0x2d0 /* our map */
4#define E820MAX 128 /* number of entries in E820MAP */
5#define E820NR 0x1e8 /* # entries in E820MAP */
6
7#define E820_RAM 1
8#define E820_RESERVED 2
9#define E820_ACPI 3
10#define E820_NVS 4
11
12#ifndef __ASSEMBLY__
13struct e820entry {
14 __u64 addr; /* start of memory segment */
15 __u64 size; /* size of memory segment */
16 __u32 type; /* type of memory segment */
17} __attribute__((packed));
18
19struct e820map {
20 __u32 nr_map;
21 struct e820entry map[E820MAX];
22};
23#endif /* __ASSEMBLY__ */
24
25#ifdef __KERNEL__
1#ifdef CONFIG_X86_32 26#ifdef CONFIG_X86_32
2# include "e820_32.h" 27# include "e820_32.h"
3#else 28#else
4# include "e820_64.h" 29# include "e820_64.h"
5#endif 30#endif
31#endif /* __KERNEL__ */
32
33#endif /* __ASM_E820_H */
diff --git a/include/asm-x86/e820_32.h b/include/asm-x86/e820_32.h
index cf67dbb1db79..03f60c690c8a 100644
--- a/include/asm-x86/e820_32.h
+++ b/include/asm-x86/e820_32.h
@@ -12,30 +12,10 @@
12#ifndef __E820_HEADER 12#ifndef __E820_HEADER
13#define __E820_HEADER 13#define __E820_HEADER
14 14
15#define E820MAP 0x2d0 /* our map */
16#define E820MAX 128 /* number of entries in E820MAP */
17#define E820NR 0x1e8 /* # entries in E820MAP */
18
19#define E820_RAM 1
20#define E820_RESERVED 2
21#define E820_ACPI 3
22#define E820_NVS 4
23
24#define HIGH_MEMORY (1024*1024) 15#define HIGH_MEMORY (1024*1024)
25 16
26#ifndef __ASSEMBLY__ 17#ifndef __ASSEMBLY__
27 18
28struct e820entry {
29 u64 addr; /* start of memory segment */
30 u64 size; /* size of memory segment */
31 u32 type; /* type of memory segment */
32} __attribute__((packed));
33
34struct e820map {
35 u32 nr_map;
36 struct e820entry map[E820MAX];
37};
38
39extern struct e820map e820; 19extern struct e820map e820;
40 20
41extern int e820_all_mapped(unsigned long start, unsigned long end, 21extern int e820_all_mapped(unsigned long start, unsigned long end,
@@ -56,5 +36,4 @@ static inline void e820_mark_nosave_regions(void)
56#endif 36#endif
57 37
58#endif/*!__ASSEMBLY__*/ 38#endif/*!__ASSEMBLY__*/
59
60#endif/*__E820_HEADER*/ 39#endif/*__E820_HEADER*/
diff --git a/include/asm-x86/e820_64.h b/include/asm-x86/e820_64.h
index 3486e701bd86..0bd4787a5d57 100644
--- a/include/asm-x86/e820_64.h
+++ b/include/asm-x86/e820_64.h
@@ -11,27 +11,7 @@
11#ifndef __E820_HEADER 11#ifndef __E820_HEADER
12#define __E820_HEADER 12#define __E820_HEADER
13 13
14#define E820MAP 0x2d0 /* our map */
15#define E820MAX 128 /* number of entries in E820MAP */
16#define E820NR 0x1e8 /* # entries in E820MAP */
17
18#define E820_RAM 1
19#define E820_RESERVED 2
20#define E820_ACPI 3
21#define E820_NVS 4
22
23#ifndef __ASSEMBLY__ 14#ifndef __ASSEMBLY__
24struct e820entry {
25 u64 addr; /* start of memory segment */
26 u64 size; /* size of memory segment */
27 u32 type; /* type of memory segment */
28} __attribute__((packed));
29
30struct e820map {
31 u32 nr_map;
32 struct e820entry map[E820MAX];
33};
34
35extern unsigned long find_e820_area(unsigned long start, unsigned long end, 15extern unsigned long find_e820_area(unsigned long start, unsigned long end,
36 unsigned size); 16 unsigned size);
37extern void add_memory_region(unsigned long start, unsigned long size, 17extern void add_memory_region(unsigned long start, unsigned long size,
diff --git a/include/asm-x86/ist.h b/include/asm-x86/ist.h
index ef2003ebc6f9..6ec6ceed95a7 100644
--- a/include/asm-x86/ist.h
+++ b/include/asm-x86/ist.h
@@ -17,17 +17,17 @@
17 */ 17 */
18 18
19 19
20#ifdef __KERNEL__
21
22#include <linux/types.h> 20#include <linux/types.h>
23 21
24struct ist_info { 22struct ist_info {
25 u32 signature; 23 __u32 signature;
26 u32 command; 24 __u32 command;
27 u32 event; 25 __u32 event;
28 u32 perf_level; 26 __u32 perf_level;
29}; 27};
30 28
29#ifdef __KERNEL__
30
31extern struct ist_info ist_info; 31extern struct ist_info ist_info;
32 32
33#endif /* __KERNEL__ */ 33#endif /* __KERNEL__ */
diff --git a/include/asm-x86/lguest.h b/include/asm-x86/lguest.h
new file mode 100644
index 000000000000..ccd338460811
--- /dev/null
+++ b/include/asm-x86/lguest.h
@@ -0,0 +1,86 @@
1#ifndef _X86_LGUEST_H
2#define _X86_LGUEST_H
3
4#define GDT_ENTRY_LGUEST_CS 10
5#define GDT_ENTRY_LGUEST_DS 11
6#define LGUEST_CS (GDT_ENTRY_LGUEST_CS * 8)
7#define LGUEST_DS (GDT_ENTRY_LGUEST_DS * 8)
8
9#ifndef __ASSEMBLY__
10#include <asm/desc.h>
11
12#define GUEST_PL 1
13
14/* Every guest maps the core switcher code. */
15#define SHARED_SWITCHER_PAGES \
16 DIV_ROUND_UP(end_switcher_text - start_switcher_text, PAGE_SIZE)
17/* Pages for switcher itself, then two pages per cpu */
18#define TOTAL_SWITCHER_PAGES (SHARED_SWITCHER_PAGES + 2 * NR_CPUS)
19
20/* We map at -4M for ease of mapping into the guest (one PTE page). */
21#define SWITCHER_ADDR 0xFFC00000
22
23/* Found in switcher.S */
24extern unsigned long default_idt_entries[];
25
26struct lguest_regs
27{
28 /* Manually saved part. */
29 unsigned long eax, ebx, ecx, edx;
30 unsigned long esi, edi, ebp;
31 unsigned long gs;
32 unsigned long fs, ds, es;
33 unsigned long trapnum, errcode;
34 /* Trap pushed part */
35 unsigned long eip;
36 unsigned long cs;
37 unsigned long eflags;
38 unsigned long esp;
39 unsigned long ss;
40};
41
42/* This is a guest-specific page (mapped ro) into the guest. */
43struct lguest_ro_state
44{
45 /* Host information we need to restore when we switch back. */
46 u32 host_cr3;
47 struct Xgt_desc_struct host_idt_desc;
48 struct Xgt_desc_struct host_gdt_desc;
49 u32 host_sp;
50
51 /* Fields which are used when guest is running. */
52 struct Xgt_desc_struct guest_idt_desc;
53 struct Xgt_desc_struct guest_gdt_desc;
54 struct i386_hw_tss guest_tss;
55 struct desc_struct guest_idt[IDT_ENTRIES];
56 struct desc_struct guest_gdt[GDT_ENTRIES];
57};
58
59struct lguest_arch
60{
61 /* The GDT entries copied into lguest_ro_state when running. */
62 struct desc_struct gdt[GDT_ENTRIES];
63
64 /* The IDT entries: some copied into lguest_ro_state when running. */
65 struct desc_struct idt[IDT_ENTRIES];
66
67 /* The address of the last guest-visible pagefault (ie. cr2). */
68 unsigned long last_pagefault;
69};
70
71static inline void lguest_set_ts(void)
72{
73 u32 cr0;
74
75 cr0 = read_cr0();
76 if (!(cr0 & 8))
77 write_cr0(cr0|8);
78}
79
80/* Full 4G segment descriptors, suitable for CS and DS. */
81#define FULL_EXEC_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9b00})
82#define FULL_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9300})
83
84#endif /* __ASSEMBLY__ */
85
86#endif
diff --git a/include/asm-x86/lguest_hcall.h b/include/asm-x86/lguest_hcall.h
new file mode 100644
index 000000000000..f948491eb56a
--- /dev/null
+++ b/include/asm-x86/lguest_hcall.h
@@ -0,0 +1,71 @@
1/* Architecture specific portion of the lguest hypercalls */
2#ifndef _X86_LGUEST_HCALL_H
3#define _X86_LGUEST_HCALL_H
4
5#define LHCALL_FLUSH_ASYNC 0
6#define LHCALL_LGUEST_INIT 1
7#define LHCALL_CRASH 2
8#define LHCALL_LOAD_GDT 3
9#define LHCALL_NEW_PGTABLE 4
10#define LHCALL_FLUSH_TLB 5
11#define LHCALL_LOAD_IDT_ENTRY 6
12#define LHCALL_SET_STACK 7
13#define LHCALL_TS 8
14#define LHCALL_SET_CLOCKEVENT 9
15#define LHCALL_HALT 10
16#define LHCALL_SET_PTE 14
17#define LHCALL_SET_PMD 15
18#define LHCALL_LOAD_TLS 16
19#define LHCALL_NOTIFY 17
20
21/*G:031 First, how does our Guest contact the Host to ask for privileged
22 * operations? There are two ways: the direct way is to make a "hypercall",
23 * to make requests of the Host Itself.
24 *
25 * Our hypercall mechanism uses the highest unused trap code (traps 32 and
26 * above are used by real hardware interrupts). Seventeen hypercalls are
27 * available: the hypercall number is put in the %eax register, and the
28 * arguments (when required) are placed in %edx, %ebx and %ecx. If a return
29 * value makes sense, it's returned in %eax.
30 *
31 * Grossly invalid calls result in Sudden Death at the hands of the vengeful
32 * Host, rather than returning failure. This reflects Winston Churchill's
33 * definition of a gentleman: "someone who is only rude intentionally". */
34#define LGUEST_TRAP_ENTRY 0x1F
35
36#ifndef __ASSEMBLY__
37#include <asm/hw_irq.h>
38
39static inline unsigned long
40hcall(unsigned long call,
41 unsigned long arg1, unsigned long arg2, unsigned long arg3)
42{
43 /* "int" is the Intel instruction to trigger a trap. */
44 asm volatile("int $" __stringify(LGUEST_TRAP_ENTRY)
45 /* The call is in %eax (aka "a"), and can be replaced */
46 : "=a"(call)
47 /* The other arguments are in %eax, %edx, %ebx & %ecx */
48 : "a"(call), "d"(arg1), "b"(arg2), "c"(arg3)
49 /* "memory" means this might write somewhere in memory.
50 * This isn't true for all calls, but it's safe to tell
51 * gcc that it might happen so it doesn't get clever. */
52 : "memory");
53 return call;
54}
55/*:*/
56
57void async_hcall(unsigned long call,
58 unsigned long arg1, unsigned long arg2, unsigned long arg3);
59
60/* Can't use our min() macro here: needs to be a constant */
61#define LGUEST_IRQS (NR_IRQS < 32 ? NR_IRQS: 32)
62
63#define LHCALL_RING_SIZE 64
64struct hcall_args
65{
66 /* These map directly onto eax, ebx, ecx, edx in struct lguest_regs */
67 unsigned long arg0, arg2, arg3, arg1;
68};
69
70#endif /* !__ASSEMBLY__ */
71#endif /* _I386_LGUEST_HCALL_H */
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index e3ffd14a3f0b..6a65231bc785 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -186,6 +186,7 @@ unifdef-y += cyclades.h
186unifdef-y += dccp.h 186unifdef-y += dccp.h
187unifdef-y += dirent.h 187unifdef-y += dirent.h
188unifdef-y += dlm.h 188unifdef-y += dlm.h
189unifdef-y += edd.h
189unifdef-y += elfcore.h 190unifdef-y += elfcore.h
190unifdef-y += errno.h 191unifdef-y += errno.h
191unifdef-y += errqueue.h 192unifdef-y += errqueue.h
@@ -306,6 +307,7 @@ unifdef-y += rtc.h
306unifdef-y += rtnetlink.h 307unifdef-y += rtnetlink.h
307unifdef-y += scc.h 308unifdef-y += scc.h
308unifdef-y += sched.h 309unifdef-y += sched.h
310unifdef-y += screen_info.h
309unifdef-y += sdla.h 311unifdef-y += sdla.h
310unifdef-y += selinux_netlink.h 312unifdef-y += selinux_netlink.h
311unifdef-y += sem.h 313unifdef-y += sem.h
@@ -341,6 +343,9 @@ unifdef-y += user.h
341unifdef-y += utsname.h 343unifdef-y += utsname.h
342unifdef-y += videodev2.h 344unifdef-y += videodev2.h
343unifdef-y += videodev.h 345unifdef-y += videodev.h
346unifdef-y += virtio_config.h
347unifdef-y += virtio_blk.h
348unifdef-y += virtio_net.h
344unifdef-y += wait.h 349unifdef-y += wait.h
345unifdef-y += wanrouter.h 350unifdef-y += wanrouter.h
346unifdef-y += watchdog.h 351unifdef-y += watchdog.h
diff --git a/include/linux/apm_bios.h b/include/linux/apm_bios.h
index 5f921c84827a..9754baa14921 100644
--- a/include/linux/apm_bios.h
+++ b/include/linux/apm_bios.h
@@ -16,29 +16,29 @@
16 * General Public License for more details. 16 * General Public License for more details.
17 */ 17 */
18 18
19typedef unsigned short apm_event_t; 19#include <linux/types.h>
20typedef unsigned short apm_eventinfo_t; 20
21struct apm_bios_info {
22 __u16 version;
23 __u16 cseg;
24 __u32 offset;
25 __u16 cseg_16;
26 __u16 dseg;
27 __u16 flags;
28 __u16 cseg_len;
29 __u16 cseg_16_len;
30 __u16 dseg_len;
31};
21 32
22#ifdef __KERNEL__ 33#ifdef __KERNEL__
23 34
24#include <linux/types.h> 35typedef unsigned short apm_event_t;
36typedef unsigned short apm_eventinfo_t;
25 37
26#define APM_CS (GDT_ENTRY_APMBIOS_BASE * 8) 38#define APM_CS (GDT_ENTRY_APMBIOS_BASE * 8)
27#define APM_CS_16 (APM_CS + 8) 39#define APM_CS_16 (APM_CS + 8)
28#define APM_DS (APM_CS_16 + 8) 40#define APM_DS (APM_CS_16 + 8)
29 41
30struct apm_bios_info {
31 u16 version;
32 u16 cseg;
33 u32 offset;
34 u16 cseg_16;
35 u16 dseg;
36 u16 flags;
37 u16 cseg_len;
38 u16 cseg_16_len;
39 u16 dseg_len;
40};
41
42/* Results of APM Installation Check */ 42/* Results of APM Installation Check */
43#define APM_16_BIT_SUPPORT 0x0001 43#define APM_16_BIT_SUPPORT 0x0001
44#define APM_32_BIT_SUPPORT 0x0002 44#define APM_32_BIT_SUPPORT 0x0002
diff --git a/include/linux/edd.h b/include/linux/edd.h
index 7b647822d6dc..5d747c5cd0fe 100644
--- a/include/linux/edd.h
+++ b/include/linux/edd.h
@@ -67,113 +67,113 @@
67#define EDD_INFO_USE_INT13_FN50 (1 << 7) 67#define EDD_INFO_USE_INT13_FN50 (1 << 7)
68 68
69struct edd_device_params { 69struct edd_device_params {
70 u16 length; 70 __u16 length;
71 u16 info_flags; 71 __u16 info_flags;
72 u32 num_default_cylinders; 72 __u32 num_default_cylinders;
73 u32 num_default_heads; 73 __u32 num_default_heads;
74 u32 sectors_per_track; 74 __u32 sectors_per_track;
75 u64 number_of_sectors; 75 __u64 number_of_sectors;
76 u16 bytes_per_sector; 76 __u16 bytes_per_sector;
77 u32 dpte_ptr; /* 0xFFFFFFFF for our purposes */ 77 __u32 dpte_ptr; /* 0xFFFFFFFF for our purposes */
78 u16 key; /* = 0xBEDD */ 78 __u16 key; /* = 0xBEDD */
79 u8 device_path_info_length; /* = 44 */ 79 __u8 device_path_info_length; /* = 44 */
80 u8 reserved2; 80 __u8 reserved2;
81 u16 reserved3; 81 __u16 reserved3;
82 u8 host_bus_type[4]; 82 __u8 host_bus_type[4];
83 u8 interface_type[8]; 83 __u8 interface_type[8];
84 union { 84 union {
85 struct { 85 struct {
86 u16 base_address; 86 __u16 base_address;
87 u16 reserved1; 87 __u16 reserved1;
88 u32 reserved2; 88 __u32 reserved2;
89 } __attribute__ ((packed)) isa; 89 } __attribute__ ((packed)) isa;
90 struct { 90 struct {
91 u8 bus; 91 __u8 bus;
92 u8 slot; 92 __u8 slot;
93 u8 function; 93 __u8 function;
94 u8 channel; 94 __u8 channel;
95 u32 reserved; 95 __u32 reserved;
96 } __attribute__ ((packed)) pci; 96 } __attribute__ ((packed)) pci;
97 /* pcix is same as pci */ 97 /* pcix is same as pci */
98 struct { 98 struct {
99 u64 reserved; 99 __u64 reserved;
100 } __attribute__ ((packed)) ibnd; 100 } __attribute__ ((packed)) ibnd;
101 struct { 101 struct {
102 u64 reserved; 102 __u64 reserved;
103 } __attribute__ ((packed)) xprs; 103 } __attribute__ ((packed)) xprs;
104 struct { 104 struct {
105 u64 reserved; 105 __u64 reserved;
106 } __attribute__ ((packed)) htpt; 106 } __attribute__ ((packed)) htpt;
107 struct { 107 struct {
108 u64 reserved; 108 __u64 reserved;
109 } __attribute__ ((packed)) unknown; 109 } __attribute__ ((packed)) unknown;
110 } interface_path; 110 } interface_path;
111 union { 111 union {
112 struct { 112 struct {
113 u8 device; 113 __u8 device;
114 u8 reserved1; 114 __u8 reserved1;
115 u16 reserved2; 115 __u16 reserved2;
116 u32 reserved3; 116 __u32 reserved3;
117 u64 reserved4; 117 __u64 reserved4;
118 } __attribute__ ((packed)) ata; 118 } __attribute__ ((packed)) ata;
119 struct { 119 struct {
120 u8 device; 120 __u8 device;
121 u8 lun; 121 __u8 lun;
122 u8 reserved1; 122 __u8 reserved1;
123 u8 reserved2; 123 __u8 reserved2;
124 u32 reserved3; 124 __u32 reserved3;
125 u64 reserved4; 125 __u64 reserved4;
126 } __attribute__ ((packed)) atapi; 126 } __attribute__ ((packed)) atapi;
127 struct { 127 struct {
128 u16 id; 128 __u16 id;
129 u64 lun; 129 __u64 lun;
130 u16 reserved1; 130 __u16 reserved1;
131 u32 reserved2; 131 __u32 reserved2;
132 } __attribute__ ((packed)) scsi; 132 } __attribute__ ((packed)) scsi;
133 struct { 133 struct {
134 u64 serial_number; 134 __u64 serial_number;
135 u64 reserved; 135 __u64 reserved;
136 } __attribute__ ((packed)) usb; 136 } __attribute__ ((packed)) usb;
137 struct { 137 struct {
138 u64 eui; 138 __u64 eui;
139 u64 reserved; 139 __u64 reserved;
140 } __attribute__ ((packed)) i1394; 140 } __attribute__ ((packed)) i1394;
141 struct { 141 struct {
142 u64 wwid; 142 __u64 wwid;
143 u64 lun; 143 __u64 lun;
144 } __attribute__ ((packed)) fibre; 144 } __attribute__ ((packed)) fibre;
145 struct { 145 struct {
146 u64 identity_tag; 146 __u64 identity_tag;
147 u64 reserved; 147 __u64 reserved;
148 } __attribute__ ((packed)) i2o; 148 } __attribute__ ((packed)) i2o;
149 struct { 149 struct {
150 u32 array_number; 150 __u32 array_number;
151 u32 reserved1; 151 __u32 reserved1;
152 u64 reserved2; 152 __u64 reserved2;
153 } __attribute__ ((packed)) raid; 153 } __attribute__ ((packed)) raid;
154 struct { 154 struct {
155 u8 device; 155 __u8 device;
156 u8 reserved1; 156 __u8 reserved1;
157 u16 reserved2; 157 __u16 reserved2;
158 u32 reserved3; 158 __u32 reserved3;
159 u64 reserved4; 159 __u64 reserved4;
160 } __attribute__ ((packed)) sata; 160 } __attribute__ ((packed)) sata;
161 struct { 161 struct {
162 u64 reserved1; 162 __u64 reserved1;
163 u64 reserved2; 163 __u64 reserved2;
164 } __attribute__ ((packed)) unknown; 164 } __attribute__ ((packed)) unknown;
165 } device_path; 165 } device_path;
166 u8 reserved4; 166 __u8 reserved4;
167 u8 checksum; 167 __u8 checksum;
168} __attribute__ ((packed)); 168} __attribute__ ((packed));
169 169
170struct edd_info { 170struct edd_info {
171 u8 device; 171 __u8 device;
172 u8 version; 172 __u8 version;
173 u16 interface_support; 173 __u16 interface_support;
174 u16 legacy_max_cylinder; 174 __u16 legacy_max_cylinder;
175 u8 legacy_max_head; 175 __u8 legacy_max_head;
176 u8 legacy_sectors_per_track; 176 __u8 legacy_sectors_per_track;
177 struct edd_device_params params; 177 struct edd_device_params params;
178} __attribute__ ((packed)); 178} __attribute__ ((packed));
179 179
@@ -184,8 +184,9 @@ struct edd {
184 unsigned char edd_info_nr; 184 unsigned char edd_info_nr;
185}; 185};
186 186
187#ifdef __KERNEL__
187extern struct edd edd; 188extern struct edd edd;
188 189#endif /* __KERNEL__ */
189#endif /*!__ASSEMBLY__ */ 190#endif /*!__ASSEMBLY__ */
190 191
191#endif /* _LINUX_EDD_H */ 192#endif /* _LINUX_EDD_H */
diff --git a/include/linux/lguest.h b/include/linux/lguest.h
index 157ad64aa7ce..8beb29134626 100644
--- a/include/linux/lguest.h
+++ b/include/linux/lguest.h
@@ -1,76 +1,16 @@
1/* Things the lguest guest needs to know. Note: like all lguest interfaces, 1/* Things the lguest guest needs to know. Note: like all lguest interfaces,
2 * this is subject to wild and random change between versions. */ 2 * this is subject to wild and random change between versions. */
3#ifndef _ASM_LGUEST_H 3#ifndef _LINUX_LGUEST_H
4#define _ASM_LGUEST_H 4#define _LINUX_LGUEST_H
5 5
6#ifndef __ASSEMBLY__ 6#ifndef __ASSEMBLY__
7#include <linux/time.h>
7#include <asm/irq.h> 8#include <asm/irq.h>
8 9#include <asm/lguest_hcall.h>
9#define LHCALL_FLUSH_ASYNC 0
10#define LHCALL_LGUEST_INIT 1
11#define LHCALL_CRASH 2
12#define LHCALL_LOAD_GDT 3
13#define LHCALL_NEW_PGTABLE 4
14#define LHCALL_FLUSH_TLB 5
15#define LHCALL_LOAD_IDT_ENTRY 6
16#define LHCALL_SET_STACK 7
17#define LHCALL_TS 8
18#define LHCALL_SET_CLOCKEVENT 9
19#define LHCALL_HALT 10
20#define LHCALL_BIND_DMA 12
21#define LHCALL_SEND_DMA 13
22#define LHCALL_SET_PTE 14
23#define LHCALL_SET_PMD 15
24#define LHCALL_LOAD_TLS 16
25 10
26#define LG_CLOCK_MIN_DELTA 100UL 11#define LG_CLOCK_MIN_DELTA 100UL
27#define LG_CLOCK_MAX_DELTA ULONG_MAX 12#define LG_CLOCK_MAX_DELTA ULONG_MAX
28 13
29/*G:031 First, how does our Guest contact the Host to ask for privileged
30 * operations? There are two ways: the direct way is to make a "hypercall",
31 * to make requests of the Host Itself.
32 *
33 * Our hypercall mechanism uses the highest unused trap code (traps 32 and
34 * above are used by real hardware interrupts). Seventeen hypercalls are
35 * available: the hypercall number is put in the %eax register, and the
36 * arguments (when required) are placed in %edx, %ebx and %ecx. If a return
37 * value makes sense, it's returned in %eax.
38 *
39 * Grossly invalid calls result in Sudden Death at the hands of the vengeful
40 * Host, rather than returning failure. This reflects Winston Churchill's
41 * definition of a gentleman: "someone who is only rude intentionally". */
42#define LGUEST_TRAP_ENTRY 0x1F
43
44static inline unsigned long
45hcall(unsigned long call,
46 unsigned long arg1, unsigned long arg2, unsigned long arg3)
47{
48 /* "int" is the Intel instruction to trigger a trap. */
49 asm volatile("int $" __stringify(LGUEST_TRAP_ENTRY)
50 /* The call is in %eax (aka "a"), and can be replaced */
51 : "=a"(call)
52 /* The other arguments are in %eax, %edx, %ebx & %ecx */
53 : "a"(call), "d"(arg1), "b"(arg2), "c"(arg3)
54 /* "memory" means this might write somewhere in memory.
55 * This isn't true for all calls, but it's safe to tell
56 * gcc that it might happen so it doesn't get clever. */
57 : "memory");
58 return call;
59}
60/*:*/
61
62void async_hcall(unsigned long call,
63 unsigned long arg1, unsigned long arg2, unsigned long arg3);
64
65/* Can't use our min() macro here: needs to be a constant */
66#define LGUEST_IRQS (NR_IRQS < 32 ? NR_IRQS: 32)
67
68#define LHCALL_RING_SIZE 64
69struct hcall_ring
70{
71 u32 eax, edx, ebx, ecx;
72};
73
74/*G:032 The second method of communicating with the Host is to via "struct 14/*G:032 The second method of communicating with the Host is to via "struct
75 * lguest_data". The Guest's very first hypercall is to tell the Host where 15 * lguest_data". The Guest's very first hypercall is to tell the Host where
76 * this is, and then the Guest and Host both publish information in it. :*/ 16 * this is, and then the Guest and Host both publish information in it. :*/
@@ -97,20 +37,24 @@ struct lguest_data
97 /* 0xFF == done (set by Host), 0 == pending (set by Guest). */ 37 /* 0xFF == done (set by Host), 0 == pending (set by Guest). */
98 u8 hcall_status[LHCALL_RING_SIZE]; 38 u8 hcall_status[LHCALL_RING_SIZE];
99 /* The actual registers for the hypercalls. */ 39 /* The actual registers for the hypercalls. */
100 struct hcall_ring hcalls[LHCALL_RING_SIZE]; 40 struct hcall_args hcalls[LHCALL_RING_SIZE];
101 41
102/* Fields initialized by the Host at boot: */ 42/* Fields initialized by the Host at boot: */
103 /* Memory not to try to access */ 43 /* Memory not to try to access */
104 unsigned long reserve_mem; 44 unsigned long reserve_mem;
105 /* ID of this Guest (used by network driver to set ethernet address) */
106 u16 guestid;
107 /* KHz for the TSC clock. */ 45 /* KHz for the TSC clock. */
108 u32 tsc_khz; 46 u32 tsc_khz;
47 /* Page where the top-level pagetable is */
48 unsigned long pgdir;
109 49
110/* Fields initialized by the Guest at boot: */ 50/* Fields initialized by the Guest at boot: */
111 /* Instruction range to suppress interrupts even if enabled */ 51 /* Instruction range to suppress interrupts even if enabled */
112 unsigned long noirq_start, noirq_end; 52 unsigned long noirq_start, noirq_end;
53 /* Address above which page tables are all identical. */
54 unsigned long kernel_address;
55 /* The vector to try to use for system calls (0x40 or 0x80). */
56 unsigned int syscall_vec;
113}; 57};
114extern struct lguest_data lguest_data; 58extern struct lguest_data lguest_data;
115#endif /* __ASSEMBLY__ */ 59#endif /* __ASSEMBLY__ */
116#endif /* _ASM_LGUEST_H */ 60#endif /* _LINUX_LGUEST_H */
diff --git a/include/linux/lguest_bus.h b/include/linux/lguest_bus.h
deleted file mode 100644
index d27853ddc644..000000000000
--- a/include/linux/lguest_bus.h
+++ /dev/null
@@ -1,51 +0,0 @@
1#ifndef _ASM_LGUEST_DEVICE_H
2#define _ASM_LGUEST_DEVICE_H
3/* Everything you need to know about lguest devices. */
4#include <linux/device.h>
5#include <linux/lguest.h>
6#include <linux/lguest_launcher.h>
7
8struct lguest_device {
9 /* Unique busid, and index into lguest_page->devices[] */
10 unsigned int index;
11
12 struct device dev;
13
14 /* Driver can hang data off here. */
15 void *private;
16};
17
18/*D:380 Since interrupt numbers are arbitrary, we use a convention: each device
19 * can use the interrupt number corresponding to its index. The +1 is because
20 * interrupt 0 is not usable (it's actually the timer interrupt). */
21static inline int lgdev_irq(const struct lguest_device *dev)
22{
23 return dev->index + 1;
24}
25/*:*/
26
27/* dma args must not be vmalloced! */
28void lguest_send_dma(unsigned long key, struct lguest_dma *dma);
29int lguest_bind_dma(unsigned long key, struct lguest_dma *dmas,
30 unsigned int num, u8 irq);
31void lguest_unbind_dma(unsigned long key, struct lguest_dma *dmas);
32
33/* Map the virtual device space */
34void *lguest_map(unsigned long phys_addr, unsigned long pages);
35void lguest_unmap(void *);
36
37struct lguest_driver {
38 const char *name;
39 struct module *owner;
40 u16 device_type;
41 int (*probe)(struct lguest_device *dev);
42 void (*remove)(struct lguest_device *dev);
43
44 struct device_driver drv;
45};
46
47extern int register_lguest_driver(struct lguest_driver *drv);
48extern void unregister_lguest_driver(struct lguest_driver *drv);
49
50extern struct lguest_device_desc *lguest_devices; /* Just past max_pfn */
51#endif /* _ASM_LGUEST_DEVICE_H */
diff --git a/include/linux/lguest_launcher.h b/include/linux/lguest_launcher.h
index 641670579446..61e1e3e6b1cc 100644
--- a/include/linux/lguest_launcher.h
+++ b/include/linux/lguest_launcher.h
@@ -1,6 +1,7 @@
1#ifndef _ASM_LGUEST_USER 1#ifndef _ASM_LGUEST_USER
2#define _ASM_LGUEST_USER 2#define _ASM_LGUEST_USER
3/* Everything the "lguest" userspace program needs to know. */ 3/* Everything the "lguest" userspace program needs to know. */
4#include <linux/types.h>
4/* They can register up to 32 arrays of lguest_dma. */ 5/* They can register up to 32 arrays of lguest_dma. */
5#define LGUEST_MAX_DMA 32 6#define LGUEST_MAX_DMA 32
6/* At most we can dma 16 lguest_dma in one op. */ 7/* At most we can dma 16 lguest_dma in one op. */
@@ -9,66 +10,6 @@
9/* How many devices? Assume each one wants up to two dma arrays per device. */ 10/* How many devices? Assume each one wants up to two dma arrays per device. */
10#define LGUEST_MAX_DEVICES (LGUEST_MAX_DMA/2) 11#define LGUEST_MAX_DEVICES (LGUEST_MAX_DMA/2)
11 12
12/*D:200
13 * Lguest I/O
14 *
15 * The lguest I/O mechanism is the only way Guests can talk to devices. There
16 * are two hypercalls involved: SEND_DMA for output and BIND_DMA for input. In
17 * each case, "struct lguest_dma" describes the buffer: this contains 16
18 * addr/len pairs, and if there are fewer buffer elements the len array is
19 * terminated with a 0.
20 *
21 * I/O is organized by keys: BIND_DMA attaches buffers to a particular key, and
22 * SEND_DMA transfers to buffers bound to particular key. By convention, keys
23 * correspond to a physical address within the device's page. This means that
24 * devices will never accidentally end up with the same keys, and allows the
25 * Host use The Futex Trick (as we'll see later in our journey).
26 *
27 * SEND_DMA simply indicates a key to send to, and the physical address of the
28 * "struct lguest_dma" to send. The Host will write the number of bytes
29 * transferred into the "struct lguest_dma"'s used_len member.
30 *
31 * BIND_DMA indicates a key to bind to, a pointer to an array of "struct
32 * lguest_dma"s ready for receiving, the size of that array, and an interrupt
33 * to trigger when data is received. The Host will only allow transfers into
34 * buffers with a used_len of zero: it then sets used_len to the number of
35 * bytes transferred and triggers the interrupt for the Guest to process the
36 * new input. */
37struct lguest_dma
38{
39 /* 0 if free to be used, filled by the Host. */
40 u32 used_len;
41 unsigned long addr[LGUEST_MAX_DMA_SECTIONS];
42 u16 len[LGUEST_MAX_DMA_SECTIONS];
43};
44/*:*/
45
46/*D:460 This is the layout of a block device memory page. The Launcher sets up
47 * the num_sectors initially to tell the Guest the size of the disk. The Guest
48 * puts the type, sector and length of the request in the first three fields,
49 * then DMAs to the Host. The Host processes the request, sets up the result,
50 * then DMAs back to the Guest. */
51struct lguest_block_page
52{
53 /* 0 is a read, 1 is a write. */
54 int type;
55 u32 sector; /* Offset in device = sector * 512. */
56 u32 bytes; /* Length expected to be read/written in bytes */
57 /* 0 = pending, 1 = done, 2 = done, error */
58 int result;
59 u32 num_sectors; /* Disk length = num_sectors * 512 */
60};
61
62/*D:520 The network device is basically a memory page where all the Guests on
63 * the network publish their MAC (ethernet) addresses: it's an array of "struct
64 * lguest_net": */
65struct lguest_net
66{
67 /* Simply the mac address (with multicast bit meaning promisc). */
68 unsigned char mac[6];
69};
70/*:*/
71
72/* Where the Host expects the Guest to SEND_DMA console output to. */ 13/* Where the Host expects the Guest to SEND_DMA console output to. */
73#define LGUEST_CONSOLE_DMA_KEY 0 14#define LGUEST_CONSOLE_DMA_KEY 0
74 15
@@ -81,38 +22,29 @@ struct lguest_net
81 * complex burden for the Host and suboptimal for the Guest, so we have our own 22 * complex burden for the Host and suboptimal for the Guest, so we have our own
82 * "lguest" bus and simple drivers. 23 * "lguest" bus and simple drivers.
83 * 24 *
84 * Devices are described by an array of LGUEST_MAX_DEVICES of these structs, 25 * Devices are described by a simplified ID, a status byte, and some "config"
85 * placed by the Launcher just above the top of physical memory: 26 * bytes which describe this device's configuration. This is placed by the
27 * Launcher just above the top of physical memory:
86 */ 28 */
87struct lguest_device_desc { 29struct lguest_device_desc {
88 /* The device type: console, network, disk etc. */ 30 /* The device type: console, network, disk etc. Type 0 terminates. */
89 u16 type; 31 __u8 type;
90#define LGUEST_DEVICE_T_CONSOLE 1 32 /* The number of bytes of the config array. */
91#define LGUEST_DEVICE_T_NET 2 33 __u8 config_len;
92#define LGUEST_DEVICE_T_BLOCK 3 34 /* A status byte, written by the Guest. */
93 35 __u8 status;
94 /* The specific features of this device: these depends on device type 36 __u8 config[0];
95 * except for LGUEST_DEVICE_F_RANDOMNESS. */ 37};
96 u16 features;
97#define LGUEST_NET_F_NOCSUM 0x4000 /* Don't bother checksumming */
98#define LGUEST_DEVICE_F_RANDOMNESS 0x8000 /* IRQ is fairly random */
99
100 /* This is how the Guest reports status of the device: the Host can set
101 * LGUEST_DEVICE_S_REMOVED to indicate removal, but the rest are only
102 * ever manipulated by the Guest, and only ever set. */
103 u16 status;
104/* 256 and above are device specific. */
105#define LGUEST_DEVICE_S_ACKNOWLEDGE 1 /* We have seen device. */
106#define LGUEST_DEVICE_S_DRIVER 2 /* We have found a driver */
107#define LGUEST_DEVICE_S_DRIVER_OK 4 /* Driver says OK! */
108#define LGUEST_DEVICE_S_REMOVED 8 /* Device has gone away. */
109#define LGUEST_DEVICE_S_REMOVED_ACK 16 /* Driver has been told. */
110#define LGUEST_DEVICE_S_FAILED 128 /* Something actually failed */
111 38
112 /* Each device exists somewhere in Guest physical memory, over some 39/*D:135 This is how we expect the device configuration field for a virtqueue
113 * number of pages. */ 40 * (type VIRTIO_CONFIG_F_VIRTQUEUE) to be laid out: */
114 u16 num_pages; 41struct lguest_vqconfig {
115 u32 pfn; 42 /* The number of entries in the virtio_ring */
43 __u16 num;
44 /* The interrupt we get when something happens. */
45 __u16 irq;
46 /* The page number of the virtio ring for this device. */
47 __u32 pfn;
116}; 48};
117/*:*/ 49/*:*/
118 50
@@ -120,7 +52,7 @@ struct lguest_device_desc {
120enum lguest_req 52enum lguest_req
121{ 53{
122 LHREQ_INITIALIZE, /* + pfnlimit, pgdir, start, pageoffset */ 54 LHREQ_INITIALIZE, /* + pfnlimit, pgdir, start, pageoffset */
123 LHREQ_GETDMA, /* + addr (returns &lguest_dma, irq in ->used_len) */ 55 LHREQ_GETDMA, /* No longer used */
124 LHREQ_IRQ, /* + irq */ 56 LHREQ_IRQ, /* + irq */
125 LHREQ_BREAK, /* + on/off flag (on blocks until someone does off) */ 57 LHREQ_BREAK, /* + on/off flag (on blocks until someone does off) */
126}; 58};
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 522b0dd836cf..e9fddb42f26c 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -361,4 +361,10 @@ struct ssb_device_id {
361#define SSB_ANY_ID 0xFFFF 361#define SSB_ANY_ID 0xFFFF
362#define SSB_ANY_REV 0xFF 362#define SSB_ANY_REV 0xFF
363 363
364struct virtio_device_id {
365 __u32 device;
366 __u32 vendor;
367};
368#define VIRTIO_DEV_ANY_ID 0xffffffff
369
364#endif /* LINUX_MOD_DEVICETABLE_H */ 370#endif /* LINUX_MOD_DEVICETABLE_H */
diff --git a/include/linux/screen_info.h b/include/linux/screen_info.h
index ba81ffe9958a..827b85bbf388 100644
--- a/include/linux/screen_info.h
+++ b/include/linux/screen_info.h
@@ -8,45 +8,43 @@
8 */ 8 */
9 9
10struct screen_info { 10struct screen_info {
11 u8 orig_x; /* 0x00 */ 11 __u8 orig_x; /* 0x00 */
12 u8 orig_y; /* 0x01 */ 12 __u8 orig_y; /* 0x01 */
13 u16 ext_mem_k; /* 0x02 */ 13 __u16 ext_mem_k; /* 0x02 */
14 u16 orig_video_page; /* 0x04 */ 14 __u16 orig_video_page; /* 0x04 */
15 u8 orig_video_mode; /* 0x06 */ 15 __u8 orig_video_mode; /* 0x06 */
16 u8 orig_video_cols; /* 0x07 */ 16 __u8 orig_video_cols; /* 0x07 */
17 u16 unused2; /* 0x08 */ 17 __u16 unused2; /* 0x08 */
18 u16 orig_video_ega_bx; /* 0x0a */ 18 __u16 orig_video_ega_bx;/* 0x0a */
19 u16 unused3; /* 0x0c */ 19 __u16 unused3; /* 0x0c */
20 u8 orig_video_lines; /* 0x0e */ 20 __u8 orig_video_lines; /* 0x0e */
21 u8 orig_video_isVGA; /* 0x0f */ 21 __u8 orig_video_isVGA; /* 0x0f */
22 u16 orig_video_points; /* 0x10 */ 22 __u16 orig_video_points;/* 0x10 */
23 23
24 /* VESA graphic mode -- linear frame buffer */ 24 /* VESA graphic mode -- linear frame buffer */
25 u16 lfb_width; /* 0x12 */ 25 __u16 lfb_width; /* 0x12 */
26 u16 lfb_height; /* 0x14 */ 26 __u16 lfb_height; /* 0x14 */
27 u16 lfb_depth; /* 0x16 */ 27 __u16 lfb_depth; /* 0x16 */
28 u32 lfb_base; /* 0x18 */ 28 __u32 lfb_base; /* 0x18 */
29 u32 lfb_size; /* 0x1c */ 29 __u32 lfb_size; /* 0x1c */
30 u16 cl_magic, cl_offset; /* 0x20 */ 30 __u16 cl_magic, cl_offset; /* 0x20 */
31 u16 lfb_linelength; /* 0x24 */ 31 __u16 lfb_linelength; /* 0x24 */
32 u8 red_size; /* 0x26 */ 32 __u8 red_size; /* 0x26 */
33 u8 red_pos; /* 0x27 */ 33 __u8 red_pos; /* 0x27 */
34 u8 green_size; /* 0x28 */ 34 __u8 green_size; /* 0x28 */
35 u8 green_pos; /* 0x29 */ 35 __u8 green_pos; /* 0x29 */
36 u8 blue_size; /* 0x2a */ 36 __u8 blue_size; /* 0x2a */
37 u8 blue_pos; /* 0x2b */ 37 __u8 blue_pos; /* 0x2b */
38 u8 rsvd_size; /* 0x2c */ 38 __u8 rsvd_size; /* 0x2c */
39 u8 rsvd_pos; /* 0x2d */ 39 __u8 rsvd_pos; /* 0x2d */
40 u16 vesapm_seg; /* 0x2e */ 40 __u16 vesapm_seg; /* 0x2e */
41 u16 vesapm_off; /* 0x30 */ 41 __u16 vesapm_off; /* 0x30 */
42 u16 pages; /* 0x32 */ 42 __u16 pages; /* 0x32 */
43 u16 vesa_attributes; /* 0x34 */ 43 __u16 vesa_attributes; /* 0x34 */
44 u32 capabilities; /* 0x36 */ 44 __u32 capabilities; /* 0x36 */
45 u8 _reserved[6]; /* 0x3a */ 45 __u8 _reserved[6]; /* 0x3a */
46} __attribute__((packed)); 46} __attribute__((packed));
47 47
48extern struct screen_info screen_info;
49
50#define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */ 48#define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
51#define VIDEO_TYPE_CGA 0x11 /* CGA Display */ 49#define VIDEO_TYPE_CGA 0x11 /* CGA Display */
52#define VIDEO_TYPE_EGAM 0x20 /* EGA/VGA in Monochrome Mode */ 50#define VIDEO_TYPE_EGAM 0x20 /* EGA/VGA in Monochrome Mode */
@@ -65,4 +63,17 @@ extern struct screen_info screen_info;
65 63
66#define VIDEO_TYPE_PMAC 0x60 /* PowerMacintosh frame buffer. */ 64#define VIDEO_TYPE_PMAC 0x60 /* PowerMacintosh frame buffer. */
67 65
66#ifdef __KERNEL__
67extern struct screen_info screen_info;
68
69#define ORIG_X (screen_info.orig_x)
70#define ORIG_Y (screen_info.orig_y)
71#define ORIG_VIDEO_MODE (screen_info.orig_video_mode)
72#define ORIG_VIDEO_COLS (screen_info.orig_video_cols)
73#define ORIG_VIDEO_EGA_BX (screen_info.orig_video_ega_bx)
74#define ORIG_VIDEO_LINES (screen_info.orig_video_lines)
75#define ORIG_VIDEO_ISVGA (screen_info.orig_video_isVGA)
76#define ORIG_VIDEO_POINTS (screen_info.orig_video_points)
77#endif /* __KERNEL__ */
78
68#endif /* _SCREEN_INFO_H */ 79#endif /* _SCREEN_INFO_H */
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
new file mode 100644
index 000000000000..14e1379876d3
--- /dev/null
+++ b/include/linux/virtio.h
@@ -0,0 +1,110 @@
1#ifndef _LINUX_VIRTIO_H
2#define _LINUX_VIRTIO_H
3/* Everything a virtio driver needs to work with any particular virtio
4 * implementation. */
5#include <linux/types.h>
6#include <linux/scatterlist.h>
7#include <linux/spinlock.h>
8#include <linux/device.h>
9#include <linux/mod_devicetable.h>
10
11/**
12 * virtqueue - a queue to register buffers for sending or receiving.
13 * @callback: the function to call when buffers are consumed (can be NULL).
14 * If this returns false, callbacks are suppressed until vq_ops->restart
15 * is called.
16 * @vdev: the virtio device this queue was created for.
17 * @vq_ops: the operations for this virtqueue (see below).
18 * @priv: a pointer for the virtqueue implementation to use.
19 */
20struct virtqueue
21{
22 bool (*callback)(struct virtqueue *vq);
23 struct virtio_device *vdev;
24 struct virtqueue_ops *vq_ops;
25 void *priv;
26};
27
28/**
29 * virtqueue_ops - operations for virtqueue abstraction layer
30 * @add_buf: expose buffer to other end
31 * vq: the struct virtqueue we're talking about.
32 * sg: the description of the buffer(s).
33 * out_num: the number of sg readable by other side
34 * in_num: the number of sg which are writable (after readable ones)
35 * data: the token identifying the buffer.
36 * Returns 0 or an error.
37 * @kick: update after add_buf
38 * vq: the struct virtqueue
39 * After one or more add_buf calls, invoke this to kick the other side.
40 * @get_buf: get the next used buffer
41 * vq: the struct virtqueue we're talking about.
42 * len: the length written into the buffer
43 * Returns NULL or the "data" token handed to add_buf.
44 * @restart: restart callbacks after callback returned false.
45 * vq: the struct virtqueue we're talking about.
46 * This returns "false" (and doesn't re-enable) if there are pending
47 * buffers in the queue, to avoid a race.
48 * @shutdown: "unadd" all buffers.
49 * vq: the struct virtqueue we're talking about.
50 * Remove everything from the queue.
51 *
52 * Locking rules are straightforward: the driver is responsible for
53 * locking. No two operations may be invoked simultaneously.
54 *
55 * All operations can be called in any context.
56 */
57struct virtqueue_ops {
58 int (*add_buf)(struct virtqueue *vq,
59 struct scatterlist sg[],
60 unsigned int out_num,
61 unsigned int in_num,
62 void *data);
63
64 void (*kick)(struct virtqueue *vq);
65
66 void *(*get_buf)(struct virtqueue *vq, unsigned int *len);
67
68 bool (*restart)(struct virtqueue *vq);
69
70 void (*shutdown)(struct virtqueue *vq);
71};
72
73/**
74 * virtio_device - representation of a device using virtio
75 * @index: unique position on the virtio bus
76 * @dev: underlying device.
77 * @id: the device type identification (used to match it with a driver).
78 * @config: the configuration ops for this device.
79 * @priv: private pointer for the driver's use.
80 */
81struct virtio_device
82{
83 int index;
84 struct device dev;
85 struct virtio_device_id id;
86 struct virtio_config_ops *config;
87 void *priv;
88};
89
90int register_virtio_device(struct virtio_device *dev);
91void unregister_virtio_device(struct virtio_device *dev);
92
93/**
94 * virtio_driver - operations for a virtio I/O driver
95 * @driver: underlying device driver (populate name and owner).
96 * @id_table: the ids serviced by this driver.
97 * @probe: the function to call when a device is found. Returns a token for
98 * remove, or PTR_ERR().
99 * @remove: the function when a device is removed.
100 */
101struct virtio_driver {
102 struct device_driver driver;
103 const struct virtio_device_id *id_table;
104 int (*probe)(struct virtio_device *dev);
105 void (*remove)(struct virtio_device *dev);
106};
107
108int register_virtio_driver(struct virtio_driver *drv);
109void unregister_virtio_driver(struct virtio_driver *drv);
110#endif /* _LINUX_VIRTIO_H */
diff --git a/include/linux/virtio_blk.h b/include/linux/virtio_blk.h
new file mode 100644
index 000000000000..7bd2bce0cfd9
--- /dev/null
+++ b/include/linux/virtio_blk.h
@@ -0,0 +1,51 @@
1#ifndef _LINUX_VIRTIO_BLK_H
2#define _LINUX_VIRTIO_BLK_H
3#include <linux/virtio_config.h>
4
5/* The ID for virtio_block */
6#define VIRTIO_ID_BLOCK 2
7
8/* Feature bits */
9#define VIRTIO_CONFIG_BLK_F 0x40
10#define VIRTIO_BLK_F_BARRIER 1 /* Does host support barriers? */
11
12/* The capacity (in 512-byte sectors). */
13#define VIRTIO_CONFIG_BLK_F_CAPACITY 0x41
14/* The maximum segment size. */
15#define VIRTIO_CONFIG_BLK_F_SIZE_MAX 0x42
16/* The maximum number of segments. */
17#define VIRTIO_CONFIG_BLK_F_SEG_MAX 0x43
18
19/* These two define direction. */
20#define VIRTIO_BLK_T_IN 0
21#define VIRTIO_BLK_T_OUT 1
22
23/* This bit says it's a scsi command, not an actual read or write. */
24#define VIRTIO_BLK_T_SCSI_CMD 2
25
26/* Barrier before this op. */
27#define VIRTIO_BLK_T_BARRIER 0x80000000
28
29/* This is the first element of the read scatter-gather list. */
30struct virtio_blk_outhdr
31{
32 /* VIRTIO_BLK_T* */
33 __u32 type;
34 /* io priority. */
35 __u32 ioprio;
36 /* Sector (ie. 512 byte offset) */
37 __u64 sector;
38 /* Where to put reply. */
39 __u64 id;
40};
41
42#define VIRTIO_BLK_S_OK 0
43#define VIRTIO_BLK_S_IOERR 1
44#define VIRTIO_BLK_S_UNSUPP 2
45
46/* This is the first element of the write scatter-gather list */
47struct virtio_blk_inhdr
48{
49 unsigned char status;
50};
51#endif /* _LINUX_VIRTIO_BLK_H */
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
new file mode 100644
index 000000000000..bcc01888df78
--- /dev/null
+++ b/include/linux/virtio_config.h
@@ -0,0 +1,111 @@
1#ifndef _LINUX_VIRTIO_CONFIG_H
2#define _LINUX_VIRTIO_CONFIG_H
3/* Virtio devices use a standardized configuration space to define their
4 * features and pass configuration information, but each implementation can
5 * store and access that space differently. */
6#include <linux/types.h>
7
8/* Status byte for guest to report progress, and synchronize config. */
9/* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */
10#define VIRTIO_CONFIG_S_ACKNOWLEDGE 1
11/* We have found a driver for the device. */
12#define VIRTIO_CONFIG_S_DRIVER 2
13/* Driver has used its parts of the config, and is happy */
14#define VIRTIO_CONFIG_S_DRIVER_OK 4
15/* We've given up on this device. */
16#define VIRTIO_CONFIG_S_FAILED 0x80
17
18/* Feature byte (actually 7 bits availabe): */
19/* Requirements/features of the virtio implementation. */
20#define VIRTIO_CONFIG_F_VIRTIO 1
21/* Requirements/features of the virtqueue (may have more than one). */
22#define VIRTIO_CONFIG_F_VIRTQUEUE 2
23
24#ifdef __KERNEL__
25struct virtio_device;
26
27/**
28 * virtio_config_ops - operations for configuring a virtio device
29 * @find: search for the next configuration field of the given type.
30 * vdev: the virtio_device
31 * type: the feature type
32 * len: the (returned) length of the field if found.
33 * Returns a token if found, or NULL. Never returnes the same field twice
34 * (ie. it's used up).
35 * @get: read the value of a configuration field after find().
36 * vdev: the virtio_device
37 * token: the token returned from find().
38 * buf: the buffer to write the field value into.
39 * len: the length of the buffer (given by find()).
40 * Note that contents are conventionally little-endian.
41 * @set: write the value of a configuration field after find().
42 * vdev: the virtio_device
43 * token: the token returned from find().
44 * buf: the buffer to read the field value from.
45 * len: the length of the buffer (given by find()).
46 * Note that contents are conventionally little-endian.
47 * @get_status: read the status byte
48 * vdev: the virtio_device
49 * Returns the status byte
50 * @set_status: write the status byte
51 * vdev: the virtio_device
52 * status: the new status byte
53 * @find_vq: find the first VIRTIO_CONFIG_F_VIRTQUEUE and create a virtqueue.
54 * vdev: the virtio_device
55 * callback: the virqtueue callback
56 * Returns the new virtqueue or ERR_PTR().
57 * @del_vq: free a virtqueue found by find_vq().
58 */
59struct virtio_config_ops
60{
61 void *(*find)(struct virtio_device *vdev, u8 type, unsigned *len);
62 void (*get)(struct virtio_device *vdev, void *token,
63 void *buf, unsigned len);
64 void (*set)(struct virtio_device *vdev, void *token,
65 const void *buf, unsigned len);
66 u8 (*get_status)(struct virtio_device *vdev);
67 void (*set_status)(struct virtio_device *vdev, u8 status);
68 struct virtqueue *(*find_vq)(struct virtio_device *vdev,
69 bool (*callback)(struct virtqueue *));
70 void (*del_vq)(struct virtqueue *vq);
71};
72
73/**
74 * virtio_config_val - get a single virtio config and mark it used.
75 * @config: the virtio config space
76 * @type: the type to search for.
77 * @val: a pointer to the value to fill in.
78 *
79 * Once used, the config type is marked with VIRTIO_CONFIG_F_USED so it can't
80 * be found again. This version does endian conversion. */
81#define virtio_config_val(vdev, type, v) ({ \
82 int _err = __virtio_config_val((vdev),(type),(v),sizeof(*(v))); \
83 \
84 BUILD_BUG_ON(sizeof(*(v)) != 1 && sizeof(*(v)) != 2 \
85 && sizeof(*(v)) != 4 && sizeof(*(v)) != 8); \
86 if (!_err) { \
87 switch (sizeof(*(v))) { \
88 case 2: le16_to_cpus((__u16 *) v); break; \
89 case 4: le32_to_cpus((__u32 *) v); break; \
90 case 8: le64_to_cpus((__u64 *) v); break; \
91 } \
92 } \
93 _err; \
94})
95
96int __virtio_config_val(struct virtio_device *dev,
97 u8 type, void *val, size_t size);
98
99/**
100 * virtio_use_bit - helper to use a feature bit in a bitfield value.
101 * @dev: the virtio device
102 * @token: the token as returned from vdev->config->find().
103 * @len: the length of the field.
104 * @bitnum: the bit to test.
105 *
106 * If handed a NULL token, it returns false, otherwise returns bit status.
107 * If it's one, it sets the mirroring acknowledgement bit. */
108int virtio_use_bit(struct virtio_device *vdev,
109 void *token, unsigned int len, unsigned int bitnum);
110#endif /* __KERNEL__ */
111#endif /* _LINUX_VIRTIO_CONFIG_H */
diff --git a/include/linux/virtio_console.h b/include/linux/virtio_console.h
new file mode 100644
index 000000000000..ed2d4ead7eb7
--- /dev/null
+++ b/include/linux/virtio_console.h
@@ -0,0 +1,12 @@
1#ifndef _LINUX_VIRTIO_CONSOLE_H
2#define _LINUX_VIRTIO_CONSOLE_H
3#include <linux/virtio_config.h>
4
5/* The ID for virtio console */
6#define VIRTIO_ID_CONSOLE 3
7
8#ifdef __KERNEL__
9int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int));
10#endif /* __KERNEL__ */
11
12#endif /* _LINUX_VIRTIO_CONSOLE_H */
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
new file mode 100644
index 000000000000..ae469ae55d36
--- /dev/null
+++ b/include/linux/virtio_net.h
@@ -0,0 +1,36 @@
1#ifndef _LINUX_VIRTIO_NET_H
2#define _LINUX_VIRTIO_NET_H
3#include <linux/virtio_config.h>
4
5/* The ID for virtio_net */
6#define VIRTIO_ID_NET 1
7
8/* The bitmap of config for virtio net */
9#define VIRTIO_CONFIG_NET_F 0x40
10#define VIRTIO_NET_F_NO_CSUM 0
11#define VIRTIO_NET_F_TSO4 1
12#define VIRTIO_NET_F_UFO 2
13#define VIRTIO_NET_F_TSO4_ECN 3
14#define VIRTIO_NET_F_TSO6 4
15
16/* The config defining mac address. */
17#define VIRTIO_CONFIG_NET_MAC_F 0x41
18
19/* This is the first element of the scatter-gather list. If you don't
20 * specify GSO or CSUM features, you can simply ignore the header. */
21struct virtio_net_hdr
22{
23#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 // Use csum_start, csum_offset
24 __u8 flags;
25#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame
26#define VIRTIO_NET_HDR_GSO_TCPV4 1 // GSO frame, IPv4 TCP (TSO)
27/* FIXME: Do we need this? If they said they can handle ECN, do they care? */
28#define VIRTIO_NET_HDR_GSO_TCPV4_ECN 2 // GSO frame, IPv4 TCP w/ ECN
29#define VIRTIO_NET_HDR_GSO_UDP 3 // GSO frame, IPv4 UDP (UFO)
30#define VIRTIO_NET_HDR_GSO_TCPV6 4 // GSO frame, IPv6 TCP
31 __u8 gso_type;
32 __u16 gso_size;
33 __u16 csum_start;
34 __u16 csum_offset;
35};
36#endif /* _LINUX_VIRTIO_NET_H */
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
new file mode 100644
index 000000000000..ac69e7bb5a14
--- /dev/null
+++ b/include/linux/virtio_ring.h
@@ -0,0 +1,119 @@
1#ifndef _LINUX_VIRTIO_RING_H
2#define _LINUX_VIRTIO_RING_H
3/* An interface for efficient virtio implementation, currently for use by KVM
4 * and lguest, but hopefully others soon. Do NOT change this since it will
5 * break existing servers and clients.
6 *
7 * This header is BSD licensed so anyone can use the definitions to implement
8 * compatible drivers/servers.
9 *
10 * Copyright Rusty Russell IBM Corporation 2007. */
11#include <linux/types.h>
12
13/* This marks a buffer as continuing via the next field. */
14#define VRING_DESC_F_NEXT 1
15/* This marks a buffer as write-only (otherwise read-only). */
16#define VRING_DESC_F_WRITE 2
17
18/* This means don't notify other side when buffer added. */
19#define VRING_USED_F_NO_NOTIFY 1
20/* This means don't interrupt guest when buffer consumed. */
21#define VRING_AVAIL_F_NO_INTERRUPT 1
22
23/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */
24struct vring_desc
25{
26 /* Address (guest-physical). */
27 __u64 addr;
28 /* Length. */
29 __u32 len;
30 /* The flags as indicated above. */
31 __u16 flags;
32 /* We chain unused descriptors via this, too */
33 __u16 next;
34};
35
36struct vring_avail
37{
38 __u16 flags;
39 __u16 idx;
40 __u16 ring[];
41};
42
43/* u32 is used here for ids for padding reasons. */
44struct vring_used_elem
45{
46 /* Index of start of used descriptor chain. */
47 __u32 id;
48 /* Total length of the descriptor chain which was used (written to) */
49 __u32 len;
50};
51
52struct vring_used
53{
54 __u16 flags;
55 __u16 idx;
56 struct vring_used_elem ring[];
57};
58
59struct vring {
60 unsigned int num;
61
62 struct vring_desc *desc;
63
64 struct vring_avail *avail;
65
66 struct vring_used *used;
67};
68
69/* The standard layout for the ring is a continuous chunk of memory which looks
70 * like this. The used fields will be aligned to a "num+1" boundary.
71 *
72 * struct vring
73 * {
74 * // The actual descriptors (16 bytes each)
75 * struct vring_desc desc[num];
76 *
77 * // A ring of available descriptor heads with free-running index.
78 * __u16 avail_flags;
79 * __u16 avail_idx;
80 * __u16 available[num];
81 *
82 * // Padding so a correctly-chosen num value will cache-align used_idx.
83 * char pad[sizeof(struct vring_desc) - sizeof(avail_flags)];
84 *
85 * // A ring of used descriptor heads with free-running index.
86 * __u16 used_flags;
87 * __u16 used_idx;
88 * struct vring_used_elem used[num];
89 * };
90 */
91static inline void vring_init(struct vring *vr, unsigned int num, void *p)
92{
93 vr->num = num;
94 vr->desc = p;
95 vr->avail = p + num*sizeof(struct vring);
96 vr->used = p + (num+1)*(sizeof(struct vring) + sizeof(__u16));
97}
98
99static inline unsigned vring_size(unsigned int num)
100{
101 return (num + 1) * (sizeof(struct vring_desc) + sizeof(__u16))
102 + sizeof(__u32) + num * sizeof(struct vring_used_elem);
103}
104
105#ifdef __KERNEL__
106#include <linux/irqreturn.h>
107struct virtio_device;
108struct virtqueue;
109
110struct virtqueue *vring_new_virtqueue(unsigned int num,
111 struct virtio_device *vdev,
112 void *pages,
113 void (*notify)(struct virtqueue *vq),
114 bool (*callback)(struct virtqueue *vq));
115void vring_del_virtqueue(struct virtqueue *vq);
116
117irqreturn_t vring_interrupt(int irq, void *_vq);
118#endif /* __KERNEL__ */
119#endif /* _LINUX_VIRTIO_RING_H */
diff --git a/include/video/Kbuild b/include/video/Kbuild
index 53a6c7310e61..0e406f730c2f 100644
--- a/include/video/Kbuild
+++ b/include/video/Kbuild
@@ -1 +1,2 @@
1unifdef-y += sisfb.h uvesafb.h 1unifdef-y += sisfb.h uvesafb.h
2unifdef-y += edid.h
diff --git a/include/video/edid.h b/include/video/edid.h
index f6a42d6c2e2d..928c342b33d6 100644
--- a/include/video/edid.h
+++ b/include/video/edid.h
@@ -1,17 +1,16 @@
1#ifndef __linux_video_edid_h__ 1#ifndef __linux_video_edid_h__
2#define __linux_video_edid_h__ 2#define __linux_video_edid_h__
3 3
4#ifdef __KERNEL__ 4#if !defined(__KERNEL__) || defined(CONFIG_X86)
5
6 5
7#ifdef CONFIG_X86
8struct edid_info { 6struct edid_info {
9 unsigned char dummy[128]; 7 unsigned char dummy[128];
10}; 8};
11 9
10#ifdef __KERNEL__
12extern struct edid_info edid_info; 11extern struct edid_info edid_info;
13#endif /* CONFIG_X86 */
14
15#endif /* __KERNEL__ */ 12#endif /* __KERNEL__ */
16 13
14#endif
15
17#endif /* __linux_video_edid_h__ */ 16#endif /* __linux_video_edid_h__ */