Index: head-2006-02-23/drivers/xen/Kconfig =================================================================== --- head-2006-02-23.orig/drivers/xen/Kconfig 2006-02-28 16:33:03.000000000 +0100 +++ head-2006-02-23/drivers/xen/Kconfig 2006-02-28 15:56:27.000000000 +0100 @@ -160,6 +160,12 @@ config XEN_TPMDEV_FRONTEND select TCG_XEN help The TPM-device frontend driver. + +config XEN_CONSOLE + tristate "Xen virtual console" + default y + help + The Xen virtual console is ... config XEN_NETDEV_LOOPBACK tristate "Network-device loopback driver" Index: head-2006-02-23/drivers/xen/console/Makefile =================================================================== --- head-2006-02-23.orig/drivers/xen/console/Makefile 2006-02-28 16:33:03.000000000 +0100 +++ head-2006-02-23/drivers/xen/console/Makefile 2006-02-28 16:35:28.000000000 +0100 @@ -1,2 +1,3 @@ +obj-$(CONFIG_XEN_CONSOLE) := xencons.o -obj-y := console.o xencons_ring.o +xencons-y := console.o xencons_ring.o Index: head-2006-02-23/drivers/xen/console/console.c =================================================================== --- head-2006-02-23.orig/drivers/xen/console/console.c 2006-02-28 16:33:03.000000000 +0100 +++ head-2006-02-23/drivers/xen/console/console.c 2006-02-28 16:29:42.000000000 +0100 @@ -44,8 +44,10 @@ #include #include #include +#ifndef MODULE #include #include +#endif #include #include #include @@ -68,7 +70,7 @@ static enum { XC_OFF, XC_DEFAULT, XC_TTY, XC_SERIAL } xc_mode = XC_DEFAULT; static int xc_num = -1; -#ifdef CONFIG_MAGIC_SYSRQ +#if defined(CONFIG_MAGIC_SYSRQ) && !defined(MODULE) static unsigned long sysrq_requested; extern int sysrq_enabled; #endif @@ -103,7 +105,12 @@ static int __init xencons_setup(char *st return 1; } +#ifndef MODULE __setup("xencons=", xencons_setup); +#else +static char __initdata mode_str[128]; +module_param_string(mode, mode_str, sizeof(mode_str), 0); +#endif /* The kernel and user-land drivers share a common transmit buffer. */ static unsigned int wbuf_size = 4096; @@ -119,7 +126,12 @@ static int __init xencons_bufsz_setup(ch wbuf_size <<= 1; return 1; } +#ifndef MODULE __setup("xencons_bufsz=", xencons_bufsz_setup); +#else +static char __initdata bufsz_str[32]; +module_param_string(bufsz, bufsz_str, sizeof(bufsz_str), 0); +#endif /* This lock protects accesses to the common transmit buffer. */ static spinlock_t xencons_lock = SPIN_LOCK_UNLOCKED; @@ -213,12 +225,27 @@ static int __init xen_console_init(void) return __RETCODE; } +#ifndef MODULE wbuf = alloc_bootmem(wbuf_size); +#else + wbuf = kmalloc(wbuf_size, GFP_KERNEL); +#endif + if (!wbuf) + return -ENOMEM; register_console(&kcons_info); return __RETCODE; } + +static void xen_console_exit(void) +{ +#ifdef MODULE + unregister_console(&kcons_info); +#endif +} + +#ifndef MODULE console_initcall(xen_console_init); /*** Useful function for console debugging -- goes straight to Xen. ***/ @@ -238,9 +265,14 @@ asmlinkage int xprintk(const char *fmt, return 0; } +#endif /*** Forcibly flush console data before dying. ***/ +#ifndef MODULE void xencons_force_flush(void) +#else +static void _xencons_force_flush(void) +#endif { int sz; @@ -259,6 +291,15 @@ void xencons_force_flush(void) } } +#ifndef MODULE +void xencons_resume(void) +#else +static void _xencons_resume(void) +#endif +{ + (void)xencons_ring_init(); +} + /******************** User-space console driver (/dev/console) ************/ @@ -281,7 +322,7 @@ void xencons_rx(char *buf, unsigned len, goto out; for (i = 0; i < len; i++) { -#ifdef CONFIG_MAGIC_SYSRQ +#if defined(CONFIG_MAGIC_SYSRQ) && !defined(MODULE) if (sysrq_enabled) { if (buf[i] == '\x0f') { /* ^O */ sysrq_requested = jiffies; @@ -569,6 +610,14 @@ static int __init xencons_init(void) if (xen_init() < 0) return -ENODEV; +#ifdef MODULE + xencons_setup(mode_str); + xencons_bufsz_setup(bufsz_str); + rc = xen_console_init(); + if (rc) + return rc; +#endif + if (xc_mode == XC_OFF) return 0; @@ -576,8 +625,10 @@ static int __init xencons_init(void) xencons_driver = alloc_tty_driver((xc_mode == XC_SERIAL) ? 1 : MAX_NR_CONSOLES); - if (xencons_driver == NULL) + if (xencons_driver == NULL) { + xen_console_exit(); return -ENOMEM; + } DRV(xencons_driver)->name = "xencons"; DRV(xencons_driver)->major = TTY_MAJOR; @@ -611,6 +662,7 @@ static int __init xencons_init(void) DRV(xencons_driver)->name_base); put_tty_driver(xencons_driver); xencons_driver = NULL; + xen_console_exit(); return rc; } @@ -630,12 +682,27 @@ static int __init xencons_init(void) printk("Xen virtual console successfully installed as %s%d\n", DRV(xencons_driver)->name, DRV(xencons_driver)->name_base ); - + +#ifdef MODULE + __xencons_resume = _xencons_resume; + __xencons_force_flush = _xencons_force_flush; + __unsafe(THIS_MODULE); +#endif + return 0; } module_init(xencons_init); +static void __exit xencons_exit(void) +{ + BUG(); +} + +module_exit(xencons_exit); + +MODULE_LICENSE("Dual BSD/GPL"); + /* * Local variables: * c-file-style: "linux" Index: head-2006-02-23/drivers/xen/console/xencons_ring.c =================================================================== --- head-2006-02-23.orig/drivers/xen/console/xencons_ring.c 2006-02-28 16:33:03.000000000 +0100 +++ head-2006-02-23/drivers/xen/console/xencons_ring.c 2006-02-28 15:59:30.000000000 +0100 @@ -109,11 +109,6 @@ int xencons_ring_init(void) return 0; } -void xencons_resume(void) -{ - (void)xencons_ring_init(); -} - /* * Local variables: * c-file-style: "linux" Index: head-2006-02-23/drivers/xen/core/reboot.c =================================================================== --- head-2006-02-23.orig/drivers/xen/core/reboot.c 2006-02-23 11:55:09.000000000 +0100 +++ head-2006-02-23/drivers/xen/core/reboot.c 2006-02-28 16:35:13.000000000 +0100 @@ -25,6 +25,13 @@ void (*pm_power_off)(void); EXPORT_SYMBOL(pm_power_off); #endif +#ifdef CONFIG_XEN_CONSOLE_MODULE +void (*__xencons_force_flush)(void) = NULL; +EXPORT_SYMBOL(__xencons_force_flush); +void (*__xencons_resume)(void) = NULL; +EXPORT_SYMBOL(__xencons_resume); +#endif + #define SHUTDOWN_INVALID -1 #define SHUTDOWN_POWEROFF 0 #define SHUTDOWN_REBOOT 1 Index: head-2006-02-23/include/xen/xencons.h =================================================================== --- head-2006-02-23.orig/include/xen/xencons.h 2006-02-28 16:33:03.000000000 +0100 +++ head-2006-02-23/include/xen/xencons.h 2006-02-28 15:53:35.000000000 +0100 @@ -1,8 +1,29 @@ #ifndef __ASM_XENCONS_H__ #define __ASM_XENCONS_H__ +#ifdef CONFIG_XEN_CONSOLE void xencons_force_flush(void); void xencons_resume(void); +#else +#ifdef CONFIG_XEN_CONSOLE_MODULE +extern void (*__xencons_force_flush)(void); +extern void (*__xencons_resume)(void); +#endif +static inline void xencons_force_flush(void) +{ +#ifdef CONFIG_XEN_CONSOLE_MODULE + if (__xencons_force_flush) + __xencons_force_flush(); +#endif +} +static inline void xencons_resume(void) +{ +#ifdef CONFIG_XEN_CONSOLE_MODULE + if (__xencons_resume) + __xencons_resume(); +#endif +} +#endif /* Interrupt work hooks. Receive data, or kick data out. */ void xencons_rx(char *buf, unsigned len, struct pt_regs *regs);