Path: blob/master/arch/powerpc/platforms/pseries/hvconsole.c
10818 views
/*1* hvconsole.c2* Copyright (C) 2004 Hollis Blanchard, IBM Corporation3* Copyright (C) 2004 IBM Corporation4*5* Additional Author(s):6* Ryan S. Arnold <[email protected]>7*8* LPAR console support.9*10* This program is free software; you can redistribute it and/or modify11* it under the terms of the GNU General Public License as published by12* the Free Software Foundation; either version 2 of the License, or13* (at your option) any later version.14*15* This program is distributed in the hope that it will be useful,16* but WITHOUT ANY WARRANTY; without even the implied warranty of17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the18* GNU General Public License for more details.19*20* You should have received a copy of the GNU General Public License21* along with this program; if not, write to the Free Software22* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA23*/2425#include <linux/kernel.h>26#include <linux/module.h>27#include <asm/hvcall.h>28#include <asm/hvconsole.h>29#include "plpar_wrappers.h"3031/**32* hvc_get_chars - retrieve characters from firmware for denoted vterm adatper33* @vtermno: The vtermno or unit_address of the adapter from which to fetch the34* data.35* @buf: The character buffer into which to put the character data fetched from36* firmware.37* @count: not used?38*/39int hvc_get_chars(uint32_t vtermno, char *buf, int count)40{41unsigned long got;4243if (plpar_get_term_char(vtermno, &got, buf) == H_SUCCESS)44return got;4546return 0;47}4849EXPORT_SYMBOL(hvc_get_chars);505152/**53* hvc_put_chars: send characters to firmware for denoted vterm adapter54* @vtermno: The vtermno or unit_address of the adapter from which the data55* originated.56* @buf: The character buffer that contains the character data to send to57* firmware.58* @count: Send this number of characters.59*/60int hvc_put_chars(uint32_t vtermno, const char *buf, int count)61{62unsigned long *lbuf = (unsigned long *) buf;63long ret;646566/* hcall will ret H_PARAMETER if 'count' exceeds firmware max.*/67if (count > MAX_VIO_PUT_CHARS)68count = MAX_VIO_PUT_CHARS;6970ret = plpar_hcall_norets(H_PUT_TERM_CHAR, vtermno, count, lbuf[0],71lbuf[1]);72if (ret == H_SUCCESS)73return count;74if (ret == H_BUSY)75return 0;76return -EIO;77}7879EXPORT_SYMBOL(hvc_put_chars);808182