From bf589111ffc708a39bf7765228c4655d25b28515 Mon Sep 17 00:00:00 2001
From: Roger Pau Monne <roger.pau@citrix.com>
Date: Thu, 19 Jun 2014 13:05:55 +0200
Subject: [PATCH v5 08/29] xen: Dom0 console fixes and workarounds

Minor fixes and workarounds to make the Xen Dom0 console work.

Approved by: xxx
Sponsored by: Citrix Systems R&D

dev/xen/console/xencons_ring.c:
 - Always return true in xencons_has_input for Dom0.
 - Implement Dom0 console support for xencons_handle_input.
---
 sys/dev/xen/console/xencons_ring.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/sys/dev/xen/console/xencons_ring.c b/sys/dev/xen/console/xencons_ring.c
index 42b9abe..3c6487e 100644
--- a/sys/dev/xen/console/xencons_ring.c
+++ b/sys/dev/xen/console/xencons_ring.c
@@ -48,6 +48,9 @@ xencons_has_input(void)
 {
 	struct xencons_interface *intf; 
 
+	if (xen_initial_domain())
+		return 1;
+
 	intf = xencons_interface();		
 
 	return (intf->in_cons != intf->in_prod);
@@ -98,6 +101,20 @@ xencons_handle_input(void *unused)
 	XENCONS_RING_IDX cons, prod;
 
 	CN_LOCK(cn_mtx);
+
+	if (xen_initial_domain()) {
+		/* XXX: read from console */
+		static char rbuf[16];
+		int         l;
+
+		while ((l = HYPERVISOR_console_io(CONSOLEIO_read, 16, rbuf))
+		    > 0)
+			xencons_rx(rbuf, l);
+
+		CN_UNLOCK(cn_mtx);
+		return;
+	}
+
 	intf = xencons_interface();
 
 	cons = intf->in_cons;
-- 
1.7.7.5 (Apple Git-26)

