xref: /haiku/src/add-ons/kernel/bus_managers/ps2/ps2_defs.h (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
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_MOUSE_SET_SCALE11		0xe6
52 #define PS2_CMD_MOUSE_SET_SCALE21		0xe7
53 #define PS2_CMD_MOUSE_SET_RES			0xe8
54 #define PS2_CMD_MOUSE_GET_INFO			0xe9
55 #define PS2_CMD_MOUSE_SET_STREAM  		0xea
56 #define PS2_CMD_KEYBOARD_SET_LEDS		0xed
57 #define PS2_CMD_MOUSE_SET_POLL			0xf0
58 #define PS2_CMD_SET_TYPEMATIC			0xf3
59 #define PS2_CMD_ECHO					0xee
60 #define PS2_CMD_TEST_PASSED				0xaa
61 #define PS2_CMD_GET_DEVICE_ID			0xf2
62 #define PS2_CMD_SET_SAMPLE_RATE			0xf3
63 #define PS2_CMD_ENABLE					0xf4
64 #define PS2_CMD_DISABLE					0xf5
65 #define PS2_CMD_MOUSE_RESET_DIS			0xf6
66 #define PS2_CMD_RESET					0xff
67 #define PS2_CMD_RESEND					0xfe
68 
69 // reply codes
70 #define PS2_REPLY_TEST_PASSED			0x55
71 #define PS2_REPLY_ACK					0xfa
72 #define PS2_REPLY_RESEND				0xfe
73 #define PS2_REPLY_ERROR					0xfc
74 
75 // interrupts
76 #define INT_PS2_MOUSE					0x0c
77 #define INT_PS2_KEYBOARD				0x01
78 
79 // mouse device IDs
80 #define PS2_DEV_ID_STANDARD				0
81 #define PS2_DEV_ID_INTELLIMOUSE			3
82 #define PS2_DEV_ID_TOUCHPAD_RICATECH	4
83 
84 // packet sizes
85 #define PS2_PACKET_STANDARD				3
86 #define PS2_PACKET_INTELLIMOUSE			4
87 #define PS2_PACKET_SYNAPTICS			6
88 #define PS2_PACKET_ALPS					6
89 #define PS2_PACKET_ELANTECH				6	// version 1 is only 4
90 #define PS2_MAX_PACKET_SIZE				6
91 	// Should be equal to the biggest packet size
92 
93 // timeouts
94 #define PS2_CTRL_WAIT_TIMEOUT			500000
95 
96 #endif /* _PS2_H */
97