xref: /haiku/src/add-ons/kernel/bus_managers/ps2/ps2_dev.h (revision ce8185b383eb2d071a486a0bfd50364f6037d3e7)
1d61a52a7SMarcus Overhagen /*
2*ce8185b3SMarcus Overhagen  * Copyright 2005-2007 Haiku, Inc.
3d61a52a7SMarcus Overhagen  * Distributed under the terms of the MIT License.
4d61a52a7SMarcus Overhagen  *
5*ce8185b3SMarcus Overhagen  * PS/2 bus manager
6d61a52a7SMarcus Overhagen  *
7d61a52a7SMarcus Overhagen  * Authors (in chronological order):
8d61a52a7SMarcus Overhagen  *		Marcus Overhagen (marcus@overhagen.de)
9d61a52a7SMarcus Overhagen  */
10d61a52a7SMarcus Overhagen #ifndef __PS2_DEV_H
11d61a52a7SMarcus Overhagen #define __PS2_DEV_H
12d61a52a7SMarcus Overhagen 
13dfd5628dSMarcus Overhagen struct ps2_dev;
14dfd5628dSMarcus Overhagen typedef struct ps2_dev ps2_dev;
15dfd5628dSMarcus Overhagen 
16487f6591SMarcus Overhagen #include "ps2_common.h"
17d61a52a7SMarcus Overhagen 
18f9ff1193SMarcus Overhagen typedef struct
19f9ff1193SMarcus Overhagen {
20f9ff1193SMarcus Overhagen 	bigtime_t		time;
21f9ff1193SMarcus Overhagen 	uint8			data;
2245d3c4ecSMarcus Overhagen 	bool			error;
23f9ff1193SMarcus Overhagen } data_history;
24dfd5628dSMarcus Overhagen 
25dfd5628dSMarcus Overhagen struct ps2_dev
26d61a52a7SMarcus Overhagen {
27d61a52a7SMarcus Overhagen 	const char *	name;
28d61a52a7SMarcus Overhagen 	bool			active;
29d61a52a7SMarcus Overhagen 	uint32			flags;
3003d0d41aSMarcus Overhagen 	uint8           idx;
31d61a52a7SMarcus Overhagen 	sem_id			result_sem;
32d61a52a7SMarcus Overhagen 	uint8 *			result_buf;
33d61a52a7SMarcus Overhagen 	int				result_buf_idx;
34d61a52a7SMarcus Overhagen 	int				result_buf_cnt;
35dfd5628dSMarcus Overhagen 	void *			cookie;
3645d3c4ecSMarcus Overhagen 	data_history	history[2];
37130a1761SMarcus Overhagen 
38130a1761SMarcus Overhagen // functions
39130a1761SMarcus Overhagen 	void          (*disconnect)(ps2_dev *);
40f9ff1193SMarcus Overhagen 	int32		  (*handle_int)(ps2_dev *);
41dfd5628dSMarcus Overhagen };
42d61a52a7SMarcus Overhagen 
43395817e3SMarcus Overhagen #define PS2_DEVICE_COUNT 5
44395817e3SMarcus Overhagen 
45395817e3SMarcus Overhagen extern ps2_dev ps2_device[PS2_DEVICE_COUNT];
46d61a52a7SMarcus Overhagen 
47d61a52a7SMarcus Overhagen #define PS2_DEVICE_MOUSE 0
48d61a52a7SMarcus Overhagen #define PS2_DEVICE_KEYB  4
49d61a52a7SMarcus Overhagen 
50dfd5628dSMarcus Overhagen #define PS2_FLAG_KEYB		(1<<0)
51dfd5628dSMarcus Overhagen #define PS2_FLAG_OPEN		(1<<1)
52dfd5628dSMarcus Overhagen #define PS2_FLAG_ENABLED	(1<<2)
53dfd5628dSMarcus Overhagen #define PS2_FLAG_CMD		(1<<3)
54dfd5628dSMarcus Overhagen #define PS2_FLAG_ACK		(1<<4)
55dfd5628dSMarcus Overhagen #define PS2_FLAG_NACK		(1<<5)
56a9e8a72aSMarcus Overhagen #define PS2_FLAG_GETID		(1<<6)
57d61a52a7SMarcus Overhagen 
58d61a52a7SMarcus Overhagen status_t	ps2_dev_init(void);
59d61a52a7SMarcus Overhagen void		ps2_dev_exit(void);
60d61a52a7SMarcus Overhagen 
6103d0d41aSMarcus Overhagen status_t	ps2_dev_command(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count);
6203d0d41aSMarcus Overhagen 
6303d0d41aSMarcus Overhagen 
64d61a52a7SMarcus Overhagen void		ps2_dev_publish(ps2_dev *dev);
65d61a52a7SMarcus Overhagen void		ps2_dev_unpublish(ps2_dev *dev);
66d61a52a7SMarcus Overhagen 
6745d3c4ecSMarcus Overhagen int32		ps2_dev_handle_int(ps2_dev *dev);
68d61a52a7SMarcus Overhagen 
69d61a52a7SMarcus Overhagen #endif
70