From: Andrew Cooper Date: Sun, 29 Mar 2015 18:17:05 +0000 (+0100) Subject: Write to the hypervisor console X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1cb1e25efbf77c798c41667544bea39e7ef7c96c;p=people%2Froyger%2Fxen-test-framework.git Write to the hypervisor console Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/hypercall_page.S b/arch/x86/hypercall_page.S index 4e8ed73..725cfb2 100644 --- a/arch/x86/hypercall_page.S +++ b/arch/x86/hypercall_page.S @@ -9,4 +9,5 @@ GLOBAL(hypercall_page) .fill PAGE_SIZE, 1, 0xc3 .size hypercall_page, PAGE_SIZE +DECLARE_HYPERCALL(console_io) DECLARE_HYPERCALL(sched_op) diff --git a/arch/x86/setup.c b/arch/x86/setup.c index 2a2451d..09669b7 100644 --- a/arch/x86/setup.c +++ b/arch/x86/setup.c @@ -1,17 +1,22 @@ #include +#include +#include #include -#include - #ifdef CONFIG_ENV_pv /* Filled in by head_pv.S */ start_info_t *start_info = NULL; #endif -void arch_setup(void) +static void xen_console_write(const char *buf, size_t len) { + hypercall_console_write(buf, len); +} +void arch_setup(void) +{ + register_console_callback(xen_console_write); } /* diff --git a/common/console.c b/common/console.c index 0f907fe..da68dba 100644 --- a/common/console.c +++ b/common/console.c @@ -6,6 +6,7 @@ /* * Output functions, registered if/when available. * Possibilities: + * - Xen hypervisor console */ static cons_output_cb output_fns[1]; static unsigned int nr_cons_cb; diff --git a/include/arch/x86/x86_32/hypercall-x86_32.h b/include/arch/x86/x86_32/hypercall-x86_32.h index 0394cd9..b31ef4a 100644 --- a/include/arch/x86/x86_32/hypercall-x86_32.h +++ b/include/arch/x86/x86_32/hypercall-x86_32.h @@ -19,6 +19,18 @@ (type)__res; \ }) +#define _hypercall32_3(type, name, a1, a2, a3) \ + ({ \ + long __res, __ign1, __ign2, __ign3; \ + asm volatile ( \ + "call hypercall_page + %c[offset]" \ + : "=a" (__res), "=b" (__ign1), "=c" (__ign2), "=d" (__ign3) \ + : [offset] "i" (__HYPERVISOR_##name * 32), \ + "1" ((long)(a1)), "2" ((long)(a2)), "3" ((long)(a3)) \ + : "memory" ); \ + (type)__res; \ + }) + #endif /* XTF_X86_32_HYPERCALL_H */ /* diff --git a/include/arch/x86/x86_64/hypercall-x86_64.h b/include/arch/x86/x86_64/hypercall-x86_64.h index 916dd42..3982a9b 100644 --- a/include/arch/x86/x86_64/hypercall-x86_64.h +++ b/include/arch/x86/x86_64/hypercall-x86_64.h @@ -19,6 +19,18 @@ (type)__res; \ }) +#define _hypercall64_3(type, name, a1, a2, a3) \ + ({ \ + long __res, __ign1, __ign2, __ign3; \ + asm volatile ( \ + "call hypercall_page + %c[offset]" \ + : "=a" (__res), "=D" (__ign1), "=S" (__ign2), "=d" (__ign3) \ + : [offset] "i" (__HYPERVISOR_##name * 32), \ + "1" ((long)(a1)), "2" ((long)(a2)), "3" ((long)(a3)) \ + : "memory" ); \ + (type)__res; \ + }) + #endif /* XTF_X86_64_HYPERCALL_H */ /* diff --git a/include/xen/xen.h b/include/xen/xen.h index 305c47e..e311a6e 100644 --- a/include/xen/xen.h +++ b/include/xen/xen.h @@ -11,8 +11,12 @@ #error Bad architecture #endif +#define __HYPERVISOR_console_io 18 #define __HYPERVISOR_sched_op 29 +/* Commands to HYPERVISOR_console_io */ +#define CONSOLEIO_write 0 + #ifndef __ASSEMBLY__ struct start_info { /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */ diff --git a/include/xtf/hypercall.h b/include/xtf/hypercall.h index c6f8ec0..3dca881 100644 --- a/include/xtf/hypercall.h +++ b/include/xtf/hypercall.h @@ -7,11 +7,13 @@ # include # define HYPERCALL2 _hypercall64_2 +# define HYPERCALL3 _hypercall64_3 #elif defined(__i386__) # include # define HYPERCALL2 _hypercall32_2 +# define HYPERCALL3 _hypercall32_3 #else # error Bad architecture for hypercalls @@ -32,6 +34,11 @@ static inline long hypercall_sched_op(unsigned int cmd, void *arg) /* * Higher level hypercall helpers */ +static inline void hypercall_console_write(const char *buf, unsigned long count) +{ + (void)HYPERCALL3(long, console_io, CONSOLEIO_write, count, buf); +} + static inline long hypercall_shutdown(unsigned int reason) { return hypercall_sched_op(SCHEDOP_shutdown, &reason);