diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2008-11-05 09:20:17 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-11-19 00:04:25 -0500 |
commit | d5e54913433fff89609adfc4b96fefcf807a9030 (patch) | |
tree | 6ab66827c98837a86a2b4f0e77732c43238db5a0 /drivers/char | |
parent | 8c6531868d4917adbd363030f28a734b76c7471a (diff) |
powerpc: udbg-based backend for hvc_console
This adds a new backend for the hvc console based on the low-level
udbg callbacks. This effectively implements a working runtime console
in terms of the simple udbg primitives. This is kind of a hack -
since udbg isn't something you really want to be using routinely - but
it's really useful during bringup.
This can be used to quickly implement a userspace-usable console while
you're working on a proper driver for whatever console I/O device the
hardware has. Or, it can be used to avoid writing a full blown
tty/console driver entirely for quick-and-dirty I/O hardware that will
later be replaced by something else.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/Kconfig | 6 | ||||
-rw-r--r-- | drivers/char/Makefile | 1 | ||||
-rw-r--r-- | drivers/char/hvc_udbg.c | 96 |
3 files changed, 103 insertions, 0 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 43b35d0369d6..19e255c49f15 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -631,6 +631,12 @@ config HVC_XEN | |||
631 | help | 631 | help |
632 | Xen virtual console device driver | 632 | Xen virtual console device driver |
633 | 633 | ||
634 | config HVC_UDBG | ||
635 | bool "udbg based fake hypervisor console" | ||
636 | depends on PPC && EXPERIMENTAL | ||
637 | select HVC_DRIVER | ||
638 | default n | ||
639 | |||
634 | config VIRTIO_CONSOLE | 640 | config VIRTIO_CONSOLE |
635 | tristate "Virtio console" | 641 | tristate "Virtio console" |
636 | depends on VIRTIO | 642 | depends on VIRTIO |
diff --git a/drivers/char/Makefile b/drivers/char/Makefile index 438f71317c5c..52e15524af39 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile | |||
@@ -50,6 +50,7 @@ obj-$(CONFIG_HVC_BEAT) += hvc_beat.o | |||
50 | obj-$(CONFIG_HVC_DRIVER) += hvc_console.o | 50 | obj-$(CONFIG_HVC_DRIVER) += hvc_console.o |
51 | obj-$(CONFIG_HVC_IRQ) += hvc_irq.o | 51 | obj-$(CONFIG_HVC_IRQ) += hvc_irq.o |
52 | obj-$(CONFIG_HVC_XEN) += hvc_xen.o | 52 | obj-$(CONFIG_HVC_XEN) += hvc_xen.o |
53 | obj-$(CONFIG_HVC_UDBG) += hvc_udbg.o | ||
53 | obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o | 54 | obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o |
54 | obj-$(CONFIG_RAW_DRIVER) += raw.o | 55 | obj-$(CONFIG_RAW_DRIVER) += raw.o |
55 | obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o | 56 | obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o |
diff --git a/drivers/char/hvc_udbg.c b/drivers/char/hvc_udbg.c new file mode 100644 index 000000000000..bd63ba878a56 --- /dev/null +++ b/drivers/char/hvc_udbg.c | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | * udbg interface to hvc_console.c | ||
3 | * | ||
4 | * (C) Copyright David Gibson, IBM Corporation 2008. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <linux/console.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include <linux/err.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/moduleparam.h> | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/irq.h> | ||
28 | |||
29 | #include <asm/udbg.h> | ||
30 | |||
31 | #include "hvc_console.h" | ||
32 | |||
33 | struct hvc_struct *hvc_udbg_dev; | ||
34 | |||
35 | static int hvc_udbg_put(uint32_t vtermno, const char *buf, int count) | ||
36 | { | ||
37 | int i; | ||
38 | |||
39 | for (i = 0; i < count; i++) | ||
40 | udbg_putc(buf[i]); | ||
41 | |||
42 | return i; | ||
43 | } | ||
44 | |||
45 | static int hvc_udbg_get(uint32_t vtermno, char *buf, int count) | ||
46 | { | ||
47 | int i, c; | ||
48 | |||
49 | if (!udbg_getc_poll) | ||
50 | return 0; | ||
51 | |||
52 | for (i = 0; i < count; i++) { | ||
53 | if ((c = udbg_getc_poll()) == -1) | ||
54 | break; | ||
55 | buf[i] = c; | ||
56 | } | ||
57 | |||
58 | return i; | ||
59 | } | ||
60 | |||
61 | static struct hv_ops hvc_udbg_ops = { | ||
62 | .get_chars = hvc_udbg_get, | ||
63 | .put_chars = hvc_udbg_put, | ||
64 | }; | ||
65 | |||
66 | static int __init hvc_udbg_init(void) | ||
67 | { | ||
68 | struct hvc_struct *hp; | ||
69 | |||
70 | BUG_ON(hvc_udbg_dev); | ||
71 | |||
72 | hp = hvc_alloc(0, NO_IRQ, &hvc_udbg_ops, 16); | ||
73 | if (IS_ERR(hp)) | ||
74 | return PTR_ERR(hp); | ||
75 | |||
76 | hvc_udbg_dev = hp; | ||
77 | |||
78 | return 0; | ||
79 | } | ||
80 | module_init(hvc_udbg_init); | ||
81 | |||
82 | static void __exit hvc_udbg_exit(void) | ||
83 | { | ||
84 | if (hvc_udbg_dev) | ||
85 | hvc_remove(hvc_udbg_dev); | ||
86 | } | ||
87 | module_exit(hvc_udbg_exit); | ||
88 | |||
89 | static int __init hvc_udbg_console_init(void) | ||
90 | { | ||
91 | hvc_instantiate(0, 0, &hvc_udbg_ops); | ||
92 | add_preferred_console("hvc", 0, NULL); | ||
93 | |||
94 | return 0; | ||
95 | } | ||
96 | console_initcall(hvc_udbg_console_init); | ||