5c56c48c5a1c2c4651a4dec4fc2d56af9c525b1e
[bootcensus] / src / kbregs.h
1 /*
2 pcboot - bootable PC demo/game kernel
3 Copyright (C) 2018  John Tsiombikas <nuclear@member.fsf.org>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY, without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 */
18 #ifndef KBREGS_H_
19 #define KBREGS_H_
20
21 #define KB_IRQ          1
22 #define PSAUX_IRQ       12
23
24 #define KB_DATA_PORT    0x60
25 #define KB_CMD_PORT             0x64
26 #define KB_STATUS_PORT  0x64
27
28 #define KB_ACK                  0xfa
29 #define KB_NACK                 0xfe
30
31 #define KB_STAT_OUTBUF_FULL     0x01
32 #define KB_STAT_INBUF_FULL      0x02
33 #define KB_STAT_SYSFLAG         0x04
34 #define KB_STAT_CMD                     0x08
35 #define KB_STAT_ACTIVE          0x10
36 #define KB_STAT_AUX                     0x20
37 #define KB_STAT_TIMEOUT         0x40
38 #define KB_STAT_PAR_ERROR       0x80
39
40 /* keyboard commands */
41 #define KB_CMD_GET_CMDBYTE              0x20
42 #define KB_CMD_SET_CMDBYTE              0x60
43 #define KB_CMD_AUX_ENABLE               0xa8
44 #define KB_CMD_READ_OUTPORT             0xd0
45 #define KB_CMD_WRITE_OUTPORT    0xd1
46 #define KB_CMD_PSAUX                    0xd4
47 #define KB_CMD_PULSE_RESET              0xfe
48
49 /* controller command byte bits */
50 #define KB_CCB_KB_INTREN                0x01
51 #define KB_CCB_AUX_INTREN               0x02
52 #define KB_CCB_SYSFLAG                  0x04
53 #define KB_CCB_KB_DISABLE               0x10
54 #define KB_CCB_AUX_DISABLE              0x20
55 #define KB_CCB_KB_XLAT                  0x40
56
57 /* psaux commands (use with d4 prefix) */
58 #define AUX_CMD_STREAM_MODE             0xea
59 #define AUX_CMD_READ_MOUSE              0xeb
60 #define AUX_CMD_REMOTE_MODE             0xf0
61 #define AUX_CMD_ENABLE                  0xf4
62 #define AUX_CMD_DEFAULTS                0xf6
63
64 #define AUX_PKT0_LEFTBN                 0x01
65 #define AUX_PKT0_RIGHTBN                0x02
66 #define AUX_PKT0_MIDDLEBN               0x04
67 #define AUX_PKT0_ALWAYS1                0x08
68 #define AUX_PKT0_XSIGN                  0x10
69 #define AUX_PKT0_YSIGN                  0x20
70 #define AUX_PKT0_XOVF                   0x40
71 #define AUX_PKT0_YOVF                   0x80
72
73 #define AUX_PKT0_OVF_BITS               (AUX_PKT0_XOVF | AUX_PKT0_YOVF)
74 #define AUX_PKT0_BUTTON_BITS \
75         (AUX_PKT0_LEFTBN | AUX_PKT0_RIGHTBN | AUX_PKT0_MIDDLEBN)
76
77 #endif  /* KBREGS_H_ */