1 /* $NetBSD: consio.c,v 1.4 2001/12/02 14:25:44 minoura Exp $ */
4 * Copyright (c) 2001 MINOURA Makoto.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include <machine/stdarg.h>
29 #include <lib/libkern/libkern.h>
30 #include <lib/libsa/stand.h>
40 } x68k_console_device
;
43 consio_init(int device
)
45 if (device
< 0) { /* undetemined yet */
49 IOCS_B_PRINT ("No keyboard; "
50 "switching to serial console...");
57 x68k_console_device
= ITE
;
58 /* set palette here */
62 x68k_console_device
= SERIAL
;
64 IOCS_SET232C (SERPARAM
);
67 return x68k_console_device
;
75 switch (x68k_console_device
) {
77 while ((r
= IOCS_B_KEYINP () & 0xff) == 0);
80 while ((r
= IOCS_INP232C () & 0xff) == 0);
92 switch (x68k_console_device
) {
103 switch (x68k_console_device
) {
105 return IOCS_B_KEYSNS () & 0xff;
107 return IOCS_ISNS232C () & 0xff;
118 while (check_getchar())
121 for (i
= 0; i
< 100 && (c
= check_getchar()) == 0; i
++) {
122 while (MFP_TIMERC
> 100)
124 while (MFP_TIMERC
<= 100)
128 while (check_getchar())
135 panic(const char *fmt
,...)
148 extern void put_image(int, int);
151 print_title(const char *fmt
, ...)
155 if (x68k_console_device
== ITE
) {
157 char *buf
= alloca(240); /* about 3 lines */
160 y
= y1
= (IOCS_B_LOCATE(-1, -1) & 0xffff) + 1;
161 put_image(8, y
*16-6);
162 IOCS_B_LOCATE(0, y
+3);
163 IOCS_B_PRINT("\360D\360a\360e\360m\360o\360n "
164 "\360l\360o\360g\360o "
165 "\360(\360C\360)\3601\3609\3609\3608\360 "
167 "\360M\360a\360r\360s\360h\360a\360l\360l\360 "
168 "\360K\360i\360r\360k\360 "
169 "\360M\360c\360K\360u\360s\360i\360c\360k\360.");
171 vsnprintf(buf
, 240, fmt
, ap
);
173 while ((p
= strchr(buf
, '\n')) != 0) {
175 IOCS_B_LOCATE(9, ++y
);
179 IOCS_B_LOCATE(9, ++y
);
181 IOCS_B_LOCATE(0, y1
+5);