Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hvconsole.c
Go to the documentation of this file.
1 /*
2  * hvconsole.c
3  * Copyright (C) 2004 Hollis Blanchard, IBM Corporation
4  * Copyright (C) 2004 IBM Corporation
5  *
6  * Additional Author(s):
7  * Ryan S. Arnold <[email protected]>
8  *
9  * LPAR console support.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  */
25 
26 #include <linux/kernel.h>
27 #include <linux/export.h>
28 #include <linux/errno.h>
29 #include <asm/hvcall.h>
30 #include <asm/hvconsole.h>
31 #include "plpar_wrappers.h"
32 
41 int hvc_get_chars(uint32_t vtermno, char *buf, int count)
42 {
43  unsigned long got;
44 
45  if (plpar_get_term_char(vtermno, &got, buf) == H_SUCCESS)
46  return got;
47 
48  return 0;
49 }
50 
52 
53 
62 int hvc_put_chars(uint32_t vtermno, const char *buf, int count)
63 {
64  unsigned long *lbuf = (unsigned long *) buf;
65  long ret;
66 
67 
68  /* hcall will ret H_PARAMETER if 'count' exceeds firmware max.*/
69  if (count > MAX_VIO_PUT_CHARS)
70  count = MAX_VIO_PUT_CHARS;
71 
72  ret = plpar_hcall_norets(H_PUT_TERM_CHAR, vtermno, count, lbuf[0],
73  lbuf[1]);
74  if (ret == H_SUCCESS)
75  return count;
76  if (ret == H_BUSY)
77  return -EAGAIN;
78  return -EIO;
79 }
80