| 1 | /* |
|---|
| 2 | * This program is free software; you can redistribute it and/or modify |
|---|
| 3 | * it under the terms of the GNU General Public License as published by |
|---|
| 4 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 5 | * (at your option) any later version. |
|---|
| 6 | * |
|---|
| 7 | * This program is distributed in the hope that it will be useful, |
|---|
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 10 | * GNU General Public License for more details. |
|---|
| 11 | * |
|---|
| 12 | * You should have received a copy of the GNU General Public License |
|---|
| 13 | * along with this program; if not, write to the Free Software |
|---|
| 14 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|---|
| 15 | * |
|---|
| 16 | * Copyright (C) IBM Corp. 2005 |
|---|
| 17 | * |
|---|
| 18 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #include <xen/config.h> |
|---|
| 22 | #include <xen/types.h> |
|---|
| 23 | #include <xen/sched.h> |
|---|
| 24 | #include <xen/init.h> |
|---|
| 25 | #include <public/xen.h> |
|---|
| 26 | #include <asm/current.h> |
|---|
| 27 | #include <asm/papr.h> |
|---|
| 28 | #include <asm/hcalls.h> |
|---|
| 29 | |
|---|
| 30 | static void h_put_term_char(struct cpu_user_regs *regs) |
|---|
| 31 | { |
|---|
| 32 | char data[(sizeof (u64) * 4) + 1]; |
|---|
| 33 | ulong count; |
|---|
| 34 | extern void serial_puts(int handle, const char *s); |
|---|
| 35 | |
|---|
| 36 | /* XXX what to do with 'channel' in r4? */ |
|---|
| 37 | |
|---|
| 38 | count = regs->gprs[5]; |
|---|
| 39 | if (count > 16) { |
|---|
| 40 | regs->gprs[3] = H_Parameter; |
|---|
| 41 | return; |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | memcpy(data, ®s->gprs[6], count); |
|---|
| 45 | data[count] = '\0'; |
|---|
| 46 | |
|---|
| 47 | serial_puts(0, data); |
|---|
| 48 | regs->gprs[3] = H_Success; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | static void h_get_term_char(struct cpu_user_regs *regs) |
|---|
| 52 | { |
|---|
| 53 | /* temporary hack to let us use xmon in dom0 */ |
|---|
| 54 | extern char serial_getc_nb(int handle); |
|---|
| 55 | char c; |
|---|
| 56 | |
|---|
| 57 | c = serial_getc_nb(0); |
|---|
| 58 | if (c > 0) { |
|---|
| 59 | regs->gprs[4] = 1; |
|---|
| 60 | regs->gprs[5] = (ulong)c << (7 * 8); |
|---|
| 61 | regs->gprs[6] = 0; /* paranoid */ |
|---|
| 62 | } else { |
|---|
| 63 | regs->gprs[4] = 0; |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | regs->gprs[3] = H_Success; |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | __init_papr_hcall(H_PUT_TERM_CHAR, h_put_term_char); |
|---|
| 70 | __init_papr_hcall(H_GET_TERM_CHAR, h_get_term_char); |
|---|