i8042prt driver by tinus.
[reactos.git] / reactos / drivers / input / kbdclass / kbdclass.h
1 #ifndef _KEYBOARD_H_
2 #define _KEYBOARD_H_
3 #include <ddk/ntddkbd.h>
4 #include <ddk/ntdd8042.h>
5
6 #define KBD_BUFFER_SIZE 32
7 #define KBD_WRAP_MASK 0x1F
8
9 /*-----------------------------------------------------
10 * DeviceExtension
11 * --------------------------------------------------*/
12 typedef struct _DEVICE_EXTENSION
13 {
14 PDEVICE_OBJECT I8042Device;
15 PDEVICE_OBJECT DeviceObject;
16
17 KEYBOARD_INPUT_DATA KbdBuffer[KBD_BUFFER_SIZE];
18 int BufHead,BufTail;
19 int KeysInBuffer;
20
21 BOOLEAN AlreadyOpened;
22 } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
23
24 typedef struct _CONNECT_DATA {
25 PDEVICE_OBJECT ClassDeviceObject;
26 PVOID ClassService;
27 } CONNECT_DATA, *PCONNECT_DATA;
28
29 /*
30 * Some defines
31 */
32
33 #define IOCTL_INTERNAL_KEYBOARD_CONNECT \
34 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0080, METHOD_NEITHER, FILE_ANY_ACCESS)
35
36 #define KEYBOARD_IRQ 1
37
38 #define disable() __asm__("cli\n\t")
39 #define enable() __asm__("sti\n\t")
40
41 #define ALT_PRESSED (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)
42 #define CTRL_PRESSED (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)
43
44
45 /*
46 * Keyboard controller ports
47 */
48
49 #define KBD_DATA_PORT 0x60
50 #define KBD_CTRL_PORT 0x64
51
52
53 /*
54 * Controller commands
55 */
56
57 #define KBD_READ_MODE 0x20
58 #define KBD_WRITE_MODE 0x60
59 #define KBD_SELF_TEST 0xAA
60 #define KBD_LINE_TEST 0xAB
61 #define KBD_CTRL_ENABLE 0xAE
62
63 /*
64 * Keyboard commands
65 */
66
67 #define KBD_ENABLE 0xF4
68 #define KBD_DISABLE 0xF5
69 #define KBD_RESET 0xFF
70
71
72 /*
73 * Keyboard responces
74 */
75
76 #define KBD_ACK 0xFA
77 #define KBD_BATCC 0xAA
78
79
80 /*
81 * Controller status register bits
82 */
83
84 #define KBD_OBF 0x01
85 #define KBD_IBF 0x02
86 #define KBD_GTO 0x40
87 #define KBD_PERR 0x80
88
89
90 /*
91 * LED bits
92 */
93
94 #define KBD_LED_SCROLL 0x01
95 #define KBD_LED_NUM 0x02
96 #define KBD_LED_CAPS 0x04
97
98 #endif // _KEYBOARD_H_