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 <asm/hvcall.h>
25 #include <asm/hvconsole.h>
27 int hvc_get_chars(int index, char *buf, int count)
31 if (plpar_hcall(H_GET_TERM_CHAR, index, 0, 0, 0, &got,
32 (unsigned long *)buf, (unsigned long *)buf+1) == H_Success) {
34 * Work around a HV bug where it gives us a null
35 * after every \r. -- paulus
39 for (i = 1; i < got; ++i) {
40 if (buf[i] == 0 && buf[i-1] == '\r') {
43 memmove(&buf[i], &buf[i+1],
53 int hvc_put_chars(int index, const char *buf, int count)
55 unsigned long *lbuf = (unsigned long *) buf;
58 ret = plpar_hcall_norets(H_PUT_TERM_CHAR, index, count, lbuf[0],
67 /* return the number of client vterms present */
68 /* XXX this requires an interface change to handle multiple discontiguous
70 int hvc_count(int *start_termno)
72 struct device_node *vty;
75 /* consider only the first vty node.
76 * we should _always_ be able to find one. */
77 vty = of_find_node_by_name(NULL, "vty");
78 if (vty && device_is_compatible(vty, "hvterm1")) {
79 u32 *termno = (u32 *)get_property(vty, "reg", 0);
81 if (termno && start_termno)
82 *start_termno = *termno;