]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
poll console github/console
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 4 Jul 2017 09:05:37 +0000 (09:05 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 10 Jul 2017 13:13:10 +0000 (14:13 +0100)
common/console.c
include/xtf/hypercall.h
include/xtf/types.h

index c008a4bd6a6425141b49aaeaef022e4aeaaaf238..5b4305e5fbd0d4f4fb13d617ab20c9b6cf7a3635 100644 (file)
@@ -1,9 +1,11 @@
 #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.
@@ -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);
index 63c16f3ec1ac90e3dd9b7d6e384f68fc81d21ae0..17e9636560771e12768797e0b59d59ebb976eba8 100644 (file)
@@ -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);
index 4b827c2df8a826956f4e3a0e6e9ddf431fbbfd7f..a2ab15e4ade81ae3273e9ab01e4409cea194002b 100644 (file)
@@ -13,6 +13,7 @@
 #include <stdarg.h>
 #include <stddef.h>
 #include <inttypes.h>
+#include <limits.h>
 
 /**
  * An array which the linker resolves to 0.