Path: blob/master/arch/powerpc/platforms/pseries/hvconsole.c
26481 views
// SPDX-License-Identifier: GPL-2.0-or-later1/*2* hvconsole.c3* Copyright (C) 2004 Hollis Blanchard, IBM Corporation4* Copyright (C) 2004 IBM Corporation5*6* Additional Author(s):7* Ryan S. Arnold <[email protected]>8*9* LPAR console support.10*/1112#include <linux/kernel.h>13#include <linux/export.h>14#include <linux/errno.h>15#include <asm/hvcall.h>16#include <asm/hvconsole.h>17#include <asm/plpar_wrappers.h>1819/**20* hvc_get_chars - retrieve characters from firmware for denoted vterm adapter21* @vtermno: The vtermno or unit_address of the adapter from which to fetch the22* data.23* @buf: The character buffer into which to put the character data fetched from24* firmware.25* @count: not used?26*/27ssize_t hvc_get_chars(uint32_t vtermno, u8 *buf, size_t count)28{29long ret;30unsigned long retbuf[PLPAR_HCALL_BUFSIZE];31unsigned long *lbuf = (unsigned long *)buf;3233ret = plpar_hcall(H_GET_TERM_CHAR, retbuf, vtermno);34lbuf[0] = be64_to_cpu(retbuf[1]);35lbuf[1] = be64_to_cpu(retbuf[2]);3637if (ret == H_SUCCESS)38return retbuf[0];3940return 0;41}4243EXPORT_SYMBOL(hvc_get_chars);444546/**47* hvc_put_chars: send characters to firmware for denoted vterm adapter48* @vtermno: The vtermno or unit_address of the adapter from which the data49* originated.50* @buf: The character buffer that contains the character data to send to51* firmware. Must be at least 16 bytes, even if count is less than 16.52* @count: Send this number of characters.53*/54ssize_t hvc_put_chars(uint32_t vtermno, const u8 *buf, size_t count)55{56unsigned long *lbuf = (unsigned long *) buf;57long ret;585960/* hcall will ret H_PARAMETER if 'count' exceeds firmware max.*/61if (count > MAX_VIO_PUT_CHARS)62count = MAX_VIO_PUT_CHARS;6364ret = plpar_hcall_norets(H_PUT_TERM_CHAR, vtermno, count,65cpu_to_be64(lbuf[0]),66cpu_to_be64(lbuf[1]));67if (ret == H_SUCCESS)68return count;69if (ret == H_BUSY)70return -EAGAIN;71return -EIO;72}7374EXPORT_SYMBOL(hvc_put_chars);757677