3 * Copyright (C) 2004 Hollis Blanchard, IBM Corporation
4 * Copyright (C) 2004 IBM Corporation
6 * Additional Author(s):
7 * Ryan S. Arnold <rsa@us.ibm.com>
9 * LPAR console support.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/kernel.h>
27 #include <linux/module.h>
28 #include <asm/hvcall.h>
29 #include <asm/hvconsole.h>
33 * hvc_get_chars - retrieve characters from firmware for denoted vterm adatper
34 * @vtermno: The vtermno or unit_address of the adapter from which to fetch the
36 * @buf: The character buffer into which to put the character data fetched from
40 int hvc_get_chars(uint32_t vtermno
, char *buf
, int count
)
44 if (plpar_hcall(H_GET_TERM_CHAR
, vtermno
, 0, 0, 0, &got
,
45 (unsigned long *)buf
, (unsigned long *)buf
+1) == H_Success
) {
47 * Work around a HV bug where it gives us a null
48 * after every \r. -- paulus
52 for (i
= 1; i
< got
; ++i
) {
53 if (buf
[i
] == 0 && buf
[i
-1] == '\r') {
56 memmove(&buf
[i
], &buf
[i
+1],
66 EXPORT_SYMBOL(hvc_get_chars
);
69 * hvc_put_chars: send characters to firmware for denoted vterm adapter
70 * @vtermno: The vtermno or unit_address of the adapter from which the data
72 * @buf: The character buffer that contains the character data to send to
74 * @count: Send this number of characters.
76 int hvc_put_chars(uint32_t vtermno
, const char *buf
, int count
)
78 unsigned long *lbuf
= (unsigned long *) buf
;
81 ret
= plpar_hcall_norets(H_PUT_TERM_CHAR
, vtermno
, count
, lbuf
[0],
90 EXPORT_SYMBOL(hvc_put_chars
);
93 * We hope/assume that the first vty found corresponds to the first console
96 int hvc_find_vtys(void)
98 struct device_node
*vty
;
101 for (vty
= of_find_node_by_name(NULL
, "vty"); vty
!= NULL
;
102 vty
= of_find_node_by_name(vty
, "vty")) {
105 /* We have statically defined space for only a certain number of
106 * console adapters. */
107 if (num_found
>= MAX_NR_HVC_CONSOLES
)
110 vtermno
= (uint32_t *)get_property(vty
, "reg", NULL
);
114 if (device_is_compatible(vty
, "hvterm1")) {
115 hvc_instantiate(*vtermno
, num_found
);