From 3b4181bd50a27eb18e3c415278beb8b78c1d44b8 Mon Sep 17 00:00:00 2001 From: Stephen Tweedie Date: Wed, 21 Nov 2007 18:40:31 +0000 Subject: [PATCH] xen debug: Add xprintk to log directly via hypercall For early debugging, it is useful to have a way of doing debugging output direct to the hypervisor without having to rely on console being fully initialised. Signed-off-by: Stephen Tweedie --- arch/x86/xen/enlighten.c | 32 ++++++++++++++++++++++++++++++++ include/xen/hvc-console.h | 1 + 2 files changed, 33 insertions(+), 0 deletions(-) diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 94c39aa..225432c 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -141,6 +142,37 @@ static void __init xen_banner(void) printk(KERN_INFO "Hypervisor signature: %s\n", xen_start_info->magic); } +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 xen_cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { diff --git a/include/xen/hvc-console.h b/include/xen/hvc-console.h index 21c0ecf..cb7a3c9 100644 --- a/include/xen/hvc-console.h +++ b/include/xen/hvc-console.h @@ -2,5 +2,6 @@ #define XEN_HVC_CONSOLE_H extern struct console xenboot_console; +extern asmlinkage int xprintk(const char *fmt, ...); #endif /* XEN_HVC_CONSOLE_H */ -- 1.5.3.4