f32fcbedbe
Switch character types to u8 and sizes to size_t. To conform to characters/sizes in the rest of the tty layer. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: Amit Shah <amit@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: linuxppc-dev@lists.ozlabs.org Cc: virtualization@lists.linux.dev Cc: linux-riscv@lists.infradead.org Link: https://lore.kernel.org/r/20231206073712.17776-13-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
76 lines
1.9 KiB
C
76 lines
1.9 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* hvconsole.c
|
|
* Copyright (C) 2004 Hollis Blanchard, IBM Corporation
|
|
* Copyright (C) 2004 IBM Corporation
|
|
*
|
|
* Additional Author(s):
|
|
* Ryan S. Arnold <rsa@us.ibm.com>
|
|
*
|
|
* LPAR console support.
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/export.h>
|
|
#include <linux/errno.h>
|
|
#include <asm/hvcall.h>
|
|
#include <asm/hvconsole.h>
|
|
#include <asm/plpar_wrappers.h>
|
|
|
|
/**
|
|
* hvc_get_chars - retrieve characters from firmware for denoted vterm adapter
|
|
* @vtermno: The vtermno or unit_address of the adapter from which to fetch the
|
|
* data.
|
|
* @buf: The character buffer into which to put the character data fetched from
|
|
* firmware.
|
|
* @count: not used?
|
|
*/
|
|
ssize_t hvc_get_chars(uint32_t vtermno, u8 *buf, size_t count)
|
|
{
|
|
long ret;
|
|
unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
|
|
unsigned long *lbuf = (unsigned long *)buf;
|
|
|
|
ret = plpar_hcall(H_GET_TERM_CHAR, retbuf, vtermno);
|
|
lbuf[0] = be64_to_cpu(retbuf[1]);
|
|
lbuf[1] = be64_to_cpu(retbuf[2]);
|
|
|
|
if (ret == H_SUCCESS)
|
|
return retbuf[0];
|
|
|
|
return 0;
|
|
}
|
|
|
|
EXPORT_SYMBOL(hvc_get_chars);
|
|
|
|
|
|
/**
|
|
* hvc_put_chars: send characters to firmware for denoted vterm adapter
|
|
* @vtermno: The vtermno or unit_address of the adapter from which the data
|
|
* originated.
|
|
* @buf: The character buffer that contains the character data to send to
|
|
* firmware. Must be at least 16 bytes, even if count is less than 16.
|
|
* @count: Send this number of characters.
|
|
*/
|
|
ssize_t hvc_put_chars(uint32_t vtermno, const u8 *buf, size_t count)
|
|
{
|
|
unsigned long *lbuf = (unsigned long *) buf;
|
|
long ret;
|
|
|
|
|
|
/* hcall will ret H_PARAMETER if 'count' exceeds firmware max.*/
|
|
if (count > MAX_VIO_PUT_CHARS)
|
|
count = MAX_VIO_PUT_CHARS;
|
|
|
|
ret = plpar_hcall_norets(H_PUT_TERM_CHAR, vtermno, count,
|
|
cpu_to_be64(lbuf[0]),
|
|
cpu_to_be64(lbuf[1]));
|
|
if (ret == H_SUCCESS)
|
|
return count;
|
|
if (ret == H_BUSY)
|
|
return -EAGAIN;
|
|
return -EIO;
|
|
}
|
|
|
|
EXPORT_SYMBOL(hvc_put_chars);
|