3 * Copyright (C) 2004 Hollis Blanchard, IBM Corporation
5 * LPAR console support.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <asm/hvcall.h>
26 #include <asm/hvconsole.h>
28 int hvc_get_chars(int index, char *buf, int count)
32 if (plpar_hcall(H_GET_TERM_CHAR, index, 0, 0, 0, &got,
33 (unsigned long *)buf, (unsigned long *)buf+1) == H_Success) {
35 * Work around a HV bug where it gives us a null
36 * after every \r. -- paulus
40 for (i = 1; i < got; ++i) {
41 if (buf[i] == 0 && buf[i-1] == '\r') {
44 memmove(&buf[i], &buf[i+1],
54 EXPORT_SYMBOL(hvc_get_chars);
56 int hvc_put_chars(int index, const char *buf, int count)
58 unsigned long *lbuf = (unsigned long *) buf;
61 ret = plpar_hcall_norets(H_PUT_TERM_CHAR, index, count, lbuf[0],
70 EXPORT_SYMBOL(hvc_put_chars);
72 /* return the number of client vterms present */
73 /* XXX this requires an interface change to handle multiple discontiguous
75 int hvc_count(int *start_termno)
77 struct device_node *vty;
80 /* consider only the first vty node.
81 * we should _always_ be able to find one. */
82 vty = of_find_node_by_name(NULL, "vty");
83 if (vty && device_is_compatible(vty, "hvterm1")) {
84 u32 *termno = (u32 *)get_property(vty, "reg", NULL);
86 if (termno && start_termno)
87 *start_termno = *termno;