From: Sergiy Kibrik <sergiy.kib...@globallogic.com>
Committer: Sergiy Kibrik <sergiy.kib...@globallogic.com>
Branch: master

osv: add Xen console basic driver

Primitive driver that uses HYPERVISOR_console_io hypercall to provide early console.

Signed-off-by: Sergiy Kibrik <sergiy.kib...@globallogic.com>

---
diff --git a/drivers/xenconsole.cc b/drivers/xenconsole.cc
--- a/drivers/xenconsole.cc
+++ b/drivers/xenconsole.cc
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2017 Sergiy Kibrik <sergiy.kib...@globallogic.com>
+ *
+ * This work is open source software, licensed under the terms of the
+ * BSD license as described in the LICENSE file in the top-level directory.
+ */
+
+#include <bsd/porting/netport.h> /* __dead2 defined here */
+#include <xen/hypervisor.h>
+
+#include "xenconsole.hh"
+
+namespace console {
+
+void XEN_Console::write(const char *str, size_t len) {
+       HYPERVISOR_console_write(str, len);
+}
+
+void XEN_Console::dev_start()
+{
+}
+
+void XEN_Console::flush()
+{
+}
+
+bool XEN_Console::input_ready()
+{
+       return false; /*TODO: support input */
+}
+
+char XEN_Console::readch() {
+    return '\0'; /*TODO: support input */
+}
+
+}
diff --git a/drivers/xenconsole.hh b/drivers/xenconsole.hh
--- a/drivers/xenconsole.hh
+++ b/drivers/xenconsole.hh
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2017 Sergiy Kibrik <sergiy.kib...@globallogic.com>
+ *
+ * This work is open source software, licensed under the terms of the
+ * BSD license as described in the LICENSE file in the top-level directory.
+ */
+
+#ifndef XEN_CONSOLE_HH
+#define XEN_CONSOLE_HH
+
+#include "console-driver.hh"
+#include "exceptions.hh"
+#include <osv/interrupt.hh>
+
+namespace console {
+
+class XEN_Console : public console_driver {
+public:
+    virtual void write(const char *str, size_t len);
+    virtual void flush();
+    virtual bool input_ready();
+    virtual char readch();
+
+private:
+    virtual void dev_start();
+    virtual const char *thread_name() { return "xen-input"; }
+};
+
+}
+
+#endif /* XEN_CONSOLE_HH */

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to