@@ -33,9 +33,9 @@
#include <xen/pv_console.h>
#include <asm/setup.h>
#include <xen/sections.h>
+#include <xen/consoled.h>
#ifdef CONFIG_X86
-#include <xen/consoled.h>
#include <asm/guest.h>
#endif
#ifdef CONFIG_SBSA_VUART_CONSOLE
@@ -505,11 +505,9 @@ static void console_find_owner(void)
break;
}
-#ifdef CONFIG_PV_SHIM
- if ( next_rx == 1 )
+ if ( consoled_is_enabled() && next_rx == 1 )
domid = get_initial_domain_id();
else
-#endif
domid = next_rx - 1;
d = rcu_lock_domain_by_id(domid);
if ( d )
@@ -573,10 +571,8 @@ static void __serial_rx(char c)
#endif
}
-#ifdef CONFIG_X86
- if ( pv_shim && pv_console )
+ if ( consoled_is_enabled() )
consoled_guest_tx(c);
-#endif
}
static void cf_check serial_rx(char c)
@@ -43,13 +43,13 @@ struct xencons_interface *consoled_get_ring_addr(void)
static char buf[BUF_SZ + 1];
/* Receives characters from a domain's PV console */
-void consoled_guest_rx(void)
+int consoled_guest_rx(void)
{
size_t idx = 0;
XENCONS_RING_IDX cons, prod;
if ( !cons_ring )
- return;
+ return 0;
spin_lock(&rx_lock);
@@ -91,15 +91,17 @@ void consoled_guest_rx(void)
out:
spin_unlock(&rx_lock);
+
+ return 0;
}
/* Sends a character into a domain's PV console */
-void consoled_guest_tx(char c)
+int consoled_guest_tx(char c)
{
XENCONS_RING_IDX cons, prod;
if ( !cons_ring )
- return;
+ return 0;
cons = ACCESS_ONCE(cons_ring->in_cons);
prod = cons_ring->in_prod;
@@ -118,6 +120,7 @@ void consoled_guest_tx(char c)
cons_ring->in[MASK_XENCONS_IDX(prod++, cons_ring->in)] = c;
+
/* Write to the ring before updating the pointer */
smp_wmb();
ACCESS_ONCE(cons_ring->in_prod) = prod;
@@ -125,6 +128,13 @@ void consoled_guest_tx(char c)
notify:
/* Always notify the guest: prevents receive path from getting stuck. */
pv_shim_inject_evtchn(pv_console_evtchn());
+
+ return 0;
+}
+
+bool consoled_is_enabled(void)
+{
+ return pv_shim && pv_console;
}
/*
@@ -3,10 +3,41 @@
#include <public/io/console.h>
+#if defined(CONFIG_PV_SHIM)
+
void consoled_set_ring_addr(struct xencons_interface *ring);
struct xencons_interface *consoled_get_ring_addr(void);
-void consoled_guest_rx(void);
-void consoled_guest_tx(char c);
+int consoled_guest_rx(void);
+int consoled_guest_tx(char c);
+bool consoled_is_enabled(void);
+
+#else
+
+void consoled_set_ring_addr(struct xencons_interface *ring)
+{
+}
+
+struct xencons_interface *consoled_get_ring_addr(void)
+{
+ return NULL;
+}
+
+int consoled_guest_rx(void)
+{
+ return 0;
+}
+
+int consoled_guest_tx(char c)
+{
+ return 0;
+}
+
+bool consoled_is_enabled(void)
+{
+ return false;
+}
+
+#endif /* #if defined(CONFIG_PV_SHIM) */
#endif /* __XEN_CONSOLED_H__ */
/*