diff --git a/sys/dev/xen/console/xen_console.c b/sys/dev/xen/console/xen_console.c --- a/sys/dev/xen/console/xen_console.c +++ b/sys/dev/xen/console/xen_console.c @@ -138,6 +138,13 @@ size_t n_next; }; +void __weak_symbol +xen_emergency_print(const char *str, size_t size) +{ + KASSERT((xen_domain()), ("call to xc_printf from non Xen guest")); + HYPERVISOR_console_write(str, size); +} + static void putchar(int c, void *arg) { @@ -150,12 +157,12 @@ * We have no buffer, output directly to the * console char by char. */ - HYPERVISOR_console_write((char *)&c, 1); + xen_emergency_print((char *)&c, 1); } else { pca->buf[pca->n_next++] = c; if ((pca->size == pca->n_next) || (c = '\0')) { /* Flush the buffer */ - HYPERVISOR_console_write(pca->buf, pca->n_next); + xen_emergency_print(pca->buf, pca->n_next); pca->n_next = 0; } } @@ -177,15 +184,13 @@ pca.size = 0; #endif - KASSERT((xen_domain()), ("call to xc_printf from non Xen guest")); - va_start(ap, fmt); kvprintf(fmt, putchar, &pca, 10, ap); va_end(ap); #ifdef PRINTF_BUFR_SIZE if (pca.n_next != 0) - HYPERVISOR_console_write(buf, pca.n_next); + xen_emergency_print(buf, pca.n_next); #endif } diff --git a/sys/x86/xen/hvm.c b/sys/x86/xen/hvm.c --- a/sys/x86/xen/hvm.c +++ b/sys/x86/xen/hvm.c @@ -95,6 +95,11 @@ /*---------------------- XEN Hypervisor Probe and Setup ----------------------*/ +void xen_emergency_print(const char *str, size_t size) +{ + outsb(XEN_HVM_DEBUGCONS_IOPORT, str, size); +} + uint32_t xen_cpuid_base; static uint32_t diff --git a/sys/xen/xen-os.h b/sys/xen/xen-os.h --- a/sys/xen/xen-os.h +++ b/sys/xen/xen-os.h @@ -151,6 +151,13 @@ /* Debug/emergency function, prints directly to hypervisor console */ void xc_printf(const char *, ...) __printflike(1, 2); +/* + * Emergency print function, can be defined per-arch, otherwise defaults to + * HYPERVISOR_console_write. Should not be called directly, use xc_printf + * instead. + */ +void xen_emergency_print(const char *str, size_t size); + #ifndef xen_mb #define xen_mb() mb() #endif