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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_USB_REGISTER_IMPL_H
27 #define	_SYS_USB_REGISTER_IMPL_H
28 
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /* For binary dump function */
35 #define	BINDUMP_BYTES_PER_LINE	16 /* For binary dump of class/vendor descr */
36 #define	INDENT_SPACE_STR	"    " /* Spaces for indentation */
37 #define	SPACES_PER_INDENT	(strlen(INDENT_SPACE_STR) - 1)
38 
39 #define	USBA_ALL	-1			/* Build all */
40 
41 /* State of the tree-building process */
42 typedef struct usba_reg_state {
43 	dev_info_t	*dip;			/* Dev info pointer */
44 	usb_cfg_data_t	*st_curr_cfg;	/* Current cfg being init'ed */
45 	usb_if_data_t	*st_curr_if;		/* Current if being init'ed */
46 	usb_alt_if_data_t *st_curr_alt;	/* Current alt being init'ed */
47 	usb_ep_data_t	*st_curr_ep;		/* Current ep being init'ed */
48 	int		st_last_processed_descr_type; /* Type of last descr */
49 					    /* processed for placing c/vs */
50 	int		st_if_to_build;		/* Interface to build */
51 	int		st_cfg_to_build;	/* Configuration to build */
52 	int		st_total_cfg_length;	/* Len of all descriptors */
53 						/* for the current config */
54 	uchar_t 	*st_curr_raw_descr;	/* Ptr to raw curr descr */
55 	uchar_t 	st_curr_raw_descr_type;    /* Type of curr descr */
56 	uchar_t 	st_curr_raw_descr_len;    /* Length of curr descr */
57 	char		*st_curr_cfg_str;    /* Cfg string from usba_device */
58 	usb_reg_parse_lvl_t st_dev_parse_level;	/* All, curr cfg, 1 iface */
59 	usb_cfg_data_t	*st_dev_cfg;		/* Cfg array, root of tree */
60 	uint_t		st_dev_n_cfg;		/* Number cfgs in tree */
61 	boolean_t	st_build_ep_comp;	/* for wusb only */
62 } usba_reg_state_t;
63 
64 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only", usb_cvs_data))
65 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only", usb_ep_data))
66 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only", usb_alt_if_data))
67 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only", usb_if_data))
68 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only", usb_cfg_data))
69 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only", usba_reg_state))
70 
71 
72 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
73 					usb_client_dev_data::dev_cfg))
74 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
75 					usb_client_dev_data::dev_curr_cfg))
76 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
77 					usb_client_dev_data::dev_n_cfg))
78 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
79 					usb_client_dev_data::dev_parse_level))
80 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
81 					usb_client_dev_data::dev_curr_if))
82 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
83 					usb_client_dev_data::dev_default_ph))
84 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
85 					usb_client_dev_data::dev_descr))
86 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
87 					usb_client_dev_data::dev_bos))
88 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
89 					usb_client_dev_data::dev_iblock_cookie))
90 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
91 					usb_client_dev_data::dev_mfg))
92 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
93 					usb_client_dev_data::dev_product))
94 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
95 					usb_client_dev_data::dev_serial))
96 
97 #ifdef	__cplusplus
98 }
99 #endif
100 
101 #endif	/* _SYS_USB_REGISTER_IMPL_H */
102