17568cb4eSPaul Mackerras /* 27568cb4eSPaul Mackerras * hvconsole.c 37568cb4eSPaul Mackerras * Copyright (C) 2004 Hollis Blanchard, IBM Corporation 47568cb4eSPaul Mackerras * Copyright (C) 2004 IBM Corporation 57568cb4eSPaul Mackerras * 67568cb4eSPaul Mackerras * Additional Author(s): 77568cb4eSPaul Mackerras * Ryan S. Arnold <rsa@us.ibm.com> 87568cb4eSPaul Mackerras * 97568cb4eSPaul Mackerras * LPAR console support. 107568cb4eSPaul Mackerras * 117568cb4eSPaul Mackerras * This program is free software; you can redistribute it and/or modify 127568cb4eSPaul Mackerras * it under the terms of the GNU General Public License as published by 137568cb4eSPaul Mackerras * the Free Software Foundation; either version 2 of the License, or 147568cb4eSPaul Mackerras * (at your option) any later version. 157568cb4eSPaul Mackerras * 167568cb4eSPaul Mackerras * This program is distributed in the hope that it will be useful, 177568cb4eSPaul Mackerras * but WITHOUT ANY WARRANTY; without even the implied warranty of 187568cb4eSPaul Mackerras * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 197568cb4eSPaul Mackerras * GNU General Public License for more details. 207568cb4eSPaul Mackerras * 217568cb4eSPaul Mackerras * You should have received a copy of the GNU General Public License 227568cb4eSPaul Mackerras * along with this program; if not, write to the Free Software 237568cb4eSPaul Mackerras * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 247568cb4eSPaul Mackerras */ 257568cb4eSPaul Mackerras 267568cb4eSPaul Mackerras #include <linux/kernel.h> 277568cb4eSPaul Mackerras #include <linux/module.h> 287568cb4eSPaul Mackerras #include <asm/hvcall.h> 297568cb4eSPaul Mackerras #include <asm/hvconsole.h> 30b9377ffcSAnton Blanchard #include "plpar_wrappers.h" 317568cb4eSPaul Mackerras 327568cb4eSPaul Mackerras /** 337568cb4eSPaul Mackerras * hvc_get_chars - retrieve characters from firmware for denoted vterm adatper 347568cb4eSPaul Mackerras * @vtermno: The vtermno or unit_address of the adapter from which to fetch the 357568cb4eSPaul Mackerras * data. 367568cb4eSPaul Mackerras * @buf: The character buffer into which to put the character data fetched from 377568cb4eSPaul Mackerras * firmware. 387568cb4eSPaul Mackerras * @count: not used? 397568cb4eSPaul Mackerras */ 407568cb4eSPaul Mackerras int hvc_get_chars(uint32_t vtermno, char *buf, int count) 417568cb4eSPaul Mackerras { 427568cb4eSPaul Mackerras unsigned long got; 437568cb4eSPaul Mackerras 44b9377ffcSAnton Blanchard if (plpar_get_term_char(vtermno, &got, buf) == H_SUCCESS) 457568cb4eSPaul Mackerras return got; 46b9377ffcSAnton Blanchard 477568cb4eSPaul Mackerras return 0; 487568cb4eSPaul Mackerras } 497568cb4eSPaul Mackerras 507568cb4eSPaul Mackerras EXPORT_SYMBOL(hvc_get_chars); 517568cb4eSPaul Mackerras 527568cb4eSPaul Mackerras 537568cb4eSPaul Mackerras /** 547568cb4eSPaul Mackerras * hvc_put_chars: send characters to firmware for denoted vterm adapter 557568cb4eSPaul Mackerras * @vtermno: The vtermno or unit_address of the adapter from which the data 567568cb4eSPaul Mackerras * originated. 577568cb4eSPaul Mackerras * @buf: The character buffer that contains the character data to send to 587568cb4eSPaul Mackerras * firmware. 597568cb4eSPaul Mackerras * @count: Send this number of characters. 607568cb4eSPaul Mackerras */ 617568cb4eSPaul Mackerras int hvc_put_chars(uint32_t vtermno, const char *buf, int count) 627568cb4eSPaul Mackerras { 637568cb4eSPaul Mackerras unsigned long *lbuf = (unsigned long *) buf; 647568cb4eSPaul Mackerras long ret; 657568cb4eSPaul Mackerras 6645d607edSRyan S. Arnold 6745d607edSRyan S. Arnold /* hcall will ret H_PARAMETER if 'count' exceeds firmware max.*/ 6845d607edSRyan S. Arnold if (count > MAX_VIO_PUT_CHARS) 6945d607edSRyan S. Arnold count = MAX_VIO_PUT_CHARS; 7045d607edSRyan S. Arnold 717568cb4eSPaul Mackerras ret = plpar_hcall_norets(H_PUT_TERM_CHAR, vtermno, count, lbuf[0], 727568cb4eSPaul Mackerras lbuf[1]); 73706c8c93SSegher Boessenkool if (ret == H_SUCCESS) 747568cb4eSPaul Mackerras return count; 75706c8c93SSegher Boessenkool if (ret == H_BUSY) 7651d33021SAnton Blanchard return -EAGAIN; 777568cb4eSPaul Mackerras return -EIO; 787568cb4eSPaul Mackerras } 797568cb4eSPaul Mackerras 807568cb4eSPaul Mackerras EXPORT_SYMBOL(hvc_put_chars); 81