Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=3f8c4d3f82c564e5e27c6375fe17544f694359dc
Commit:     3f8c4d3f82c564e5e27c6375fe17544f694359dc
Parent:     709e89266b60eff444fc512400321eb02d2474eb
Author:     Rusty Russell <[EMAIL PROTECTED]>
AuthorDate: Thu Jul 19 01:49:27 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Thu Jul 19 10:04:52 2007 -0700

    lguest: the console driver
    
    A simple console driver for lguest.
    
    Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
    Cc: Andi Kleen <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 drivers/char/Makefile     |    1 +
 drivers/char/hvc_lguest.c |  102 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 103 insertions(+), 0 deletions(-)

diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 8852b8d..4e6f387 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_SYNCLINK_GT)     += synclink_gt.o
 obj-$(CONFIG_N_HDLC)           += n_hdlc.o
 obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o
 obj-$(CONFIG_SX)               += sx.o generic_serial.o
+obj-$(CONFIG_LGUEST_GUEST)     += hvc_lguest.o
 obj-$(CONFIG_RIO)              += rio/ generic_serial.o
 obj-$(CONFIG_HVC_CONSOLE)      += hvc_vio.o hvsi.o
 obj-$(CONFIG_HVC_ISERIES)      += hvc_iseries.o
diff --git a/drivers/char/hvc_lguest.c b/drivers/char/hvc_lguest.c
new file mode 100644
index 0000000..e7b889e
--- /dev/null
+++ b/drivers/char/hvc_lguest.c
@@ -0,0 +1,102 @@
+/* Simple console for lguest.
+ *
+ * Copyright (C) 2006 Rusty Russell, IBM Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/lguest_bus.h>
+#include "hvc_console.h"
+
+static char inbuf[256];
+static struct lguest_dma cons_input = { .used_len = 0,
+                                       .addr[0] = __pa(inbuf),
+                                       .len[0] = sizeof(inbuf),
+                                       .len[1] = 0 };
+
+static int put_chars(u32 vtermno, const char *buf, int count)
+{
+       struct lguest_dma dma;
+
+       /* FIXME: what if it's over a page boundary? */
+       dma.len[0] = count;
+       dma.len[1] = 0;
+       dma.addr[0] = __pa(buf);
+
+       lguest_send_dma(LGUEST_CONSOLE_DMA_KEY, &dma);
+       return count;
+}
+
+static int get_chars(u32 vtermno, char *buf, int count)
+{
+       static int cons_offset;
+
+       if (!cons_input.used_len)
+               return 0;
+
+       if (cons_input.used_len - cons_offset < count)
+               count = cons_input.used_len - cons_offset;
+
+       memcpy(buf, inbuf + cons_offset, count);
+       cons_offset += count;
+       if (cons_offset == cons_input.used_len) {
+               cons_offset = 0;
+               cons_input.used_len = 0;
+       }
+       return count;
+}
+
+static struct hv_ops lguest_cons = {
+       .get_chars = get_chars,
+       .put_chars = put_chars,
+};
+
+static int __init cons_init(void)
+{
+       if (strcmp(paravirt_ops.name, "lguest") != 0)
+               return 0;
+
+       return hvc_instantiate(0, 0, &lguest_cons);
+}
+console_initcall(cons_init);
+
+static int lguestcons_probe(struct lguest_device *lgdev)
+{
+       int err;
+
+       lgdev->private = hvc_alloc(0, lgdev_irq(lgdev), &lguest_cons, 256);
+       if (IS_ERR(lgdev->private))
+               return PTR_ERR(lgdev->private);
+
+       err = lguest_bind_dma(LGUEST_CONSOLE_DMA_KEY, &cons_input, 1,
+                             lgdev_irq(lgdev));
+       if (err)
+               printk("lguest console: failed to bind buffer.\n");
+       return err;
+}
+
+static struct lguest_driver lguestcons_drv = {
+       .name = "lguestcons",
+       .owner = THIS_MODULE,
+       .device_type = LGUEST_DEVICE_T_CONSOLE,
+       .probe = lguestcons_probe,
+};
+
+static int __init hvc_lguest_init(void)
+{
+       return register_lguest_driver(&lguestcons_drv);
+}
+module_init(hvc_lguest_init);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to