xref: /haiku/src/add-ons/kernel/bus_managers/ps2/ps2_defs.h (revision 58481f0f6ef1a61ba07283f012cafbc2ed874ead)
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 
61 // reply codes
62 #define PS2_REPLY_TEST_PASSED			0x55
63 #define PS2_REPLY_ACK					0xfa
64 #define PS2_REPLY_RESEND				0xfe
65 #define PS2_REPLY_ERROR					0xfc
66 
67 // interrupts
68 #define INT_PS2_MOUSE					0x0c
69 #define INT_PS2_KEYBOARD				0x01
70 
71 // mouse device IDs
72 #define PS2_DEV_ID_STANDARD				0
73 #define PS2_DEV_ID_INTELLIMOUSE			3
74 
75 // packet sizes
76 #define PS2_PACKET_STANDARD				3
77 #define PS2_PACKET_INTELLIMOUSE			4
78 #define PS2_PACKET_SYNAPTICS			6
79 #define PS2_MAX_PACKET_SIZE				6
80 	// Should be equal to the biggest packet size
81 
82 // timeouts
83 #define PS2_CTRL_WAIT_TIMEOUT			500000
84 
85 #endif /* _PS2_H */
86