2 * Beat hypervisor console driver
4 * (C) Copyright 2006 TOSHIBA CORPORATION
6 * This code is based on drivers/char/hvc_rtas.c:
7 * (C) Copyright IBM Corporation 2001-2005
8 * (C) Copyright Red Hat, Inc. 2005
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include <linux/module.h>
26 #include <linux/init.h>
27 #include <linux/err.h>
28 #include <linux/string.h>
29 #include <linux/console.h>
31 #include <asm/hvconsole.h>
32 #include <asm/firmware.h>
34 #include "hvc_console.h"
36 extern int64_t beat_get_term_char(uint64_t, uint64_t *, uint64_t *, uint64_t *);
37 extern int64_t beat_put_term_char(uint64_t, uint64_t, uint64_t, uint64_t);
39 struct hvc_struct *hvc_beat_dev = NULL;
41 /* bug: only one queue is available regardless of vtermno */
42 static int hvc_beat_get_chars(uint32_t vtermno, char *buf, int cnt)
44 static unsigned char q[sizeof(unsigned long) * 2]
45 __attribute__((aligned(sizeof(unsigned long))));
54 memmove(q + cnt, q, qlen);
56 } else { /* qlen <= cnt */
65 if (beat_get_term_char(vtermno, &got,
66 ((unsigned long *)q), ((unsigned long *)q) + 1) == 0) {
73 static int hvc_beat_put_chars(uint32_t vtermno, const char *buf, int cnt)
78 for (rest = cnt; rest > 0; rest -= nlen) {
79 nlen = (rest > 16) ? 16 : rest;
80 memcpy(kb, buf, nlen);
81 beat_put_term_char(vtermno, rest, kb[0], kb[1]);
87 static struct hv_ops hvc_beat_get_put_ops = {
88 .get_chars = hvc_beat_get_chars,
89 .put_chars = hvc_beat_put_chars,
92 static int hvc_beat_useit = 1;
94 static int hvc_beat_config(char *p)
96 hvc_beat_useit = simple_strtoul(p, NULL, 0);
100 static int __init hvc_beat_console_init(void)
102 if (hvc_beat_useit && machine_is_compatible("Beat")) {
103 hvc_instantiate(0, 0, &hvc_beat_get_put_ops);
109 static int __init hvc_beat_init(void)
111 struct hvc_struct *hp;
113 if (!firmware_has_feature(FW_FEATURE_BEAT))
116 hp = hvc_alloc(0, NO_IRQ, &hvc_beat_get_put_ops, 16);
123 static void __exit hvc_beat_exit(void)
126 hvc_remove(hvc_beat_dev);
129 module_init(hvc_beat_init);
130 module_exit(hvc_beat_exit);
132 __setup("hvc_beat=", hvc_beat_config);
134 console_initcall(hvc_beat_console_init);