backported fixes from 256boss
[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 #define KB_TEST_PASSED  0x55
31 #define KB_TEST_FAILED  0xfc
32
33 #define KB_STAT_OUTBUF_FULL     0x01
34 #define KB_STAT_INBUF_FULL      0x02
35 #define KB_STAT_SYSFLAG         0x04
36 #define KB_STAT_CMD                     0x08
37 #define KB_STAT_ACTIVE          0x10
38 #define KB_STAT_AUX                     0x20
39 #define KB_STAT_TIMEOUT         0x40
40 #define KB_STAT_PAR_ERROR       0x80
41
42 #define KB_CMD_TEST                             0xaa
43
44 /* keyboard commands */
45 #define KB_CMD_GET_CMDBYTE              0x20
46 #define KB_CMD_SET_CMDBYTE              0x60
47 #define KB_CMD_AUX_ENABLE               0xa8
48 #define KB_CMD_READ_OUTPORT             0xd0
49 #define KB_CMD_WRITE_OUTPORT    0xd1
50 #define KB_CMD_PSAUX                    0xd4
51 #define KB_CMD_PULSE_RESET              0xfe
52
53 /* controller command byte bits */
54 #define KB_CCB_KB_INTREN                0x01
55 #define KB_CCB_AUX_INTREN               0x02
56 #define KB_CCB_SYSFLAG                  0x04
57 #define KB_CCB_KB_DISABLE               0x10
58 #define KB_CCB_AUX_DISABLE              0x20
59 #define KB_CCB_KB_XLAT                  0x40
60
61 /* psaux commands (use with d4 prefix) */
62 #define AUX_CMD_STREAM_MODE             0xea
63 #define AUX_CMD_READ_MOUSE              0xeb
64 #define AUX_CMD_REMOTE_MODE             0xf0
65 #define AUX_CMD_ENABLE                  0xf4
66 #define AUX_CMD_DEFAULTS                0xf6
67
68 #define AUX_PKT0_LEFTBN                 0x01
69 #define AUX_PKT0_RIGHTBN                0x02
70 #define AUX_PKT0_MIDDLEBN               0x04
71 #define AUX_PKT0_ALWAYS1                0x08
72 #define AUX_PKT0_XSIGN                  0x10
73 #define AUX_PKT0_YSIGN                  0x20
74 #define AUX_PKT0_XOVF                   0x40
75 #define AUX_PKT0_YOVF                   0x80
76
77 #define AUX_PKT0_OVF_BITS               (AUX_PKT0_XOVF | AUX_PKT0_YOVF)
78 #define AUX_PKT0_BUTTON_BITS \
79         (AUX_PKT0_LEFTBN | AUX_PKT0_RIGHTBN | AUX_PKT0_MIDDLEBN)
80
81 #endif  /* KBREGS_H_ */