From aa819a503e9dab87d2451996ab75133b2022f871 Mon Sep 17 00:00:00 2001 From: Stephen Tweedie Date: Wed, 21 Nov 2007 18:40:31 +0000 Subject: [PATCH] DEBUG: Add xprintk to log directly via hypercall, for early debugging Signed-off-by: Stephen Tweedie --- arch/x86/xen/enlighten.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index bb97446..b091b1c 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -137,6 +137,37 @@ static void __init xen_vcpu_setup(int cpu) } } +static void kcons_write_dom0(const char *s, unsigned int count) +{ + int rc; + + while ((count > 0) && + ((rc = HYPERVISOR_console_io( + CONSOLEIO_write, count, (char *)s)) > 0)) { + count -= rc; + s += rc; + } +} + + +/*** Useful function for console debugging -- goes straight to Xen. ***/ +asmlinkage int xprintk(const char *fmt, ...) +{ + va_list args; + int printk_len; + static char printk_buf[1024]; + + /* Emit the output into the temporary buffer */ + va_start(args, fmt); + printk_len = vsnprintf(printk_buf, sizeof(printk_buf), fmt, args); + va_end(args); + + /* Send the processed output directly to Xen. */ + kcons_write_dom0(printk_buf, printk_len); + + return 0; +} + static void __init xen_banner(void) { printk(KERN_INFO "Booting paravirtualized kernel on %s\n", -- 1.5.4.1