]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/commitdiff
Write to the hypervisor console
authorAndrew Cooper <andrew.cooper3@citrix.com>
Sun, 29 Mar 2015 18:17:05 +0000 (19:17 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 28 Sep 2015 13:53:02 +0000 (14:53 +0100)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/hypercall_page.S
arch/x86/setup.c
common/console.c
include/arch/x86/x86_32/hypercall-x86_32.h
include/arch/x86/x86_64/hypercall-x86_64.h
include/xen/xen.h
include/xtf/hypercall.h

index 4e8ed7324071a5f5e5b2d2c1994c703f12214dcf..725cfb2f4ce53a55ccacbfe7dd81b9cf9b4247bb 100644 (file)
@@ -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)
index 2a2451dcb0e03969e26f15ca3f57fe10e9c27f2c..09669b7c8a1c60621ee45ea7f479e682c6cb7a95 100644 (file)
@@ -1,17 +1,22 @@
 #include <xtf/types.h>
+#include <xtf/console.h>
+#include <xtf/hypercall.h>
 
 #include <arch/x86/config.h>
 
-#include <xen/xen.h>
-
 #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);
 }
 
 /*
index 0f907fef3a00eb5a526a2af6098fc2bd8bc23f3e..da68dbadd9ea8bef57a33c55e74db9a3ea588161 100644 (file)
@@ -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;
index 0394cd94766f8853892a4db7dd32cb7c8fcc2678..b31ef4a5f1703f29d6f840a0242317ab4f1b0ebd 100644 (file)
         (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 */
 
 /*
index 916dd421792408a1902bafe7b3990b4788e819c9..3982a9be60bcd0c798f715eaab07eaaea513dd98 100644 (file)
         (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 */
 
 /*
index 305c47eeaa66864f53630dd22eb8787ca384440b..e311a6eaab6ec2950ba7be25e6a280825d05c825 100644 (file)
 #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.    */
index c6f8ec028f759f4a31ac64e271baa8d311fc20ad..3dca881528e2abc53b5d7eaafdd7ed19a64766f8 100644 (file)
@@ -7,11 +7,13 @@
 
 # include <arch/x86/x86_64/hypercall-x86_64.h>
 # define HYPERCALL2 _hypercall64_2
+# define HYPERCALL3 _hypercall64_3
 
 #elif defined(__i386__)
 
 # include <arch/x86/x86_32/hypercall-x86_32.h>
 # 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);