Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx> Index: kvm-unit-tests/lib/x86/io.c =================================================================== --- kvm-unit-tests.orig/lib/x86/io.c +++ kvm-unit-tests/lib/x86/io.c @@ -2,6 +2,7 @@ #include "smp.h" static struct spinlock lock; +static struct spinlock mon_lock; static void print_serial(const char *buf) { @@ -17,6 +18,20 @@ void puts(const char *s) spin_unlock(&lock); } +static void print_monitor(const char *buf) +{ + unsigned long len = strlen(buf); + + asm volatile ("rep/outsb" : "+S"(buf), "+c"(len) : "d"(0xf2)); +} + +void puts_monitor(const char *s) +{ + spin_lock(&mon_lock); + print_monitor(s); + spin_unlock(&mon_lock); +} + void exit(int code) { asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4)); Index: kvm-unit-tests/lib/libcflat.h =================================================================== --- kvm-unit-tests.orig/lib/libcflat.h +++ kvm-unit-tests/lib/libcflat.h @@ -45,8 +45,10 @@ extern char *strcat(char *dest, const ch extern int printf(const char *fmt, ...); extern int vsnprintf(char *buf, int size, const char *fmt, va_list va); +extern int monitor_printf(const char *fmt, ...); extern void puts(const char *s); +extern void puts_monitor(const char *s); extern void *memset(void *s, int c, size_t n); Index: kvm-unit-tests/lib/printf.c =================================================================== --- kvm-unit-tests.orig/lib/printf.c +++ kvm-unit-tests/lib/printf.c @@ -177,3 +177,16 @@ int printf(const char *fmt, ...) puts(buf); return r; } + +int monitor_printf(const char *fmt, ...) +{ + va_list va; + char buf[2000]; + int r; + + va_start(va, fmt); + r = vsnprintf(buf, sizeof buf, fmt, va); + va_end(va); + puts_monitor(buf); + return r; +} -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html