2 * Copyright (c) 1998 Robert Nordier
5 * Redistribution and use in source and binary forms are freely
6 * permitted provided that the above copyright notice and this
7 * paragraph and the following disclaimer are duplicated in all
10 * This software is provided "AS IS" and without any express or
11 * implied warranties, including, without limitation, the implied
12 * warranties of merchantability and fitness for a particular
16 #include <sys/cdefs.h>
17 __FBSDID("$FreeBSD$");
19 #include <sys/param.h>
21 #include <machine/psl.h>
31 #define SECOND 18 /* Circa that many ticks in a second. */
33 uint8_t ioctrl = IO_KEYBOARD;
41 v86.eax = 0xe00 | (c & 0xff);
50 if (ioctrl & IO_KEYBOARD)
52 if (ioctrl & IO_SERIAL)
57 getcursor(int *row, int *col)
68 *col = v86.edx & 0xff;
82 getcursor(NULL, &col);
84 for (i = 0; i < col; i++)
112 if (OPT_CHECK(RBX_NOINTR))
115 if (ioctrl & IO_KEYBOARD && getc(1))
116 return (fn ? 1 : getc(0));
117 if (ioctrl & IO_SERIAL && sio_ischar())
118 return (fn ? 1 : sio_getc());
129 return (xgetc(0) & 0xff);
133 keyhit(unsigned int secs)
137 if (OPT_CHECK(RBX_NOINTR))
143 * The extra comparison is an attempt to work around
144 * what appears to be a bug in QEMU and Bochs. Both emulators
145 * sometimes report a key-press with scancode one and ascii zero
146 * when no such key is pressed in reality. As far as I can tell,
147 * this only happens shortly after a reboot.
150 if (c != 0 && c != 0x0100)
153 t1 = *(uint32_t *)PTOV(0x46c);
156 if (t1 < t0 || t1 >= t0 + secs)
164 getstr(char *cmdstr, size_t cmdstrsize)
173 /* Translate some extended codes. */
175 case 0x5300: /* delete */
196 if (c >= 0x20 && c <= 0x7e) {
197 if (s - cmdstr < cmdstrsize - 1)