0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <linux/kernel.h>
0014 #include <linux/export.h>
0015 #include <linux/errno.h>
0016 #include <asm/hvcall.h>
0017 #include <asm/hvconsole.h>
0018 #include <asm/plpar_wrappers.h>
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 int hvc_get_chars(uint32_t vtermno, char *buf, int count)
0029 {
0030 long ret;
0031 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
0032 unsigned long *lbuf = (unsigned long *)buf;
0033
0034 ret = plpar_hcall(H_GET_TERM_CHAR, retbuf, vtermno);
0035 lbuf[0] = be64_to_cpu(retbuf[1]);
0036 lbuf[1] = be64_to_cpu(retbuf[2]);
0037
0038 if (ret == H_SUCCESS)
0039 return retbuf[0];
0040
0041 return 0;
0042 }
0043
0044 EXPORT_SYMBOL(hvc_get_chars);
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 int hvc_put_chars(uint32_t vtermno, const char *buf, int count)
0056 {
0057 unsigned long *lbuf = (unsigned long *) buf;
0058 long ret;
0059
0060
0061
0062 if (count > MAX_VIO_PUT_CHARS)
0063 count = MAX_VIO_PUT_CHARS;
0064
0065 ret = plpar_hcall_norets(H_PUT_TERM_CHAR, vtermno, count,
0066 cpu_to_be64(lbuf[0]),
0067 cpu_to_be64(lbuf[1]));
0068 if (ret == H_SUCCESS)
0069 return count;
0070 if (ret == H_BUSY)
0071 return -EAGAIN;
0072 return -EIO;
0073 }
0074
0075 EXPORT_SYMBOL(hvc_put_chars);