xref: /onnv-gate/usr/src/uts/common/sys/usb/usb_mid/usb_midvar.h (revision 3341:52e5b1750941)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*3341Sgc161489  * Common Development and Distribution License (the "License").
6*3341Sgc161489  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
20*3341Sgc161489  */
21*3341Sgc161489 /*
22*3341Sgc161489  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_USB_USB_MIDVAR_H
270Sstevel@tonic-gate #define	_SYS_USB_USB_MIDVAR_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifdef	__cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include <sys/usb/usba/usbai_private.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate 
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate  * soft	state information for this usb_mid
400Sstevel@tonic-gate  */
410Sstevel@tonic-gate typedef struct usb_mid {
420Sstevel@tonic-gate 	int			mi_instance;
430Sstevel@tonic-gate 
440Sstevel@tonic-gate 	uint_t			mi_init_state;
450Sstevel@tonic-gate 	uint_t			mi_ugen_open_count;
460Sstevel@tonic-gate 
470Sstevel@tonic-gate 	kmutex_t		mi_mutex;
480Sstevel@tonic-gate 
490Sstevel@tonic-gate 	/*
500Sstevel@tonic-gate 	 * dev_info_t reference
510Sstevel@tonic-gate 	 */
520Sstevel@tonic-gate 	dev_info_t		*mi_dip;
530Sstevel@tonic-gate 
54*3341Sgc161489 	/* pointer to usb_common_power_t */
55*3341Sgc161489 	usb_common_power_t	*mi_pm;
560Sstevel@tonic-gate 
570Sstevel@tonic-gate 	/*
580Sstevel@tonic-gate 	 * save the usba_device pointer
590Sstevel@tonic-gate 	 */
600Sstevel@tonic-gate 	usba_device_t		*mi_usba_device;
610Sstevel@tonic-gate 
620Sstevel@tonic-gate 	int			mi_softstate;
630Sstevel@tonic-gate 
640Sstevel@tonic-gate 	int			mi_dev_state;
650Sstevel@tonic-gate 
660Sstevel@tonic-gate 	int			mi_n_ifs;
670Sstevel@tonic-gate 
680Sstevel@tonic-gate 	/* track event registration of children */
690Sstevel@tonic-gate 	uint8_t			*mi_child_events;
70*3341Sgc161489 
71*3341Sgc161489 	/* record the interface num of each child node */
72*3341Sgc161489 	uint_t			*mi_children_ifs;
73*3341Sgc161489 
740Sstevel@tonic-gate 	/*
75*3341Sgc161489 	 * mi_children_dips is an array for holding
760Sstevel@tonic-gate 	 * each child dip indexed by interface number
770Sstevel@tonic-gate 	 */
780Sstevel@tonic-gate 	dev_info_t		**mi_children_dips;
79*3341Sgc161489 
800Sstevel@tonic-gate 	boolean_t		mi_removed_children;
810Sstevel@tonic-gate 
820Sstevel@tonic-gate 	size_t			mi_cd_list_length;
830Sstevel@tonic-gate 	int			mi_attach_count;
840Sstevel@tonic-gate 
850Sstevel@tonic-gate 	/* logging of messages */
860Sstevel@tonic-gate 	usb_log_handle_t	mi_log_handle;
870Sstevel@tonic-gate 
880Sstevel@tonic-gate 	/* usb registration */
890Sstevel@tonic-gate 	usb_client_dev_data_t	*mi_dev_data;
900Sstevel@tonic-gate 
910Sstevel@tonic-gate 	/* event support */
920Sstevel@tonic-gate 	ndi_event_hdl_t		mi_ndi_event_hdl;
930Sstevel@tonic-gate 
940Sstevel@tonic-gate 	/* ugen support */
950Sstevel@tonic-gate 	usb_ugen_hdl_t		mi_ugen_hdl;
960Sstevel@tonic-gate 
970Sstevel@tonic-gate } usb_mid_t;
980Sstevel@tonic-gate 
990Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(usb_mid::mi_mutex, usb_mid))
100*3341Sgc161489 _NOTE(MUTEX_PROTECTS_DATA(usb_mid::mi_mutex, usb_common_power_t))
1010Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_mid::mi_instance
1020Sstevel@tonic-gate 		usb_mid::mi_ndi_event_hdl
1030Sstevel@tonic-gate 		usb_mid::mi_dev_data
1040Sstevel@tonic-gate 		usb_mid::mi_log_handle
1050Sstevel@tonic-gate 		usb_mid::mi_ugen_hdl
1060Sstevel@tonic-gate 		usb_mid::mi_dip
1070Sstevel@tonic-gate 		usb_mid::mi_pm))
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate #define	USB_MID_MINOR_UGEN_BITS_MASK	0x1ff
1100Sstevel@tonic-gate #define	USB_MID_MINOR_INSTANCE_SHIFT	9
1110Sstevel@tonic-gate #define	USB_MID_MINOR_INSTANCE_MASK	~USB_MID_MINOR_UGEN_BITS_MASK
1120Sstevel@tonic-gate #define	USB_MID_MINOR_TO_INSTANCE(minor) \
1130Sstevel@tonic-gate 		(((minor) & USB_MID_MINOR_INSTANCE_MASK) >> \
1140Sstevel@tonic-gate 		USB_MID_MINOR_INSTANCE_SHIFT)
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate /* init state */
1170Sstevel@tonic-gate #define	USB_MID_LOCK_INIT		0x0001
1180Sstevel@tonic-gate #define	USB_MID_MINOR_NODE_CREATED	0x0002
1190Sstevel@tonic-gate #define	USB_MID_EVENTS_REGISTERED	0x0004
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate /* Tracking events registered by children */
1220Sstevel@tonic-gate #define	USB_MID_CHILD_EVENT_DISCONNECT	0x01
1230Sstevel@tonic-gate #define	USB_MID_CHILD_EVENT_PRESUSPEND	0x02
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate /*
1260Sstevel@tonic-gate  * Debug printing
1270Sstevel@tonic-gate  * Masks
1280Sstevel@tonic-gate  */
1290Sstevel@tonic-gate #define	DPRINT_MASK_ATTA	0x00000001
1300Sstevel@tonic-gate #define	DPRINT_MASK_CBOPS	0x00000002
1310Sstevel@tonic-gate #define	DPRINT_MASK_EVENTS	0x00000004
1320Sstevel@tonic-gate #define	DPRINT_MASK_DUMPING	0x00000008	/* usb_mid dump mask */
1330Sstevel@tonic-gate #define	DPRINT_MASK_PM		0x00000010
1340Sstevel@tonic-gate #define	DPRINT_MASK_ALL 	0xFFFFFFFF
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate #ifdef	__cplusplus
1380Sstevel@tonic-gate }
1390Sstevel@tonic-gate #endif
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate #endif	/* _SYS_USB_USB_MIDVAR_H */
142