1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) 2004 Hollis Blanchard, IBM Corporation
5 * Copyright (C) 2004 IBM Corporation
7 * Additional Author(s):
8 * Ryan S. Arnold <rsa@us.ibm.com>
10 * LPAR console support.
13 #include <linux/kernel.h>
14 #include <linux/export.h>
15 #include <linux/errno.h>
16 #include <asm/hvcall.h>
17 #include <asm/hvconsole.h>
18 #include <asm/plpar_wrappers.h>
21 * hvc_get_chars - retrieve characters from firmware for denoted vterm adapter
22 * @vtermno: The vtermno or unit_address of the adapter from which to fetch the
24 * @buf: The character buffer into which to put the character data fetched from
28 int hvc_get_chars(uint32_t vtermno
, char *buf
, int count
)
31 unsigned long retbuf
[PLPAR_HCALL_BUFSIZE
];
32 unsigned long *lbuf
= (unsigned long *)buf
;
34 ret
= plpar_hcall(H_GET_TERM_CHAR
, retbuf
, vtermno
);
35 lbuf
[0] = be64_to_cpu(retbuf
[1]);
36 lbuf
[1] = be64_to_cpu(retbuf
[2]);
44 EXPORT_SYMBOL(hvc_get_chars
);
48 * hvc_put_chars: send characters to firmware for denoted vterm adapter
49 * @vtermno: The vtermno or unit_address of the adapter from which the data
51 * @buf: The character buffer that contains the character data to send to
52 * firmware. Must be at least 16 bytes, even if count is less than 16.
53 * @count: Send this number of characters.
55 int hvc_put_chars(uint32_t vtermno
, const char *buf
, int count
)
57 unsigned long *lbuf
= (unsigned long *) buf
;
61 /* hcall will ret H_PARAMETER if 'count' exceeds firmware max.*/
62 if (count
> MAX_VIO_PUT_CHARS
)
63 count
= MAX_VIO_PUT_CHARS
;
65 ret
= plpar_hcall_norets(H_PUT_TERM_CHAR
, vtermno
, count
,
67 cpu_to_be64(lbuf
[1]));
75 EXPORT_SYMBOL(hvc_put_chars
);