xref: /titanic_44/usr/src/uts/common/sys/usb/usb_mid/usb_midvar.h (revision d73ae94e59c019f5cc3221ee0a0012d02091b40e)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/usb/usba/usbai_private.h>
36 
37 
38 /*
39  * soft	state information for this usb_mid
40  */
41 typedef struct usb_mid {
42 	int			mi_instance;
43 
44 	uint_t			mi_init_state;
45 	uint_t			mi_ugen_open_count;
46 
47 	kmutex_t		mi_mutex;
48 
49 	/*
50 	 * dev_info_t reference
51 	 */
52 	dev_info_t		*mi_dip;
53 
54 	/* pointer to usb_common_power_t */
55 	usb_common_power_t	*mi_pm;
56 
57 	/*
58 	 * save the usba_device pointer
59 	 */
60 	usba_device_t		*mi_usba_device;
61 
62 	int			mi_softstate;
63 
64 	int			mi_dev_state;
65 
66 	int			mi_n_ifs;
67 
68 	/* track event registration of children */
69 	uint8_t			*mi_child_events;
70 
71 	/* record the interface num of each child node */
72 	uint_t			*mi_children_ifs;
73 
74 	/*
75 	 * mi_children_dips is an array for holding
76 	 * each child dip indexed by interface number
77 	 */
78 	dev_info_t		**mi_children_dips;
79 
80 	boolean_t		mi_removed_children;
81 
82 	size_t			mi_cd_list_length;
83 	int			mi_attach_count;
84 
85 	/* logging of messages */
86 	usb_log_handle_t	mi_log_handle;
87 
88 	/* usb registration */
89 	usb_client_dev_data_t	*mi_dev_data;
90 
91 	/* event support */
92 	ndi_event_hdl_t		mi_ndi_event_hdl;
93 
94 	/* ugen support */
95 	usb_ugen_hdl_t		mi_ugen_hdl;
96 
97 } usb_mid_t;
98 
99 _NOTE(MUTEX_PROTECTS_DATA(usb_mid::mi_mutex, usb_mid))
100 _NOTE(MUTEX_PROTECTS_DATA(usb_mid::mi_mutex, usb_common_power_t))
101 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_mid::mi_instance
102 		usb_mid::mi_ndi_event_hdl
103 		usb_mid::mi_dev_data
104 		usb_mid::mi_log_handle
105 		usb_mid::mi_ugen_hdl
106 		usb_mid::mi_dip
107 		usb_mid::mi_pm))
108 
109 #define	USB_MID_MINOR_UGEN_BITS_MASK	0x1ff
110 #define	USB_MID_MINOR_INSTANCE_SHIFT	9
111 #define	USB_MID_MINOR_INSTANCE_MASK	~USB_MID_MINOR_UGEN_BITS_MASK
112 #define	USB_MID_MINOR_TO_INSTANCE(minor) \
113 		(((minor) & USB_MID_MINOR_INSTANCE_MASK) >> \
114 		USB_MID_MINOR_INSTANCE_SHIFT)
115 
116 /* init state */
117 #define	USB_MID_LOCK_INIT		0x0001
118 #define	USB_MID_MINOR_NODE_CREATED	0x0002
119 #define	USB_MID_EVENTS_REGISTERED	0x0004
120 
121 /* Tracking events registered by children */
122 #define	USB_MID_CHILD_EVENT_DISCONNECT	0x01
123 #define	USB_MID_CHILD_EVENT_PRESUSPEND	0x02
124 
125 /*
126  * Debug printing
127  * Masks
128  */
129 #define	DPRINT_MASK_ATTA	0x00000001
130 #define	DPRINT_MASK_CBOPS	0x00000002
131 #define	DPRINT_MASK_EVENTS	0x00000004
132 #define	DPRINT_MASK_DUMPING	0x00000008	/* usb_mid dump mask */
133 #define	DPRINT_MASK_PM		0x00000010
134 #define	DPRINT_MASK_ALL 	0xFFFFFFFF
135 
136 
137 #ifdef	__cplusplus
138 }
139 #endif
140 
141 #endif	/* _SYS_USB_USB_MIDVAR_H */
142