2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <asm/hvcall.h>
|
|
|
|
#include <asm/hvconsole.h>
|
2006-07-18 16:01:28 -06:00
|
|
|
#include "plpar_wrappers.h"
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* hvc_get_chars - retrieve characters from firmware for denoted vterm adatper
|
|
|
|
* @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?
|
|
|
|
*/
|
|
|
|
int hvc_get_chars(uint32_t vtermno, char *buf, int count)
|
|
|
|
{
|
|
|
|
unsigned long got;
|
|
|
|
|
2006-07-18 16:01:28 -06:00
|
|
|
if (plpar_get_term_char(vtermno, &got, buf) == H_SUCCESS)
|
2005-04-16 16:20:36 -06:00
|
|
|
return got;
|
2006-07-18 16:01:28 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(hvc_get_chars);
|
|
|
|
|
2005-07-07 18:56:26 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* @count: Send this number of characters.
|
|
|
|
*/
|
|
|
|
int hvc_put_chars(uint32_t vtermno, const char *buf, int count)
|
|
|
|
{
|
|
|
|
unsigned long *lbuf = (unsigned long *) buf;
|
|
|
|
long ret;
|
|
|
|
|
2006-03-27 12:25:16 -07:00
|
|
|
|
|
|
|
/* hcall will ret H_PARAMETER if 'count' exceeds firmware max.*/
|
|
|
|
if (count > MAX_VIO_PUT_CHARS)
|
|
|
|
count = MAX_VIO_PUT_CHARS;
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
ret = plpar_hcall_norets(H_PUT_TERM_CHAR, vtermno, count, lbuf[0],
|
|
|
|
lbuf[1]);
|
2006-03-30 05:49:40 -07:00
|
|
|
if (ret == H_SUCCESS)
|
2005-04-16 16:20:36 -06:00
|
|
|
return count;
|
2006-03-30 05:49:40 -07:00
|
|
|
if (ret == H_BUSY)
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(hvc_put_chars);
|