xref: /illumos-gate/usr/src/uts/common/sys/usb/usb_mid/usb_midvar.h (revision 2d6eb4a5e0a47d30189497241345dc5466bb68ab)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_USB_USB_MIDVAR_H
27 #define	_SYS_USB_USB_MIDVAR_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/usb/usba/usbai_private.h>
34 
35 
36 /*
37  * soft	state information for this usb_mid
38  */
39 typedef struct usb_mid {
40 	int			mi_instance;
41 
42 	uint_t			mi_init_state;
43 	uint_t			mi_ugen_open_count;
44 
45 	kmutex_t		mi_mutex;
46 
47 	/*
48 	 * dev_info_t reference
49 	 */
50 	dev_info_t		*mi_dip;
51 
52 	/* pointer to usb_common_power_t */
53 	usb_common_power_t	*mi_pm;
54 
55 	/*
56 	 * save the usba_device pointer
57 	 */
58 	usba_device_t		*mi_usba_device;
59 
60 	int			mi_softstate;
61 
62 	int			mi_dev_state;
63 
64 	int			mi_n_ifs;
65 
66 	/* track event registration of children */
67 	uint8_t			*mi_child_events;
68 
69 	/* record the interface num of each child node */
70 	uint_t			*mi_children_ifs;
71 
72 	/*
73 	 * mi_children_dips is an array for holding
74 	 * each child dip indexed by interface number
75 	 */
76 	dev_info_t		**mi_children_dips;
77 
78 	boolean_t		mi_removed_children;
79 
80 	size_t			mi_cd_list_length;
81 	int			mi_attach_count;
82 
83 	/* logging of messages */
84 	usb_log_handle_t	mi_log_handle;
85 
86 	/* usb registration */
87 	usb_client_dev_data_t	*mi_dev_data;
88 
89 	/* event support */
90 	ndi_event_hdl_t		mi_ndi_event_hdl;
91 
92 	/* ugen support */
93 	usb_ugen_hdl_t		mi_ugen_hdl;
94 
95 } usb_mid_t;
96 
97 _NOTE(MUTEX_PROTECTS_DATA(usb_mid::mi_mutex, usb_mid))
98 _NOTE(MUTEX_PROTECTS_DATA(usb_mid::mi_mutex, usb_common_power_t))
99 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_mid::mi_instance
100 		usb_mid::mi_ndi_event_hdl
101 		usb_mid::mi_dev_data
102 		usb_mid::mi_log_handle
103 		usb_mid::mi_ugen_hdl
104 		usb_mid::mi_dip
105 		usb_mid::mi_pm))
106 
107 #define	USB_MID_MINOR_UGEN_BITS_MASK	0x1ff
108 #define	USB_MID_MINOR_INSTANCE_SHIFT	9
109 #define	USB_MID_MINOR_INSTANCE_MASK	~USB_MID_MINOR_UGEN_BITS_MASK
110 #define	USB_MID_MINOR_TO_INSTANCE(minor) \
111 		(((minor) & USB_MID_MINOR_INSTANCE_MASK) >> \
112 		USB_MID_MINOR_INSTANCE_SHIFT)
113 
114 /* init state */
115 #define	USB_MID_LOCK_INIT		0x0001
116 #define	USB_MID_MINOR_NODE_CREATED	0x0002
117 #define	USB_MID_EVENTS_REGISTERED	0x0004
118 
119 /* Tracking events registered by children */
120 #define	USB_MID_CHILD_EVENT_DISCONNECT	0x01
121 #define	USB_MID_CHILD_EVENT_PRESUSPEND	0x02
122 
123 /*
124  * Debug printing
125  * Masks
126  */
127 #define	DPRINT_MASK_ATTA	0x00000001
128 #define	DPRINT_MASK_CBOPS	0x00000002
129 #define	DPRINT_MASK_EVENTS	0x00000004
130 #define	DPRINT_MASK_DUMPING	0x00000008	/* usb_mid dump mask */
131 #define	DPRINT_MASK_PM		0x00000010
132 #define	DPRINT_MASK_ALL 	0xFFFFFFFF
133 
134 
135 #ifdef	__cplusplus
136 }
137 #endif
138 
139 #endif	/* _SYS_USB_USB_MIDVAR_H */
140