#include <xtf/types.h>
#include <xtf/atomic.h>
+#include <xtf/bitops.h>
#include <xtf/console.h>
#include <xtf/hypercall.h>
#include <xtf/lib.h>
#include <xtf/libc.h>
+#include <xtf/traps.h>
/*
* Output functions, registered if/when available.
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);
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);