diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2007-10-21 21:24:21 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2007-10-23 01:49:56 -0400 |
commit | 19f1537b7b8a9a82665db3ad8210a9d954d13acd (patch) | |
tree | 793c1f8763350012caa521a55c5778b1c633b7e5 /arch/x86/lguest/boot.c | |
parent | 15045275c32bf6d15d32c2eca8157be9c0ba6e45 (diff) |
Lguest support for Virtio
This makes lguest able to use the virtio devices.
We change the device descriptor page from a simple array to a variable
length "type, config_len, status, config data..." format, and
implement virtio_config_ops to read from that config data.
We use the virtio ring implementation for an efficient Guest <-> Host
virtqueue mechanism, and the new LHCALL_NOTIFY hypercall to kick the
host when it changes.
We also use LHCALL_NOTIFY on kernel addresses for very very early
console output. We could have another hypercall, but this hack works
quite well.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'arch/x86/lguest/boot.c')
-rw-r--r-- | arch/x86/lguest/boot.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c index 959aeebb02f5..495e46a1f111 100644 --- a/arch/x86/lguest/boot.c +++ b/arch/x86/lguest/boot.c | |||
@@ -55,6 +55,7 @@ | |||
55 | #include <linux/clockchips.h> | 55 | #include <linux/clockchips.h> |
56 | #include <linux/lguest.h> | 56 | #include <linux/lguest.h> |
57 | #include <linux/lguest_launcher.h> | 57 | #include <linux/lguest_launcher.h> |
58 | #include <linux/virtio_console.h> | ||
58 | #include <asm/paravirt.h> | 59 | #include <asm/paravirt.h> |
59 | #include <asm/param.h> | 60 | #include <asm/param.h> |
60 | #include <asm/page.h> | 61 | #include <asm/page.h> |
@@ -849,6 +850,23 @@ static __init char *lguest_memory_setup(void) | |||
849 | return "LGUEST"; | 850 | return "LGUEST"; |
850 | } | 851 | } |
851 | 852 | ||
853 | /* Before virtqueues are set up, we use LHCALL_NOTIFY on normal memory to | ||
854 | * produce console output. */ | ||
855 | static __init int early_put_chars(u32 vtermno, const char *buf, int count) | ||
856 | { | ||
857 | char scratch[17]; | ||
858 | unsigned int len = count; | ||
859 | |||
860 | if (len > sizeof(scratch) - 1) | ||
861 | len = sizeof(scratch) - 1; | ||
862 | scratch[len] = '\0'; | ||
863 | memcpy(scratch, buf, len); | ||
864 | hcall(LHCALL_NOTIFY, __pa(scratch), 0, 0); | ||
865 | |||
866 | /* This routine returns the number of bytes actually written. */ | ||
867 | return len; | ||
868 | } | ||
869 | |||
852 | /*G:050 | 870 | /*G:050 |
853 | * Patching (Powerfully Placating Performance Pedants) | 871 | * Patching (Powerfully Placating Performance Pedants) |
854 | * | 872 | * |
@@ -1048,6 +1066,9 @@ __init void lguest_init(void *boot) | |||
1048 | * adapted for lguest's use. */ | 1066 | * adapted for lguest's use. */ |
1049 | add_preferred_console("hvc", 0, NULL); | 1067 | add_preferred_console("hvc", 0, NULL); |
1050 | 1068 | ||
1069 | /* Register our very early console. */ | ||
1070 | virtio_cons_early_init(early_put_chars); | ||
1071 | |||
1051 | /* Last of all, we set the power management poweroff hook to point to | 1072 | /* Last of all, we set the power management poweroff hook to point to |
1052 | * the Guest routine to power off. */ | 1073 | * the Guest routine to power off. */ |
1053 | pm_power_off = lguest_power_off; | 1074 | pm_power_off = lguest_power_off; |