1 /* Console Callback Routines.
3 Copyright (C) 2011 Richard Henderson
5 This file is part of QEMU PALcode.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the text
15 of the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not see
19 <http://www.gnu.org/licenses/>. */
27 /* All routines use the high bit to signal error. */
28 #define ERR 0x8000000000000000ul
34 /* Multiple consoles not yet supported. */
38 return uart_getchar(COM1
);
42 crb_process_keycode(long unit
, long keycode
, long again
)
44 /* This routine might be needed for real keyboards, and mostly for
45 internationalization stuff. */
46 /* Return Failure: routine not supported. */
47 return 0xc000000000000000ul
;
51 crb_puts(long unit
, const char *buf
, unsigned long length
)
53 unsigned int orig_length
= length
;
55 /* Multiple consoles not yet supported. */
59 for (; length
!= 0; --length
, ++buf
)
60 uart_putchar_raw(COM1
, (unsigned char)*buf
);
62 /* Bits <31:0> of the return value are the number of bytes written.
63 To me that implies that the input value must be 32-bit, but v2
64 of the ARM doesn't explicitly say. */
69 crb_reset_term(long unit
)
71 /* Multiple consoles not yet supported. */
75 uart_init_line(COM1
, 9600);
80 crb_set_term_ctl(long unit
, long ctb
)
82 /* ??? The contents of the CTB do not seem to be defined anywhere.
83 How, therefore, can the user set new contents? */
88 crb_set_term_int(long unit
, long mask
)
90 /* We do no buffering, therefore we don't need to support interrupts. */
91 if (unit
!= 0 || (mask
& 0x22) != 0)
97 crb_open(const char *devstr
, unsigned long length
)
104 crb_close(long channel
)
111 crb_ioctl(long channel
)
113 /* We do not, nor will not, support virtual tapes. */
118 crb_read(long channel
, unsigned long length
, char *buf
, unsigned long block
)
125 crb_write(long channel
, unsigned long length
, const char *buf
,
133 crb_get_env(unsigned long id
, char *buf
, unsigned long length
)
136 return 0xc000000000000000ul
;
140 crb_set_env(unsigned long id
, const char *buf
, unsigned long length
)
143 return 0xc000000000000000ul
;
147 crb_reset_env(unsigned long id
, char *buf
, unsigned long length
)
150 return 0xc000000000000000ul
;
157 return 0xc000000000000000ul
;
161 crb_pswitch(long action
, long cpu_id
)
163 /* Why would we ever need to support switching primary processor? */
167 static unsigned long __attribute__((used
))
168 int_crb_dispatch(long select
, long a1
, long a2
, long a3
, long a4
)
175 return crb_puts(a1
, (const char *)a2
, a3
);
177 return crb_reset_term(a1
);
178 case CRB_SET_TERM_INT
:
179 return crb_set_term_int(a1
, a2
);
180 case CRB_SET_TERM_CTL
:
181 return crb_set_term_ctl(a1
, a2
);
182 case CRB_PROCESS_KEYCODE
:
183 return crb_process_keycode(a1
, a2
, a3
);
186 return crb_open((const char*)a1
, a2
);
188 return crb_close(a1
);
190 return crb_ioctl(a1
);
192 return crb_read(a1
, a2
, (char *)a3
, a4
);
194 return crb_write(a1
, a2
, (const char *)a3
, a4
);
197 return crb_set_env(a1
, (const char *)a2
, a3
);
199 return crb_reset_env(a1
, (char *)a2
, a3
);
201 return crb_get_env(a1
, (char *)a2
, a3
);
203 return crb_save_env();
206 return crb_pswitch(a1
, a2
);
211 static unsigned long __attribute__((used
))
212 int_crb_fixup(unsigned long vptptr
, unsigned long hwrpb
)
214 /* Given that this console is written to use the KSEG, and not be
215 mapped into any page-table address space, it doesn't seem like
216 we need to do anything at all here. */
220 /* The CRB DISPATCH and FIXUP functions are defined to use the VMS
221 calling convention. This has several effects:
222 (1) The set of call-saved registers is different.
223 (2) $27 contains the procdesc_struct, not the called function.
224 Map between the two calling conventions here. */
226 asm(".macro VMStoUNIX name\n"
230 " .frame $sp, 64, $26, 0\n"
231 " subq $sp, 64, $sp\n"
240 " .mask 0x40001fc, 0\n"
243 " ldgp $gp, 0($gp)\n"
244 " bsr $26, int_\\name !samegp\n"
253 " addq $sp, 64, $sp\n"
257 " VMStoUNIX crb_dispatch\n"
258 " VMStoUNIX crb_fixup\n"