xref: /haiku/src/add-ons/kernel/bus_managers/ps2/ps2_defs.h (revision 820dca4df6c7bf955c46e8f6521b9408f50b2900)
1 /*
2  * Copyright 2004-2005 Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  *
5  * PS/2 interface definitions
6  *
7  * Authors (in chronological order):
8  *		Elad Lahav (elad@eldarshany.com)
9  *		Stefano Ceccherini (burton666@libero.it)
10  *		Axel Dörfler, axeld@pinc-software.de
11  */
12 #ifndef _PS2_DEFS_H
13 #define _PS2_DEFS_H
14 
15 
16 /** Interface definitions for the Intel 8042, 8741, or 8742 (PS/2) */
17 
18 // I/O addresses
19 #define PS2_PORT_DATA					0x60
20 #define PS2_PORT_CTRL					0x64
21 
22 // data port bits
23 #define PS2_STATUS_OUTPUT_BUFFER_FULL	0x01
24 #define PS2_STATUS_INPUT_BUFFER_FULL	0x02
25 #define PS2_STATUS_AUX_DATA				0x20
26 #define PS2_STATUS_TIMEOUT				0x40
27 
28 // control words
29 #define PS2_CTRL_READ_CMD				0x20
30 #define PS2_CTRL_WRITE_CMD				0x60
31 #define PS2_CTRL_WRITE_AUX				0xd4
32 #define PS2_CTRL_MOUSE_DISABLE			0xa7
33 #define PS2_CTRL_MOUSE_ENABLE			0xa8
34 #define PS2_CTRL_MOUSE_TEST				0xa9
35 #define PS2_CTRL_SELF_TEST				0xaa
36 #define PS2_CTRL_KEYBOARD_TEST			0xab
37 #define PS2_CTRL_KEYBOARD_ACTIVATE		0xae
38 #define PS2_CTRL_KEYBOARD_DEACTIVATE	0xad
39 
40 // command bytes
41 #define PS2_CMD_DEV_INIT				0x43
42 
43 // command bits
44 #define PS2_BITS_KEYBOARD_INTERRUPT		0x01
45 #define PS2_BITS_AUX_INTERRUPT			0x02
46 #define PS2_BITS_KEYBOARD_DISABLED		0x10
47 #define PS2_BITS_MOUSE_DISABLED			0x20
48 #define PS2_BITS_TRANSLATE_SCANCODES	0x40
49 
50 // data words
51 #define PS2_CMD_KEYBOARD_SET_LEDS		0xed
52 #define PS2_CMD_KEYBOARD_SET_TYPEMATIC	0xf3
53 #define PS2_CMD_ECHO					0xee
54 #define PS2_CMD_TEST_PASSED				0xaa
55 #define PS2_CMD_GET_DEVICE_ID			0xf2
56 #define PS2_CMD_SET_SAMPLE_RATE			0xf3
57 #define PS2_CMD_ENABLE					0xf4
58 #define PS2_CMD_DISABLE					0xf5
59 #define PS2_CMD_RESET					0xff
60 #define PS2_CMD_RESEND					0xfe
61 
62 // reply codes
63 #define PS2_REPLY_TEST_PASSED			0x55
64 #define PS2_REPLY_ACK					0xfa
65 #define PS2_REPLY_RESEND				0xfe
66 #define PS2_REPLY_ERROR					0xfc
67 
68 // interrupts
69 #define INT_PS2_MOUSE					0x0c
70 #define INT_PS2_KEYBOARD				0x01
71 
72 // mouse device IDs
73 #define PS2_DEV_ID_STANDARD				0
74 #define PS2_DEV_ID_INTELLIMOUSE			3
75 #define PS2_DEV_ID_TOUCHPAD_RICATECH	4
76 
77 // packet sizes
78 #define PS2_PACKET_STANDARD				3
79 #define PS2_PACKET_INTELLIMOUSE			4
80 #define PS2_PACKET_SYNAPTICS			6
81 #define PS2_PACKET_ALPS					6
82 #define PS2_MAX_PACKET_SIZE				6
83 	// Should be equal to the biggest packet size
84 
85 // timeouts
86 #define PS2_CTRL_WAIT_TIMEOUT			500000
87 
88 #endif /* _PS2_H */
89