From: Andrew Cooper Date: Tue, 4 Jul 2017 09:05:37 +0000 (+0000) Subject: poll X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=refs%2Fremotes%2Fgithub%2Fconsole;p=people%2Fandrewcoop%2Fxen-test-framework.git poll --- diff --git a/common/console.c b/common/console.c index c008a4b..5b4305e 100644 --- a/common/console.c +++ b/common/console.c @@ -1,9 +1,11 @@ #include #include +#include #include #include #include #include +#include /* * Output functions, registered if/when available. @@ -67,18 +69,28 @@ static void pv_console_write(const char *buf, size_t len) if ( written < len ) { while ( ACCESS_ONCE(pv_ring->out_cons) == cons ) - hypercall_yield(); + { + if ( !test_and_clear_bit(pv_evtchn, + shared_info.evtchn_pending) ) + hypercall_poll(pv_evtchn); + } } } while ( written < len ); /* Wait for xenconsoled to consume all the data we gave. */ while ( ACCESS_ONCE(pv_ring->out_cons) != pv_ring->out_prod ) - hypercall_yield(); + { + if ( !test_and_clear_bit(pv_evtchn, shared_info.evtchn_pending) ) + hypercall_poll(pv_evtchn); + } } void init_pv_console(xencons_interface_t *ring, evtchn_port_t port) { + if ( port >= (sizeof(shared_info.evtchn_pending) * CHAR_BIT) ) + panic("evtchn %u out of evtchn_pending[] range\n", port); + pv_ring = ring; pv_evtchn = port; register_console_callback(pv_console_write); diff --git a/include/xtf/hypercall.h b/include/xtf/hypercall.h index 63c16f3..17e9636 100644 --- a/include/xtf/hypercall.h +++ b/include/xtf/hypercall.h @@ -149,6 +149,13 @@ static inline void hypercall_yield(void) hypercall_sched_op(SCHEDOP_yield, NULL); } +static inline long hypercall_poll(evtchn_port_t port) +{ + struct sched_poll poll = { .ports = &port, .nr_ports = 1 }; + + return hypercall_sched_op(SCHEDOP_poll, &poll); +} + static inline int hypercall_register_callback(const xen_callback_register_t *arg) { return hypercall_callback_op(CALLBACKOP_register, arg); diff --git a/include/xtf/types.h b/include/xtf/types.h index 4b827c2..a2ab15e 100644 --- a/include/xtf/types.h +++ b/include/xtf/types.h @@ -13,6 +13,7 @@ #include #include #include +#include /** * An array which the linker resolves to 0.