kernel - close holes in autoconf's run_interrupt_driven_config_hooks()
[dragonfly.git] / usr.bin / doscmd / int16.c
blobc776912642b11f72585e7f9f3b3ab9b6143a66dd
1 /*
2 * Copyright (c) 1992, 1993, 1996
3 * Berkeley Software Design, Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Berkeley Software
16 * Design, Inc.
18 * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
30 * BSDI int16.c,v 2.2 1996/04/08 19:32:47 bostic Exp
32 * $FreeBSD: src/usr.bin/doscmd/int16.c,v 1.2.2.2 2002/04/25 11:04:51 tg Exp $
33 * $DragonFly: src/usr.bin/doscmd/int16.c,v 1.2 2003/06/17 04:29:26 dillon Exp $
36 #include "doscmd.h"
37 #include "tty.h"
39 #define K_NEXT *(u_short *)0x41a
40 #define K_FREE *(u_short *)0x41c
42 #define HWM 16
43 volatile int poll_cnt = 0;
45 void
46 wakeup_poll(void)
48 if (poll_cnt <= 0)
49 poll_cnt = HWM;
52 void
53 reset_poll(void)
55 poll_cnt = HWM;
58 void
59 sleep_poll(void)
61 #if 0
62 printf("sleep_poll: poll_cnt=%d\n", poll_cnt);
63 if (poll_cnt == 14)
64 tmode = 1;
65 #endif
66 if (--poll_cnt <= 0) {
67 poll_cnt = 0;
68 while (KbdEmpty() && poll_cnt <= 0) {
69 #if 0
70 softint(0x28);
71 #endif
72 if (KbdEmpty() && poll_cnt <= 0)
73 tty_pause();
78 void
79 int16(regcontext_t *REGS)
81 if (!xmode && !raw_kbd) {
82 if (vflag) dump_regs(REGS);
83 fatal ("int16 func 0x%x only supported in X mode\n", R_AH);
85 switch(R_AH) {
86 case 0x00:
87 case 0x10: /* Get enhanced keystroke */
88 poll_cnt = 16;
89 while (KbdEmpty())
90 tty_pause();
91 R_AX = KbdRead();
92 break;
94 case 0x01: /* Get keystroke */
95 case 0x11: /* Get enhanced keystroke */
96 if (KbdEmpty()) {
97 R_FLAGS |= PSL_Z;
98 break;
100 R_FLAGS &= ~PSL_Z;
101 R_AX = KbdPeek();
102 break;
104 case 0x02:
105 R_AL = tty_state();
106 break;
108 case 0x12:
109 R_AH = tty_estate();
110 R_AL = tty_state();
111 break;
113 case 0x03: /* Set typematic and delay rate */
114 break;
116 case 0x05:
117 KbdWrite(R_CX);
118 break;
120 case 0x55:
121 R_AX = 0x43af; /* Empirical value ... */
122 break;
124 case 0x92:
125 R_AH = 0x00;
126 break;
128 case 0xa2:
129 debug(D_HALF, "122-key keyboard support check\n");
130 break;
132 default:
133 unknown_int2(0x16, R_AH, REGS);
134 break;