-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathps2.h
213 lines (190 loc) · 6.61 KB
/
ps2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
// file: "ps2.h"
// Copyright (c) 2001-2002 by Marc Feeley and Universit� de Montr�al, All
// Rights Reserved.
//
// Revision History
// 20 Jan 02 merged support for ps/2 mouse (Marc Feeley)
// 22 Sep 01 initial version (Marc Feeley)
#ifndef __PS2_H
#define __PS2_H
//-----------------------------------------------------------------------------
#include "general.h"
//-----------------------------------------------------------------------------
//
// Definitions for 8042 keyboard controller.
//
#define PS2_MOUSE_BUFF_SIZE 3
#define PS2_PORT_A 0x60
#define PS2_PORT_B 0x61
#define PS2_PORT_C 0x62
#define PS2_PORT_CMD 0x64
#define PS2_PORT_STATUS 0x64
#define PS2_B_SW1 (1 << 7) // port A reads switches or keyboard/mouse
#define PS2_B_TKT (1 << 6) // keyboard clock enable
#define PS2_B_NME (1 << 5) // enable NMI on expansion card error
#define PS2_B_NMI (1 << 4) // enable NMI on memory parity check
#define PS2_B_REC (1 << 3) // control cassette recorder motor
#define PS2_B_SW2 (1 << 2) // select DIP switch to read
#define PS2_B_SPK (1 << 1) // send PIT counter 2 to speaker/cassette
#define PS2_B_RSG (1 << 0) // enable PIT counter 2
#define PS2_C_PAR (1 << 7) // memory parity error
#define PS2_C_ERW (1 << 6) // expansion card error
#define PS2_C_TIM (1 << 5) // output of PIT counter 2
#define PS2_C_TON (1 << 4) // cassette recorder signal
#define PS2_C_HS5 (1 << 3) // DIP switch (HS6-HS2 = size of main memory)
#define PS2_C_HS4 (1 << 2)
#define PS2_C_HS3 (1 << 1)
#define PS2_C_HS2_HS6 (1 << 0)
#define PS2_PARE (1 << 7) // last byte received from kbd/mouse has parity error
#define PS2_TIM (1 << 6) // time-out error
#define PS2_AUXB (1 << 5) // port A contains mouse data / keyboard data
#define PS2_KEYL (1 << 4) // keyboard locked
#define PS2_C_D (1 << 3) // command / data byte
#define PS2_SYSF (1 << 2) // system flag
#define PS2_INPB (1 << 1) // input buffer (to controller) full
#define PS2_OUTB (1 << 0) // output buffer (from keyboard/mouse) full
#define PS2_CMD_CONFIG 0x60
#define PS2_CMD_DISABLE_MOUSE 0xa7
#define PS2_CMD_ENABLE_MOUSE 0xa8
#define PS2_CMD_DISABLE_KEYBOARD 0xad
#define PS2_CMD_ENABLE_KEYBOARD 0xae
#define PS2_CMD_WRITE_MOUSE 0xd4
#define PS2_MOUSE_CMD_SET_SCALE11 0xe6
#define PS2_MOUSE_CMD_SET_SCALE21 0xe7
#define PS2_MOUSE_CMD_SET_RESOLUTION 0xe8
#define PS2_MOUSE_CMD_GET_STATUS 0xe9
#define PS2_MOUSE_CMD_SET_STREAM_MODE 0xea
#define PS2_MOUSE_CMD_GET_REPORT 0xeb
#define PS2_MOUSE_CMD_SET_REMOTE_MODE 0xf0
#define PS2_MOUSE_CMD_GET_ID 0xf2
#define PS2_MOUSE_CMD_SET_SAMPLE_RATE 0xf3
#define PS2_MOUSE_CMD_ENABLE_REPORTING 0xf4
#define PS2_MOUSE_CMD_DISABLE_REPORTING 0xf5
#define PS2_MOUSE_CMD_SET_DEFAULTS 0xf6
#define PS2_MOUSE_CMD_RESEND 0xfe
#define PS2_MOUSE_CMD_RESET 0xff
#define PS2_MOUSE_ACK 0xfa
#define PS2_MOUSE_BAT_ACK 0xaa
#define PS2_MOUSE_ID_PS2 0
#define PS2_MOUSE_ID_IMPS2 3
#define PS2_MOUSE_10_SAMPLES_PER_SEC 10
#define PS2_MOUSE_20_SAMPLES_PER_SEC 20
#define PS2_MOUSE_40_SAMPLES_PER_SEC 40
#define PS2_MOUSE_60_SAMPLES_PER_SEC 60
#define PS2_MOUSE_80_SAMPLES_PER_SEC 80
#define PS2_MOUSE_100_SAMPLES_PER_SEC 100
#define PS2_MOUSE_200_SAMPLES_PER_SEC 200
#define PS2_MOUSE_1_COUNTS_PER_MM 0
#define PS2_MOUSE_2_COUNTS_PER_MM 1
#define PS2_MOUSE_4_COUNTS_PER_MM 2
#define PS2_MOUSE_8_COUNTS_PER_MM 3
#define PS2_CONFIG_SCAN_CONVERT (1 << 6)
#define PS2_CONFIG_AUXB_CLOCK_DISABLE (1 << 5)
#define PS2_CONFIG_KBD_CLOCK_DISABLE (1 << 4)
#define PS2_CONFIG_SYSF (1 << 2)
#define PS2_CONFIG_ENABLE_IRQ12 (1 << 1)
#define PS2_CONFIG_ENABLE_IRQ1 (1 << 0)
#define KBD_SCANCODE_ESC 0x01
#define KBD_SCANCODE_1 0x02
#define KBD_SCANCODE_2 0x03
#define KBD_SCANCODE_3 0x04
#define KBD_SCANCODE_4 0x05
#define KBD_SCANCODE_5 0x06
#define KBD_SCANCODE_6 0x07
#define KBD_SCANCODE_7 0x08
#define KBD_SCANCODE_8 0x09
#define KBD_SCANCODE_9 0x0A
#define KBD_SCANCODE_0 0x0B
#define KBD_SCANCODE_MINUS 0x0C
#define KBD_SCANCODE_EQUAL 0x0D
#define KBD_SCANCODE_BSPACE 0x0E
#define KBD_SCANCODE_TAB 0x0F
#define KBD_SCANCODE_Q 0x10
#define KBD_SCANCODE_W 0x11
#define KBD_SCANCODE_E 0x12
#define KBD_SCANCODE_R 0x13
#define KBD_SCANCODE_T 0x14
#define KBD_SCANCODE_Y 0x15
#define KBD_SCANCODE_U 0x16
#define KBD_SCANCODE_I 0x17
#define KBD_SCANCODE_O 0x18
#define KBD_SCANCODE_P 0x19
#define KBD_SCANCODE_LBRACK 0x1A
#define KBD_SCANCODE_RBRACK 0x1B
#define KBD_SCANCODE_ENTER 0x1C
#define KBD_SCANCODE_CTRL 0x1D
#define KBD_SCANCODE_A 0x1E
#define KBD_SCANCODE_S 0x1F
#define KBD_SCANCODE_D 0x20
#define KBD_SCANCODE_F 0x21
#define KBD_SCANCODE_G 0x22
#define KBD_SCANCODE_H 0x23
#define KBD_SCANCODE_J 0x24
#define KBD_SCANCODE_K 0x25
#define KBD_SCANCODE_L 0x26
#define KBD_SCANCODE_SEMICOLON 0x27
#define KBD_SCANCODE_QUOTE 0x28
#define KBD_SCANCODE_BQUOTE 0x29
#define KBD_SCANCODE_LSHIFT 0x2A
#define KBD_SCANCODE_BSLASH 0x2B
#define KBD_SCANCODE_Z 0x2C
#define KBD_SCANCODE_X 0x2D
#define KBD_SCANCODE_C 0x2E
#define KBD_SCANCODE_V 0x2F
#define KBD_SCANCODE_B 0x30
#define KBD_SCANCODE_N 0x31
#define KBD_SCANCODE_M 0x32
#define KBD_SCANCODE_COMMA 0x33
#define KBD_SCANCODE_PERIOD 0x34
#define KBD_SCANCODE_SLASH 0x35
#define KBD_SCANCODE_RSHIFT 0x36
#define KBD_SCANCODE_PRTSC 0x37
#define KBD_SCANCODE_ALT 0x38
#define KBD_SCANCODE_SPACE 0x39
#define KBD_SCANCODE_CAPS 0x3A
#define KBD_SCANCODE_F1 0x3B
#define KBD_SCANCODE_F2 0x3C
#define KBD_SCANCODE_F3 0x3D
#define KBD_SCANCODE_F4 0x3E
#define KBD_SCANCODE_F5 0x3F
#define KBD_SCANCODE_F6 0x40
#define KBD_SCANCODE_F7 0x41
#define KBD_SCANCODE_F8 0x42
#define KBD_SCANCODE_F9 0x43
#define KBD_SCANCODE_F10 0x44
#define KBD_SCANCODE_NUM 0x45
#define KBD_SCANCODE_SCRL 0x46
#define KBD_SCANCODE_HOME 0x47
#define KBD_SCANCODE_UP 0x48
#define KBD_SCANCODE_PGUP 0x49
#define KBD_SCANCODE_NUMMINUS 0x4A
#define KBD_SCANCODE_LEFT 0x4B
#define KBD_SCANCODE_CENTER 0x4C
#define KBD_SCANCODE_RIGHT 0x4D
#define KBD_SCANCODE_PLUS 0x4E
#define KBD_SCANCODE_END 0x4F
#define KBD_SCANCODE_DOWN 0x50
#define KBD_SCANCODE_PGDN 0x51
#define KBD_SCANCODE_INS 0x52
#define KBD_SCANCODE_DEL 0x53
#define KBD_SCANCODE_UNDEF1 0x54
#define KBD_SCANCODE_UNDEF2 0x55
#define KBD_SCANCODE_UNDEF3 0x56
#define KBD_SCANCODE_F11 0x57
#define KBD_SCANCODE_F12 0x58
#define KBD_SCANCODE_LWINDOW 0x5B // always prefixed with 0xE0
#define KBD_SCANCODE_RWINDOW 0x5C // always prefixed with 0xE0
#define KBD_SCANCODE_MENU 0x5D // always prefixed with 0xE0
#define EMERGENCY_REBOOT_CODE 0x532e
#define MANUAL_GAMBIT_INTERRUPT_CODE 0x1749
#define IS_VISIBLE_CHAR(c) (((c) >= 0x20) && ((c) <= 0x7E))
#define IS_NEWLINE(c) (((c) == '\r') || ((c) == '\n'))
#define IS_DEL(c) ((c) == 127)
#define ASCII_BACKSPACE 0x08
error_code setup_ps2();
unicode_char getchar();
int getchar0(bool blocking);
#endif
// Local Variables: //
// mode: C++ //
// End: //