xref: /minix3/minix/include/minix/devman.h (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc #ifndef MINIX_LIBDEVMAN_H
2*433d6423SLionel Sambuc #define MINIX_LIBDEVMAN_H
3*433d6423SLionel Sambuc #include <minix/com.h>
4*433d6423SLionel Sambuc #include <minix/ipc.h>
5*433d6423SLionel Sambuc #include <minix/usb_ch9.h>
6*433d6423SLionel Sambuc 
7*433d6423SLionel Sambuc /* used for serializing */
8*433d6423SLionel Sambuc struct devman_device_info {
9*433d6423SLionel Sambuc 	int count;
10*433d6423SLionel Sambuc 	int parent_dev_id;
11*433d6423SLionel Sambuc 	unsigned name_offset;
12*433d6423SLionel Sambuc 	unsigned subsystem_offset;
13*433d6423SLionel Sambuc };
14*433d6423SLionel Sambuc 
15*433d6423SLionel Sambuc struct devman_device_info_entry {
16*433d6423SLionel Sambuc 	unsigned type;
17*433d6423SLionel Sambuc 	unsigned name_offset;
18*433d6423SLionel Sambuc 	unsigned data_offset;
19*433d6423SLionel Sambuc 	unsigned req_nr;
20*433d6423SLionel Sambuc };
21*433d6423SLionel Sambuc 
22*433d6423SLionel Sambuc #ifndef DEVMAN_SERVER
23*433d6423SLionel Sambuc struct devman_usb_bind_cb_data {
24*433d6423SLionel Sambuc 	int dev_id;
25*433d6423SLionel Sambuc 	int interface;
26*433d6423SLionel Sambuc };
27*433d6423SLionel Sambuc 
28*433d6423SLionel Sambuc struct devman_usb_interface {
29*433d6423SLionel Sambuc 	struct devman_dev *dev;
30*433d6423SLionel Sambuc 	struct devman_usb_dev *usb_dev;
31*433d6423SLionel Sambuc 	usb_interface_descriptor_t *desc;
32*433d6423SLionel Sambuc 	/* used by the lib */
33*433d6423SLionel Sambuc 	struct devman_usb_bind_cb_data cb_data;
34*433d6423SLionel Sambuc };
35*433d6423SLionel Sambuc 
36*433d6423SLionel Sambuc struct devman_usb_dev {
37*433d6423SLionel Sambuc 	struct devman_dev *dev;
38*433d6423SLionel Sambuc 	int    dev_id;            /* The ID identifying the device
39*433d6423SLionel Sambuc 									 on server side */
40*433d6423SLionel Sambuc 	usb_device_descriptor_t *desc;
41*433d6423SLionel Sambuc 
42*433d6423SLionel Sambuc 	int    configuration;        /* the configuration used for this
43*433d6423SLionel Sambuc 	                                device */
44*433d6423SLionel Sambuc 
45*433d6423SLionel Sambuc 	char   *manufacturer;
46*433d6423SLionel Sambuc 	char   *product;
47*433d6423SLionel Sambuc 	char   *serial;
48*433d6423SLionel Sambuc 
49*433d6423SLionel Sambuc 	int    intf_count;          /* the number of interfaces in the current
50*433d6423SLionel Sambuc 	                               configuration */
51*433d6423SLionel Sambuc 
52*433d6423SLionel Sambuc 	struct devman_usb_interface interfaces[32];
53*433d6423SLionel Sambuc 	/* used by the lib */
54*433d6423SLionel Sambuc 	struct devman_usb_bind_cb_data cb_data;
55*433d6423SLionel Sambuc };
56*433d6423SLionel Sambuc 
57*433d6423SLionel Sambuc typedef int (*devman_usb_bind_cb_t)(struct devman_usb_bind_cb_data *data, endpoint_t ep);
58*433d6423SLionel Sambuc 
59*433d6423SLionel Sambuc int devman_add_device(struct devman_dev *dev);
60*433d6423SLionel Sambuc int devman_del_device(struct devman_dev *dev);
61*433d6423SLionel Sambuc int devman_init(void);
62*433d6423SLionel Sambuc struct devman_usb_dev* devman_usb_device_new(int dev_id);
63*433d6423SLionel Sambuc int devman_usb_device_add(struct devman_usb_dev *dev);
64*433d6423SLionel Sambuc int devman_usb_device_remove(struct devman_usb_dev *dev);
65*433d6423SLionel Sambuc void devman_usb_device_delete(struct devman_usb_dev *udev);
66*433d6423SLionel Sambuc int devman_handle_msg(message *m);
67*433d6423SLionel Sambuc void devman_usb_init(devman_usb_bind_cb_t bind_cb, devman_usb_bind_cb_t
68*433d6423SLionel Sambuc 	unbind_cb);
69*433d6423SLionel Sambuc 
70*433d6423SLionel Sambuc #endif
71*433d6423SLionel Sambuc 
72*433d6423SLionel Sambuc #endif
73