]> git.dujemihanovic.xyz Git - nameless-os.git/blob - include/arch/x86/input/ps2.h
8b90a73e5de11b96a4c000bfad5ca6128665984c
[nameless-os.git] / include / arch / x86 / input / ps2.h
1 #ifndef X86_INPUT_PS2_H
2 #define X86_INPUT_PS2_H
3
4 /* port constants */
5 #define PS2_DATA_PORT 0x60
6 #define PS2_CMD_STS_PORT 0x64
7
8 /* command constants */
9 #define PS2_CMD_PORT_2_DISABLE 0xA7
10 #define PS2_CMD_PORT_1_DISABLE 0xAD
11 #define PS2_CMD_PORT_2_ENABLE 0xA8
12 #define PS2_CMD_PORT_1_ENABLE 0xAE
13 #define PS2_CMD_READ_CCB 0x20
14 #define PS2_CMD_WRITE_CCB 0x60
15 #define PS2_CMD_CONTROLLER_TEST 0xAA
16 #define PS2_CMD_PORT_1_TEST 0xAB
17 #define PS2_CMD_PORT_2_TEST 0xA9
18 #define PS2_CMD_PORT_2_WRITE 0xD4
19
20 #define PS2_DEV_RESET 0xFF
21
22 #define PS2_CONTROLLER_GOOD 0x55
23 #define PS2_CONTROLLER_BAD 0xFC
24
25 enum PS2_CCB {
26 PORT_1_IRQ = 0,
27 PORT_2_IRQ,
28 SYSTEM_FLAG,
29 ZERO,
30 PORT_1_CLK,
31 PORT_2_CLK,
32 PORT_1_TRANSL,
33 ZERO2
34 };
35
36 enum PS2_STATUS {
37 OUT_STATUS = 0,
38 IN_STATUS,
39 STS_SYSTEM_FLAG,
40 CMD_DATA,
41 UNKNOWN,
42 UNKNOWN2,
43 TIMEOUT_ERROR,
44 PARITY_ERROR
45 };
46
47 enum PS2_SPECIAL {
48 SELF_TEST_GOOD = 0xAA,
49 SELF_TEST_BAD = 0xFC,
50 SELF_TEST_BAD_2 = 0xFD,
51 ACK = 0xFA,
52 RESEND = 0xFE
53 };
54
55 static const char scancodes[] = {
56 /* letters */
57 [0x15] = 'q',
58 [0x1d] = 'w',
59 [0x24] = 'e',
60 [0x2d] = 'r',
61 [0x2c] = 't',
62 [0x35] = 'y',
63 [0x3c] = 'u',
64 [0x43] = 'i',
65 [0x44] = 'o',
66 [0x4d] = 'p',
67 [0x1c] = 'a',
68 [0x1b] = 's',
69 [0x23] = 'd',
70 [0x2b] = 'f',
71 [0x34] = 'g',
72 [0x33] = 'h',
73 [0x3b] = 'j',
74 [0x42] = 'k',
75 [0x4b] = 'l',
76 [0x1a] = 'z',
77 [0x22] = 'x',
78 [0x21] = 'c',
79 [0x2a] = 'v',
80 [0x32] = 'b',
81 [0x31] = 'n',
82 [0x3a] = 'm',
83
84 /* special */
85 [0x29] = ' '
86 };
87
88 extern int ps2_initialize();
89 extern void ps2_input_wait();
90 extern void ps2_output_wait();
91
92 #endif