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 2008 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 } usba_reg_state_t;
62 
63 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only", usb_cvs_data))
64 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only", usb_ep_data))
65 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only", usb_alt_if_data))
66 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only", usb_if_data))
67 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only", usb_cfg_data))
68 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only", usba_reg_state))
69 
70 
71 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
72 					usb_client_dev_data::dev_cfg))
73 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
74 					usb_client_dev_data::dev_curr_cfg))
75 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
76 					usb_client_dev_data::dev_n_cfg))
77 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
78 					usb_client_dev_data::dev_parse_level))
79 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
80 					usb_client_dev_data::dev_curr_if))
81 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
82 					usb_client_dev_data::dev_default_ph))
83 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
84 					usb_client_dev_data::dev_descr))
85 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
86 					usb_client_dev_data::dev_iblock_cookie))
87 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
88 					usb_client_dev_data::dev_mfg))
89 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
90 					usb_client_dev_data::dev_product))
91 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
92 					usb_client_dev_data::dev_serial))
93 
94 #ifdef	__cplusplus
95 }
96 #endif
97 
98 #endif	/* _SYS_USB_REGISTER_IMPL_H */
99