aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/console
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-06-03 09:32:50 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-06-03 09:32:50 +0100
commite49b738ccfb422db6bbf5abb39aa6975bef8d32a (patch)
treeccba8bfd259c7a2d2677013df0dc6e077d90508e /extras/mini-os/console
parent9efd150651fe690e2bc4e5675209c75adedd823c (diff)
downloadxen-e49b738ccfb422db6bbf5abb39aa6975bef8d32a.tar.gz
xen-e49b738ccfb422db6bbf5abb39aa6975bef8d32a.tar.bz2
xen-e49b738ccfb422db6bbf5abb39aa6975bef8d32a.zip
stubdom: Add console reading support
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Diffstat (limited to 'extras/mini-os/console')
-rw-r--r--extras/mini-os/console/console.c7
-rw-r--r--extras/mini-os/console/xencons_ring.c44
2 files changed, 46 insertions, 5 deletions
diff --git a/extras/mini-os/console/console.c b/extras/mini-os/console/console.c
index 29fdd99f3b..94379ddb33 100644
--- a/extras/mini-os/console/console.c
+++ b/extras/mini-os/console/console.c
@@ -49,17 +49,13 @@
of standard dom0 handled console */
#define USE_XEN_CONSOLE
-/* Low level functions defined in xencons_ring.c */
-extern int xencons_ring_init(void);
-extern int xencons_ring_send(const char *data, unsigned len);
-extern int xencons_ring_send_no_notify(const char *data, unsigned len);
-
/* If console not initialised the printk will be sent to xen serial line
NOTE: you need to enable verbose in xen/Rules.mk for it to work. */
static int console_initialised = 0;
+#ifndef HAVE_LIBC
void xencons_rx(char *buf, unsigned len, struct pt_regs *regs)
{
if(len > 0)
@@ -77,6 +73,7 @@ void xencons_tx(void)
{
/* Do nothing, handled by _rx */
}
+#endif
void console_print(char *data, int length)
diff --git a/extras/mini-os/console/xencons_ring.c b/extras/mini-os/console/xencons_ring.c
index 583e4bcb92..251a4f95f1 100644
--- a/extras/mini-os/console/xencons_ring.c
+++ b/extras/mini-os/console/xencons_ring.c
@@ -8,6 +8,7 @@
#include <xenbus.h>
#include <xen/io/console.h>
+DECLARE_WAIT_QUEUE_HEAD(console_queue);
static inline struct xencons_interface *xencons_interface(void)
{
@@ -52,6 +53,9 @@ int xencons_ring_send(const char *data, unsigned len)
static void handle_input(evtchn_port_t port, struct pt_regs *regs, void *ign)
{
+#ifdef HAVE_LIBC
+ wake_up(&console_queue);
+#else
struct xencons_interface *intf = xencons_interface();
XENCONS_RING_IDX cons, prod;
@@ -71,8 +75,48 @@ static void handle_input(evtchn_port_t port, struct pt_regs *regs, void *ign)
notify_daemon();
xencons_tx();
+#endif
}
+#ifdef HAVE_LIBC
+int xencons_ring_avail(void)
+{
+ struct xencons_interface *intf = xencons_interface();
+ XENCONS_RING_IDX cons, prod;
+
+ cons = intf->in_cons;
+ prod = intf->in_prod;
+ mb();
+ BUG_ON((prod - cons) > sizeof(intf->in));
+
+ return prod - cons;
+}
+
+int xencons_ring_recv(char *data, unsigned len)
+{
+ struct xencons_interface *intf = xencons_interface();
+ XENCONS_RING_IDX cons, prod;
+ unsigned filled = 0;
+
+ cons = intf->in_cons;
+ prod = intf->in_prod;
+ mb();
+ BUG_ON((prod - cons) > sizeof(intf->in));
+
+ while (filled < len && cons + filled != prod) {
+ data[filled] = *(intf->in + MASK_XENCONS_IDX(cons + filled, intf->in));
+ filled++;
+ }
+
+ mb();
+ intf->in_cons = cons + filled;
+
+ notify_daemon();
+
+ return filled;
+}
+#endif
+
int xencons_ring_init(void)
{
int err;