xref: /onnv-gate/usr/src/uts/common/sys/1394/s1394.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_SYS_1394_S1394_H
28*0Sstevel@tonic-gate #define	_SYS_1394_S1394_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate /*
33*0Sstevel@tonic-gate  * s1394.h
34*0Sstevel@tonic-gate  *    Contains all of the structures used (internally) by the 1394
35*0Sstevel@tonic-gate  *    Software Framework
36*0Sstevel@tonic-gate  */
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate #include <sys/types.h>
39*0Sstevel@tonic-gate #include <sys/dditypes.h>
40*0Sstevel@tonic-gate #include <sys/ddi.h>
41*0Sstevel@tonic-gate #include <sys/sunddi.h>
42*0Sstevel@tonic-gate #include <sys/sunndi.h>
43*0Sstevel@tonic-gate #include <sys/callb.h>
44*0Sstevel@tonic-gate #include <sys/note.h>
45*0Sstevel@tonic-gate 
46*0Sstevel@tonic-gate #include <sys/1394/s1394_impl.h>
47*0Sstevel@tonic-gate #include <sys/1394/t1394.h>
48*0Sstevel@tonic-gate #include <sys/1394/h1394.h>
49*0Sstevel@tonic-gate #include <sys/1394/cmd1394.h>
50*0Sstevel@tonic-gate #include <sys/1394/ieee1212.h>
51*0Sstevel@tonic-gate #include <sys/1394/ieee1394.h>
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate #ifdef	__cplusplus
54*0Sstevel@tonic-gate extern "C" {
55*0Sstevel@tonic-gate #endif
56*0Sstevel@tonic-gate 
57*0Sstevel@tonic-gate /* SelfID buffer size */
58*0Sstevel@tonic-gate #define	S1394_SELFID_BUF_SIZE		8192
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate /* Maximum number of allocated commands per target */
61*0Sstevel@tonic-gate #define	MAX_NUMBER_ALLOC_CMDS		256
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate /* Maximum number of lock retries */
64*0Sstevel@tonic-gate #define	MAX_NUMBER_OF_LOCK_RETRIES	256
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate #define	S1394_INITIAL_STATES		2
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate /* Invalid entry in the Speed Map */
69*0Sstevel@tonic-gate #define	SPEED_MAP_INVALID		0xFF
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate /* Invalid node num */
72*0Sstevel@tonic-gate #define	S1394_INVALID_NODE_NUM		0x3F
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate /* Node state */
75*0Sstevel@tonic-gate #define	S1394_NODE_OFFLINE		1
76*0Sstevel@tonic-gate #define	S1394_NODE_ONLINE		2
77*0Sstevel@tonic-gate 
78*0Sstevel@tonic-gate /* Where are commands inserted onto the pending Q? */
79*0Sstevel@tonic-gate #define	S1394_PENDING_Q_FRONT		1
80*0Sstevel@tonic-gate #define	S1394_PENDING_Q_REAR		2
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate /* Number of self-initiated bus resets until HAL fails */
83*0Sstevel@tonic-gate #define	NUM_BR_FAIL			5
84*0Sstevel@tonic-gate 
85*0Sstevel@tonic-gate /* Reasons for Self-Initiated Bus Reset */
86*0Sstevel@tonic-gate #define	NON_CRITICAL			0
87*0Sstevel@tonic-gate #define	CRITICAL			1
88*0Sstevel@tonic-gate 
89*0Sstevel@tonic-gate /* Bus Mgr (IRM) defines */
90*0Sstevel@tonic-gate #define	ROOT_HOLDOFF			(1 << 0)
91*0Sstevel@tonic-gate #define	GAP_COUNT			(1 << 1)
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate /* Root Node has no parents */
94*0Sstevel@tonic-gate #define	NO_PARENT			-1
95*0Sstevel@tonic-gate 
96*0Sstevel@tonic-gate /* Maximum number of Hops between Nodes on the Bus */
97*0Sstevel@tonic-gate #define	MAX_HOPS			23
98*0Sstevel@tonic-gate 
99*0Sstevel@tonic-gate /* Invalid lo and hi addresses used in s1394_init_addr_space() */
100*0Sstevel@tonic-gate #define	ADDR_LO_INVALID			0x0000000000000001
101*0Sstevel@tonic-gate #define	ADDR_HI_INVALID			0x0000000000000000
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate /* Time to delay after CYCLE_TOO_LONG before enabling cycle master */
104*0Sstevel@tonic-gate #define	CYCLE_MASTER_TIMER		1000	/* 1 second */
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate /* Size of directory stack used during config rom scan */
107*0Sstevel@tonic-gate #define	S1394_DIR_STACK_SIZE		16
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate /*
110*0Sstevel@tonic-gate  * P1394a (Draft 2.x) proposes to disallow a
111*0Sstevel@tonic-gate  * Config ROM "generation" to be repeated within
112*0Sstevel@tonic-gate  * a 60 second window.
113*0Sstevel@tonic-gate  * Because of that, this value should not be set
114*0Sstevel@tonic-gate  * to any value smaller than 5 seconds without
115*0Sstevel@tonic-gate  * another method in place to ensure that this
116*0Sstevel@tonic-gate  * "generation" reuse can not happen.
117*0Sstevel@tonic-gate  */
118*0Sstevel@tonic-gate 
119*0Sstevel@tonic-gate /*
120*0Sstevel@tonic-gate  * Time delay (in ms) from Config ROM update to
121*0Sstevel@tonic-gate  * software-initiated bus reset.
122*0Sstevel@tonic-gate  */
123*0Sstevel@tonic-gate #define	CONFIG_ROM_UPDATE_DELAY		5000	/* 5 seconds */
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate #define	S1394_ROOT_TEXT_LEAF_SZ		36
126*0Sstevel@tonic-gate #define	S1394_ROOT_TEXT_LEAF_QUAD_SZ	9
127*0Sstevel@tonic-gate #define	S1394_ROOT_TEXT_KEY		0x81
128*0Sstevel@tonic-gate 
129*0Sstevel@tonic-gate #define	S1394_NODE_UNIQUE_ID_SZ		12
130*0Sstevel@tonic-gate #define	S1394_NODE_UNIQUE_ID_QUAD_SZ	3
131*0Sstevel@tonic-gate #define	S1394_NODE_UNIQUE_ID_KEY	0x8D
132*0Sstevel@tonic-gate 
133*0Sstevel@tonic-gate #define	S1394_UNIT_DIR_SZ		56
134*0Sstevel@tonic-gate #define	S1394_UNIT_DIR_QUAD_SZ		14
135*0Sstevel@tonic-gate #define	S1394_UNIT_DIR_KEY		0xD1
136*0Sstevel@tonic-gate 
137*0Sstevel@tonic-gate /* The Organizationally Unique Identifier for Sun Microsystems, Inc. */
138*0Sstevel@tonic-gate #define	S1394_SUNW_OUI			0x080020
139*0Sstevel@tonic-gate 
140*0Sstevel@tonic-gate /* Number of retries in reading the Config ROM */
141*0Sstevel@tonic-gate #define	CFGROM_READ_RETRIES		5
142*0Sstevel@tonic-gate 
143*0Sstevel@tonic-gate /* Delay time between reads of the Config ROM */
144*0Sstevel@tonic-gate #define	CFGROM_READ_DELAY		20000	/* 20ms */
145*0Sstevel@tonic-gate 
146*0Sstevel@tonic-gate /* Error message for serious HBA hardware shutdowns */
147*0Sstevel@tonic-gate #define	HALT_ERROR_MESSAGE	"%s%d: Unexpected Error: Shutting down HBA -" \
148*0Sstevel@tonic-gate 	" Hardware disabled until next reboot"
149*0Sstevel@tonic-gate 
150*0Sstevel@tonic-gate /* Command Transaction Type */
151*0Sstevel@tonic-gate #define	S1394_CMD_READ		0
152*0Sstevel@tonic-gate #define	S1394_CMD_WRITE		1
153*0Sstevel@tonic-gate #define	S1394_CMD_LOCK		2
154*0Sstevel@tonic-gate 
155*0Sstevel@tonic-gate /* Channel allocations */
156*0Sstevel@tonic-gate #define	S1394_CHANNEL_ALLOC_HI	1
157*0Sstevel@tonic-gate #define	S1394_CHANNEL_ALLOC_LO	0
158*0Sstevel@tonic-gate 
159*0Sstevel@tonic-gate /* Maximum number of bus resets allowed in isoch rsrc alloc */
160*0Sstevel@tonic-gate #define	S1394_ISOCH_ALLOC_RETRIES	5
161*0Sstevel@tonic-gate 
162*0Sstevel@tonic-gate #define	ADDR_RESERVED		1
163*0Sstevel@tonic-gate 
164*0Sstevel@tonic-gate /* Flags used by the used tree (red-black tree) */
165*0Sstevel@tonic-gate #define	BLACK			0
166*0Sstevel@tonic-gate #define	RED			1
167*0Sstevel@tonic-gate #define	LEFT			0
168*0Sstevel@tonic-gate #define	RIGHT			1
169*0Sstevel@tonic-gate 
170*0Sstevel@tonic-gate /* Isoch Bandwidth Allocation Units conversion */
171*0Sstevel@tonic-gate #define	ISOCH_SPEED_FACTOR_S100		16
172*0Sstevel@tonic-gate #define	ISOCH_SPEED_FACTOR_S200		8
173*0Sstevel@tonic-gate #define	ISOCH_SPEED_FACTOR_S400		4
174*0Sstevel@tonic-gate 
175*0Sstevel@tonic-gate /* TNF probes */
176*0Sstevel@tonic-gate #define	S1394_TNF_SL			"1394 s1394 "
177*0Sstevel@tonic-gate #define	S1394_TNF_SL_ERROR		"1394 s1394 error "
178*0Sstevel@tonic-gate #define	S1394_TNF_SL_STACK		"1394 s1394 stacktrace "
179*0Sstevel@tonic-gate #define	S1394_TNF_SL_ARREQ_STACK	"1394 s1394 arreq stacktrace "
180*0Sstevel@tonic-gate #define	S1394_TNF_SL_ARREQ_ERROR	"1394 s1394 arreq error "
181*0Sstevel@tonic-gate #define	S1394_TNF_SL_ATREQ_STACK	"1394 s1394 atreq stacktrace "
182*0Sstevel@tonic-gate #define	S1394_TNF_SL_ATREQ_ERROR	"1394 s1394 atreq error "
183*0Sstevel@tonic-gate #define	S1394_TNF_SL_ATRESP_STACK	"1394 s1394 atresp stacktrace "
184*0Sstevel@tonic-gate #define	S1394_TNF_SL_ATRESP_ERROR	"1394 s1394 atresp error "
185*0Sstevel@tonic-gate #define	S1394_TNF_SL_ATREQ_ATRESP_STACK	"1394 s1394 atreq atresp stacktrace "
186*0Sstevel@tonic-gate #define	S1394_TNF_SL_ATREQ_ATRESP_ERROR	"1394 s1394 atreq atresp error "
187*0Sstevel@tonic-gate #define	S1394_TNF_SL_BR_STACK		"1394 s1394 bus_reset stacktrace "
188*0Sstevel@tonic-gate #define	S1394_TNF_SL_BR_ERROR		"1394 s1394 bus_reset error "
189*0Sstevel@tonic-gate #define	S1394_TNF_SL_IOCTL_STACK	"1394 s1394 ioctl stacktrace "
190*0Sstevel@tonic-gate #define	S1394_TNF_SL_HOTPLUG_STACK	"1394 s1394 hotplug stacktrace "
191*0Sstevel@tonic-gate #define	S1394_TNF_SL_HOTPLUG_ERROR	"1394 s1394 hotplug error "
192*0Sstevel@tonic-gate #define	S1394_TNF_SL_NX1394_STACK	"1394 s1394 nx1394 stacktrace "
193*0Sstevel@tonic-gate #define	S1394_TNF_SL_CSR_ERROR		"1394 s1394 csr error "
194*0Sstevel@tonic-gate #define	S1394_TNF_SL_CSR_STACK		"1394 s1394 csr stacktrace "
195*0Sstevel@tonic-gate #define	S1394_TNF_SL_BR_CSR_STACK	"1394 s1394 bus_reset csr stacktrace "
196*0Sstevel@tonic-gate #define	S1394_TNF_SL_CFGROM_ERROR	"1394 s1394 cfgrom error "
197*0Sstevel@tonic-gate #define	S1394_TNF_SL_CFGROM_STACK	"1394 s1394 cfgrom stacktrace "
198*0Sstevel@tonic-gate #define	S1394_TNF_SL_ISOCH_ERROR	"1394 s1394 isoch error "
199*0Sstevel@tonic-gate #define	S1394_TNF_SL_ISOCH_STACK	"1394 s1394 isoch stacktrace "
200*0Sstevel@tonic-gate #define	S1394_TNF_SL_NEXUS_ERROR	"1394 s1394 nexus error "
201*0Sstevel@tonic-gate #define	S1394_TNF_SL_NEXUS_STACK	"1394 s1394 nexus stacktrace "
202*0Sstevel@tonic-gate #define	S1394_TNF_SL_FA_STACK		"1394 s1394 FA stacktrace "
203*0Sstevel@tonic-gate #define	S1394_TNF_SL_FA_ERROR		"1394 s1394 FA error "
204*0Sstevel@tonic-gate #define	S1394_TNF_SL_FCP_STACK		"1394 s1394 FCP stacktrace "
205*0Sstevel@tonic-gate #define	S1394_TNF_SL_FCP_ERROR		"1394 s1394 FCP error "
206*0Sstevel@tonic-gate #define	S1394_TNF_SL_CMP_STACK		"1394 s1394 CMP stacktrace "
207*0Sstevel@tonic-gate #define	S1394_TNF_SL_CMP_ERROR		"1394 s1394 CMP error "
208*0Sstevel@tonic-gate 
209*0Sstevel@tonic-gate /* s1394_hal_state_t */
210*0Sstevel@tonic-gate typedef enum {
211*0Sstevel@tonic-gate 	S1394_HAL_INIT,
212*0Sstevel@tonic-gate 	S1394_HAL_RESET,
213*0Sstevel@tonic-gate 	S1394_HAL_NORMAL,
214*0Sstevel@tonic-gate 	S1394_HAL_DREQ,
215*0Sstevel@tonic-gate 	S1394_HAL_SHUTDOWN
216*0Sstevel@tonic-gate } s1394_hal_state_t;
217*0Sstevel@tonic-gate 
218*0Sstevel@tonic-gate /* s1394_isoch_cec_type_t */
219*0Sstevel@tonic-gate typedef enum {
220*0Sstevel@tonic-gate 	S1394_SINGLE		= 1,
221*0Sstevel@tonic-gate 	S1394_PEER_TO_PEER	= 2
222*0Sstevel@tonic-gate } s1394_isoch_cec_type_t;
223*0Sstevel@tonic-gate 
224*0Sstevel@tonic-gate /* s1394_isoch_cec_state_t */
225*0Sstevel@tonic-gate typedef enum {
226*0Sstevel@tonic-gate 	ISOCH_CEC_FREE		= (1 << 0),
227*0Sstevel@tonic-gate 	ISOCH_CEC_JOIN		= (1 << 1),
228*0Sstevel@tonic-gate 	ISOCH_CEC_LEAVE		= (1 << 2),
229*0Sstevel@tonic-gate 	ISOCH_CEC_SETUP		= (1 << 3),
230*0Sstevel@tonic-gate 	ISOCH_CEC_TEARDOWN	= (1 << 4),
231*0Sstevel@tonic-gate 	ISOCH_CEC_START		= (1 << 5),
232*0Sstevel@tonic-gate 	ISOCH_CEC_STOP		= (1 << 6)
233*0Sstevel@tonic-gate } s1394_isoch_cec_state_t;
234*0Sstevel@tonic-gate 
235*0Sstevel@tonic-gate /* s1394_status_t */
236*0Sstevel@tonic-gate typedef enum {
237*0Sstevel@tonic-gate 	S1394_NOSTATUS		= (1 << 0),
238*0Sstevel@tonic-gate 	S1394_LOCK_FAILED	= (1 << 1),
239*0Sstevel@tonic-gate 	S1394_CMD_ALLOC_FAILED	= (1 << 2),
240*0Sstevel@tonic-gate 	S1394_XFER_FAILED	= (1 << 3),
241*0Sstevel@tonic-gate 	S1394_UNKNOWN		= (1 << 4),
242*0Sstevel@tonic-gate 	S1394_CMD_INFLIGHT	= (1 << 5)
243*0Sstevel@tonic-gate } s1394_status_t;
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate /* s1394_free_cfgrom_t */
246*0Sstevel@tonic-gate typedef enum {
247*0Sstevel@tonic-gate 	S1394_FREE_CFGROM_BOTH,
248*0Sstevel@tonic-gate 	S1394_FREE_CFGROM_NEW,
249*0Sstevel@tonic-gate 	S1394_FREE_CFGROM_OLD
250*0Sstevel@tonic-gate } s1394_free_cfgrom_t;
251*0Sstevel@tonic-gate 
252*0Sstevel@tonic-gate typedef struct s1394_node_s		s1394_node_t;
253*0Sstevel@tonic-gate typedef struct s1394_target_s		s1394_target_t;
254*0Sstevel@tonic-gate typedef struct s1394_hal_s		s1394_hal_t;
255*0Sstevel@tonic-gate typedef struct s1394_addr_space_blk_s	s1394_addr_space_blk_t;
256*0Sstevel@tonic-gate typedef struct s1394_config_rom_s	s1394_config_rom_t;
257*0Sstevel@tonic-gate typedef struct s1394_kstat_s		s1394_kstat_t;
258*0Sstevel@tonic-gate typedef struct s1394_isoch_cec_s	s1394_isoch_cec_t;
259*0Sstevel@tonic-gate typedef struct s1394_isoch_cec_member_s	s1394_isoch_cec_member_t;
260*0Sstevel@tonic-gate 
261*0Sstevel@tonic-gate /* cfgrom_dir_t */
262*0Sstevel@tonic-gate typedef struct {
263*0Sstevel@tonic-gate 	ushort_t		dir_start;
264*0Sstevel@tonic-gate 	ushort_t		dir_size;
265*0Sstevel@tonic-gate 	ushort_t		dir_next_quad;
266*0Sstevel@tonic-gate } cfgrom_dir_t;
267*0Sstevel@tonic-gate 
268*0Sstevel@tonic-gate /* s1394_selfid_pkt_t */
269*0Sstevel@tonic-gate typedef struct s1394_selfid_pkt_s {
270*0Sstevel@tonic-gate 	uint32_t		spkt_data;
271*0Sstevel@tonic-gate 	uint32_t		spkt_inverse;
272*0Sstevel@tonic-gate } s1394_selfid_pkt_t;
273*0Sstevel@tonic-gate 
274*0Sstevel@tonic-gate /* s1394_node_t */
275*0Sstevel@tonic-gate struct s1394_node_s {
276*0Sstevel@tonic-gate 	s1394_selfid_pkt_t	*selfid_packet;
277*0Sstevel@tonic-gate 	s1394_node_t		*phy_port[IEEE1394_MAX_NUM_PORTS];
278*0Sstevel@tonic-gate 	s1394_node_t		*old_node;
279*0Sstevel@tonic-gate 	s1394_node_t		*cur_node;
280*0Sstevel@tonic-gate 	s1394_target_t		*target_list;
281*0Sstevel@tonic-gate 	ushort_t		cfgrom_size;		/* in quads */
282*0Sstevel@tonic-gate 	ushort_t		cfgrom_valid_size;	/* in quads */
283*0Sstevel@tonic-gate 	uchar_t			link_active;
284*0Sstevel@tonic-gate 	uchar_t			node_num;
285*0Sstevel@tonic-gate 	uchar_t			max_1st;
286*0Sstevel@tonic-gate 	uchar_t			max_2nd;
287*0Sstevel@tonic-gate 	uchar_t			last_port_checked;
288*0Sstevel@tonic-gate 	uchar_t			parent_port;
289*0Sstevel@tonic-gate 	uchar_t			is_a_leaf;
290*0Sstevel@tonic-gate 	/* All fields above can be zero'd while initing the topology tree */
291*0Sstevel@tonic-gate 	uint32_t		*cfgrom;
292*0Sstevel@tonic-gate #define	node_guid_hi		cfgrom[3]
293*0Sstevel@tonic-gate #define	node_guid_lo		cfgrom[4]
294*0Sstevel@tonic-gate #define	node_root_dir		cfgrom[5]
295*0Sstevel@tonic-gate 	uint_t			node_state;
296*0Sstevel@tonic-gate 	uint_t			cfgrom_state;
297*0Sstevel@tonic-gate 	uint_t			bus_enum_flags;
298*0Sstevel@tonic-gate 	/* fields dir_stack through expected_dir_quad constitute dir stack */
299*0Sstevel@tonic-gate 	cfgrom_dir_t		dir_stack[S1394_DIR_STACK_SIZE];
300*0Sstevel@tonic-gate 	ushort_t		cur_dir_start;
301*0Sstevel@tonic-gate 	ushort_t		cur_dir_size;
302*0Sstevel@tonic-gate 	char			dir_stack_top;
303*0Sstevel@tonic-gate 	uchar_t			expected_type;
304*0Sstevel@tonic-gate 	uchar_t			expected_dir_quad;
305*0Sstevel@tonic-gate 	ushort_t		cfgrom_quad_to_read;
306*0Sstevel@tonic-gate 	ushort_t		cfgrom_quad_read_cnt; /* if rdg blk */
307*0Sstevel@tonic-gate 	uchar_t			rescan_cnt;
308*0Sstevel@tonic-gate 	uchar_t			cfgrom_read_fails;
309*0Sstevel@tonic-gate 	uchar_t			cfgrom_read_delay;	/* in ms */
310*0Sstevel@tonic-gate };
311*0Sstevel@tonic-gate 
312*0Sstevel@tonic-gate /* defines used during enumeration */
313*0Sstevel@tonic-gate #define	NODE_DIR_SIZE(data)		((data) & 0xff)
314*0Sstevel@tonic-gate #define	NODE_DIR_START(data)		(((data) >> 8) & 0xff)
315*0Sstevel@tonic-gate #define	NODE_DIR_QUAD(data)		(((data) >> 16) & 0xff)
316*0Sstevel@tonic-gate 
317*0Sstevel@tonic-gate /* defines for link_active */
318*0Sstevel@tonic-gate #define	SET_LINK_ACTIVE(n)	((n)->link_active = 1)
319*0Sstevel@tonic-gate #define	CLEAR_LINK_ACTIVE(n) 	((n)->link_active = 0)
320*0Sstevel@tonic-gate #define	LINK_ACTIVE(n)			\
321*0Sstevel@tonic-gate 		(((n)->link_active == 0) ? B_FALSE : B_TRUE)
322*0Sstevel@tonic-gate /* defines for state */
323*0Sstevel@tonic-gate #define	S1394_NODE_CONSUMING_PWR	0x00000001
324*0Sstevel@tonic-gate #define	S1394_NODE_ACTIVE		0x00000010
325*0Sstevel@tonic-gate #define	S1394_NODE_BUS_PWR_CONSUMER(n)		\
326*0Sstevel@tonic-gate 	((IEEE1394_SELFID_POWER((n)->selfid_packet) > 0x3) ? B_TRUE : B_FALSE)
327*0Sstevel@tonic-gate 
328*0Sstevel@tonic-gate /* defines for cfgrom_state */
329*0Sstevel@tonic-gate #define	S1394_CFGROM_NEW_ALLOC		0x00000001 /* fresh alloc */
330*0Sstevel@tonic-gate #define	S1394_CFGROM_BIB_READ		0x00000002 /* bus info blocks read */
331*0Sstevel@tonic-gate #define	S1394_CFGROM_ALL_READ		0x00000004 /* read all of it */
332*0Sstevel@tonic-gate #define	S1394_CFGROM_BLK_READ_OK	0x00000008 /* can be read in blocks */
333*0Sstevel@tonic-gate #define	S1394_CFGROM_GEN_CHANGED	0x00000010 /* config rom gen changed */
334*0Sstevel@tonic-gate #define	S1394_CFGROM_PARSED		0x00000020 /* rom enumerated */
335*0Sstevel@tonic-gate #define	S1394_CFGROM_DIR_STACK_OFF	0x00000040 /* dir stack turned off */
336*0Sstevel@tonic-gate #define	S1394_CFGROM_SIZE_IS_CRCSIZE	0x00000080 /* crc size == cfgrom size */
337*0Sstevel@tonic-gate 
338*0Sstevel@tonic-gate #define	S1394_CFGROM_READ_MASK	(S1394_CFGROM_BIB_READ | S1394_CFGROM_ALL_READ)
339*0Sstevel@tonic-gate 
340*0Sstevel@tonic-gate #define	S1394_VALID_MASK			\
341*0Sstevel@tonic-gate 	(S1394_CFGROM_READ_MASK | S1394_CFGROM_BLK_READ_OK | \
342*0Sstevel@tonic-gate 	S1394_CFGROM_GEN_CHANGED | S1394_CFGROM_PARSED)
343*0Sstevel@tonic-gate 
344*0Sstevel@tonic-gate #define	CLEAR_CFGROM_STATE(n)	((n)->cfgrom_state &= ~S1394_VALID_MASK)
345*0Sstevel@tonic-gate #define	CFGROM_VALID(n)				\
346*0Sstevel@tonic-gate 	((((n)->cfgrom_state & S1394_CFGROM_READ_MASK) != 0 && (n)->cfgrom != \
347*0Sstevel@tonic-gate 	    NULL) ? B_TRUE : B_FALSE)
348*0Sstevel@tonic-gate 
349*0Sstevel@tonic-gate /* macros for cfgrom_state */
350*0Sstevel@tonic-gate #define	SET_CFGROM_NEW_ALLOC(n)	((n)->cfgrom_state |= S1394_CFGROM_NEW_ALLOC)
351*0Sstevel@tonic-gate #define	CLEAR_CFGROM_NEW_ALLOC(n) ((n)->cfgrom_state &= ~S1394_CFGROM_NEW_ALLOC)
352*0Sstevel@tonic-gate #define	CFGROM_NEW_ALLOC(n)			\
353*0Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_NEW_ALLOC) != 0 ? B_TRUE : B_FALSE)
354*0Sstevel@tonic-gate 
355*0Sstevel@tonic-gate #define	SET_CFGROM_BIB_READ(n)	((n)->cfgrom_state |= S1394_CFGROM_BIB_READ)
356*0Sstevel@tonic-gate #define	CLEAR_CFGROM_BIB_READ(n) ((n)->cfgrom_state &= ~S1394_CFGROM_BIB_READ)
357*0Sstevel@tonic-gate #define	CFGROM_BIB_READ(n)			\
358*0Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_BIB_READ) != 0 ? B_TRUE : B_FALSE)
359*0Sstevel@tonic-gate 
360*0Sstevel@tonic-gate #define	SET_CFGROM_ALL_READ(n)	((n)->cfgrom_state |= S1394_CFGROM_ALL_READ)
361*0Sstevel@tonic-gate #define	CLEAR_CFGROM_ALL_READ(n)	((n)->cfgrom_state &= \
362*0Sstevel@tonic-gate 	~S1394_CFGROM_ALL_READ)
363*0Sstevel@tonic-gate #define	CFGROM_ALL_READ(n)				\
364*0Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_ALL_READ) != 0 ? B_TRUE : B_FALSE)
365*0Sstevel@tonic-gate 
366*0Sstevel@tonic-gate #define	SET_CFGROM_BLK_READ_OK(n)		\
367*0Sstevel@tonic-gate 	((n)->cfgrom_state |= S1394_CFGROM_BLK_READ_OK)
368*0Sstevel@tonic-gate #define	CLEAR_CFGROM_BLK_READ_OK(n)		\
369*0Sstevel@tonic-gate 	((n)->cfgrom_state &= ~S1394_CFGROM_BLK_READ_OK)
370*0Sstevel@tonic-gate #define	CFGROM_BLK_READ_OK(n)			\
371*0Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_BLK_READ_OK) != 0 : B_TRUE : B_FALSE)
372*0Sstevel@tonic-gate 
373*0Sstevel@tonic-gate #define	SET_CFGROM_GEN_CHANGED(n)		\
374*0Sstevel@tonic-gate 	((n)->cfgrom_state |= S1394_CFGROM_GEN_CHANGED)
375*0Sstevel@tonic-gate #define	CLEAR_CFGROM_GEN_CHANGED(n)		\
376*0Sstevel@tonic-gate 	((n)->cfgrom_state &= ~S1394_CFGROM_GEN_CHANGED)
377*0Sstevel@tonic-gate #define	CFGROM_GEN_CHANGED(n)			\
378*0Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_GEN_CHANGED) != 0 ? B_TRUE : B_FALSE)
379*0Sstevel@tonic-gate 
380*0Sstevel@tonic-gate #define	SET_CFGROM_PARSED(n)	((n)->cfgrom_state |= S1394_CFGROM_PARSED)
381*0Sstevel@tonic-gate #define	CLEAR_CFGROM_PARSED(n)	((n)->cfgrom_state &= ~S1394_CFGROM_PARSED)
382*0Sstevel@tonic-gate #define	CFGROM_PARSED(n)			\
383*0Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_PARSED) != 0 ? B_TRUE : B_FALSE)
384*0Sstevel@tonic-gate 
385*0Sstevel@tonic-gate #define	SET_CFGROM_DIR_STACK_OFF(n)		\
386*0Sstevel@tonic-gate 	((n)->cfgrom_state |= S1394_CFGROM_DIR_STACK_OFF)
387*0Sstevel@tonic-gate #define	CLEAR_CFGROM_DIR_STACK_OFF(n)		\
388*0Sstevel@tonic-gate 	((n)->cfgrom_state &= ~S1394_CFGROM_DIR_STACK_OFF)
389*0Sstevel@tonic-gate #define	CFGROM_DIR_STACK_OFF(n)			\
390*0Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_DIR_STACK_OFF) != 0 ? B_TRUE : \
391*0Sstevel@tonic-gate 	    B_FALSE)
392*0Sstevel@tonic-gate 
393*0Sstevel@tonic-gate #define	SET_CFGROM_SIZE_IS_CRCSIZE(n)		\
394*0Sstevel@tonic-gate 	((n)->cfgrom_state |= S1394_CFGROM_SIZE_IS_CRCSIZE)
395*0Sstevel@tonic-gate #define	CLEAR_CFGROM_SIZE_IS_CRCSIZE(n)		\
396*0Sstevel@tonic-gate 	((n)->cfgrom_state &= ~S1394_CFGROM_SIZE_IS_CRCSIZE)
397*0Sstevel@tonic-gate #define	CFGROM_SIZE_IS_CRCSIZE(n)			\
398*0Sstevel@tonic-gate 	(((n)->cfgrom_state & S1394_CFGROM_SIZE_IS_CRCSIZE) != 0 ? B_TRUE : \
399*0Sstevel@tonic-gate 	    B_FALSE)
400*0Sstevel@tonic-gate 
401*0Sstevel@tonic-gate /* defines for bus_enum_flags */
402*0Sstevel@tonic-gate #define	S1394_NODE_VISITED		0x00000001
403*0Sstevel@tonic-gate #define	S1394_NODE_MATCHED		0x00000010
404*0Sstevel@tonic-gate 
405*0Sstevel@tonic-gate /* macros that set/clear bus_enum_flags */
406*0Sstevel@tonic-gate #define	SET_NODE_VISITED(n)	((n)->bus_enum_flags |= S1394_NODE_VISITED)
407*0Sstevel@tonic-gate #define	CLEAR_NODE_VISITED(n)	((n)->bus_enum_flags &= ~S1394_NODE_VISITED)
408*0Sstevel@tonic-gate #define	NODE_VISITED(n)				\
409*0Sstevel@tonic-gate 	(((n)->bus_enum_flags & S1394_NODE_VISITED) != 0 ? B_TRUE : B_FALSE)
410*0Sstevel@tonic-gate 
411*0Sstevel@tonic-gate #define	SET_NODE_MATCHED(n)	((n)->bus_enum_flags |= S1394_NODE_MATCHED)
412*0Sstevel@tonic-gate #define	CLEAR_NODE_MATCHED(n)	((n)->bus_enum_flags &= ~S1394_NODE_MATCHED)
413*0Sstevel@tonic-gate #define	NODE_MATCHED(n)				\
414*0Sstevel@tonic-gate 	(((n)->bus_enum_flags & S1394_NODE_MATCHED) != 0 ? B_TRUE : B_FALSE)
415*0Sstevel@tonic-gate 
416*0Sstevel@tonic-gate #define	SET_NODE_IDENTIFIED(n)	((n)->bus_enum_flags |= S1394_NODE_IDENTIFIED)
417*0Sstevel@tonic-gate #define	CLEAR_NODE_IDENTIFIED(n) ((n)->bus_enum_flags &= ~S1394_NODE_IDENTIFIED)
418*0Sstevel@tonic-gate #define	NODE_IDENTIFIED(n)			\
419*0Sstevel@tonic-gate 	(((n)->bus_enum_flags & S1394_NODE_IDENTIFIED) != 0 ? B_TRUE : B_FALSE)
420*0Sstevel@tonic-gate 
421*0Sstevel@tonic-gate /*
422*0Sstevel@tonic-gate  * s1394_fa_type_t - FA types, used as index into target_fa and hal_fa
423*0Sstevel@tonic-gate  */
424*0Sstevel@tonic-gate typedef enum {
425*0Sstevel@tonic-gate 	S1394_FA_TYPE_FCP_CTL,		/* FCP controller */
426*0Sstevel@tonic-gate 	S1394_FA_TYPE_FCP_TGT,		/* FCP target */
427*0Sstevel@tonic-gate 	S1394_FA_TYPE_CMP_OMPR,		/* CMP oMPR */
428*0Sstevel@tonic-gate 	S1394_FA_TYPE_CMP_IMPR,		/* CMP iMPR */
429*0Sstevel@tonic-gate 	S1394_FA_NTYPES,		/* should remain the last field */
430*0Sstevel@tonic-gate 	S1394_FA_TYPE_CMP = S1394_FA_TYPE_CMP_OMPR	/* common CMP type */
431*0Sstevel@tonic-gate } s1394_fa_type_t;
432*0Sstevel@tonic-gate 
433*0Sstevel@tonic-gate 
434*0Sstevel@tonic-gate /*
435*0Sstevel@tonic-gate  * s1394_fa_descr_t - FA type descriptor
436*0Sstevel@tonic-gate  */
437*0Sstevel@tonic-gate typedef struct s1394_fa_descr_s {
438*0Sstevel@tonic-gate 	uint64_t		fd_addr;	/* address space  */
439*0Sstevel@tonic-gate 	size_t			fd_size;	/* address space size */
440*0Sstevel@tonic-gate 	t1394_addr_enable_t	fd_enable;	/* access types */
441*0Sstevel@tonic-gate 	t1394_addr_evts_t	fd_evts;	/* event callbacks */
442*0Sstevel@tonic-gate 	uint64_t		fd_conv_base;	/* address conversion base */
443*0Sstevel@tonic-gate } s1394_fa_descr_t;
444*0Sstevel@tonic-gate 
445*0Sstevel@tonic-gate /*
446*0Sstevel@tonic-gate  * s1394_fcp_target_t - per-target data required for FCP support
447*0Sstevel@tonic-gate  */
448*0Sstevel@tonic-gate typedef struct s1394_fcp_target_s {
449*0Sstevel@tonic-gate 	t1394_fcp_evts_t	fc_evts;
450*0Sstevel@tonic-gate } s1394_fcp_target_t;
451*0Sstevel@tonic-gate 
452*0Sstevel@tonic-gate /*
453*0Sstevel@tonic-gate  * s1394_cmp_target_t - per-target data required for CMP support
454*0Sstevel@tonic-gate  */
455*0Sstevel@tonic-gate typedef struct s1394_cmp_target_s {
456*0Sstevel@tonic-gate 	t1394_cmp_evts_t	cm_evts;
457*0Sstevel@tonic-gate } s1394_cmp_target_t;
458*0Sstevel@tonic-gate 
459*0Sstevel@tonic-gate /*
460*0Sstevel@tonic-gate  * s1394_fa_target_t - per-target data required for fixed address support
461*0Sstevel@tonic-gate  */
462*0Sstevel@tonic-gate typedef struct s1394_fa_target_s {
463*0Sstevel@tonic-gate 	s1394_target_t		*fat_next;	/* next in the list */
464*0Sstevel@tonic-gate 	/* type-specific data */
465*0Sstevel@tonic-gate 	union {
466*0Sstevel@tonic-gate 		s1394_fcp_target_t	fcp;
467*0Sstevel@tonic-gate 		s1394_cmp_target_t	cmp;
468*0Sstevel@tonic-gate 	} fat_u;
469*0Sstevel@tonic-gate } s1394_fa_target_t;
470*0Sstevel@tonic-gate 
471*0Sstevel@tonic-gate /* s1394_target_t - fields protected by the HAL's target_list_rwlock */
472*0Sstevel@tonic-gate struct s1394_target_s {
473*0Sstevel@tonic-gate 	int			target_version;
474*0Sstevel@tonic-gate 
475*0Sstevel@tonic-gate 	dev_info_t		*target_dip;
476*0Sstevel@tonic-gate 
477*0Sstevel@tonic-gate 	/* Pointers to the node and HAL on which the target exists */
478*0Sstevel@tonic-gate 	s1394_node_t		*on_node;
479*0Sstevel@tonic-gate 	s1394_hal_t		*on_hal;
480*0Sstevel@tonic-gate 
481*0Sstevel@tonic-gate 	s1394_target_t		*target_next;
482*0Sstevel@tonic-gate 	s1394_target_t		*target_prev;
483*0Sstevel@tonic-gate 
484*0Sstevel@tonic-gate 	/* target_list is a copy of target_list pointer in the node */
485*0Sstevel@tonic-gate 	s1394_target_t		*target_list;
486*0Sstevel@tonic-gate 	s1394_target_t		*target_sibling;
487*0Sstevel@tonic-gate 
488*0Sstevel@tonic-gate 	uint_t			unit_dir;
489*0Sstevel@tonic-gate 
490*0Sstevel@tonic-gate 	/* The max_payload sizes - max and current conditions */
491*0Sstevel@tonic-gate 	uint_t			dev_max_payload;
492*0Sstevel@tonic-gate 	uint_t			current_max_payload;
493*0Sstevel@tonic-gate 
494*0Sstevel@tonic-gate 	/* Number of asynch command target has allocated */
495*0Sstevel@tonic-gate 	uint_t			target_num_cmds;
496*0Sstevel@tonic-gate 
497*0Sstevel@tonic-gate 	/*
498*0Sstevel@tonic-gate 	 * Are physical AR requests allowed from this target's node?
499*0Sstevel@tonic-gate 	 * This field keeps track of the number of allocated blocks
500*0Sstevel@tonic-gate 	 * of physical memory the target has.
501*0Sstevel@tonic-gate 	 */
502*0Sstevel@tonic-gate 	uint_t			physical_arreq_enabled;
503*0Sstevel@tonic-gate 
504*0Sstevel@tonic-gate 	uint_t			target_state;
505*0Sstevel@tonic-gate 
506*0Sstevel@tonic-gate 	/* FCP controller and target */
507*0Sstevel@tonic-gate 	s1394_fa_target_t	target_fa[S1394_FA_NTYPES];
508*0Sstevel@tonic-gate };
509*0Sstevel@tonic-gate #define	S1394_TARG_HP_NODE		0x00000001	/* on a hp node */
510*0Sstevel@tonic-gate #define	S1394_TARG_GONE			0x00000002	/* unplugged */
511*0Sstevel@tonic-gate #define	S1394_TARG_USING_BUS_PWR	0x00000004	/* consuming pwr now */
512*0Sstevel@tonic-gate #define	S1394_TARG_BUS_PWR_CONSUMER	0x00000008	/* power consumer */
513*0Sstevel@tonic-gate #define	S1394_TARG_ACTIVE		0x00000010	/* active */
514*0Sstevel@tonic-gate 
515*0Sstevel@tonic-gate /*
516*0Sstevel@tonic-gate  * s1394_fa_hal_t - per-hal data required for fixed address support
517*0Sstevel@tonic-gate  */
518*0Sstevel@tonic-gate typedef struct s1394_fa_hal_s {
519*0Sstevel@tonic-gate 	/*
520*0Sstevel@tonic-gate 	 * each hal keeps a list of registered fixed address clients
521*0Sstevel@tonic-gate 	 */
522*0Sstevel@tonic-gate 	s1394_target_t		*fal_head;
523*0Sstevel@tonic-gate 	s1394_target_t		*fal_tail;
524*0Sstevel@tonic-gate 	uint_t			fal_gen;	/* list generation */
525*0Sstevel@tonic-gate 
526*0Sstevel@tonic-gate 	s1394_fa_descr_t	*fal_descr;	/* type descriptor */
527*0Sstevel@tonic-gate 	s1394_addr_space_blk_t	*fal_addr_blk;	/* address space block */
528*0Sstevel@tonic-gate } s1394_fa_hal_t;
529*0Sstevel@tonic-gate 
530*0Sstevel@tonic-gate /*
531*0Sstevel@tonic-gate  * s1394_cmp_hal_t - per-hal data required for fixed address support
532*0Sstevel@tonic-gate  */
533*0Sstevel@tonic-gate typedef struct s1394_cmp_hal_s {
534*0Sstevel@tonic-gate 	/* oMPR */
535*0Sstevel@tonic-gate 	krwlock_t		cmp_ompr_rwlock;
536*0Sstevel@tonic-gate 	uint32_t		cmp_ompr_val;
537*0Sstevel@tonic-gate 	/* iMPR */
538*0Sstevel@tonic-gate 	krwlock_t		cmp_impr_rwlock;
539*0Sstevel@tonic-gate 	uint32_t		cmp_impr_val;
540*0Sstevel@tonic-gate } s1394_cmp_hal_t;
541*0Sstevel@tonic-gate 
542*0Sstevel@tonic-gate /* s1394_hal_t */
543*0Sstevel@tonic-gate struct s1394_hal_s {
544*0Sstevel@tonic-gate 	s1394_hal_t		*hal_next;
545*0Sstevel@tonic-gate 	s1394_hal_t		*hal_prev;
546*0Sstevel@tonic-gate 
547*0Sstevel@tonic-gate 	/* Target list */
548*0Sstevel@tonic-gate 	s1394_target_t		*target_head;
549*0Sstevel@tonic-gate 	s1394_target_t		*target_tail;
550*0Sstevel@tonic-gate 	krwlock_t		target_list_rwlock;
551*0Sstevel@tonic-gate 
552*0Sstevel@tonic-gate 	/* halinfo structure given at attach time */
553*0Sstevel@tonic-gate 	h1394_halinfo_t		halinfo;
554*0Sstevel@tonic-gate 
555*0Sstevel@tonic-gate 	boolean_t		hal_was_suspended;
556*0Sstevel@tonic-gate 
557*0Sstevel@tonic-gate 	/* Bus reset thread */
558*0Sstevel@tonic-gate 	kthread_t		*br_thread;
559*0Sstevel@tonic-gate 	kmutex_t		br_thread_mutex;
560*0Sstevel@tonic-gate 	kcondvar_t		br_thread_cv;
561*0Sstevel@tonic-gate 	uint_t			br_thread_ev_type;
562*0Sstevel@tonic-gate 	uint32_t		br_cfgrom_read_gen;
563*0Sstevel@tonic-gate 	kmutex_t		br_cmplq_mutex;
564*0Sstevel@tonic-gate 	kcondvar_t		br_cmplq_cv;
565*0Sstevel@tonic-gate 	cmd1394_cmd_t		*br_cmplq_head;
566*0Sstevel@tonic-gate 	cmd1394_cmd_t		*br_cmplq_tail;
567*0Sstevel@tonic-gate 
568*0Sstevel@tonic-gate 	s1394_hal_state_t	hal_state;
569*0Sstevel@tonic-gate 
570*0Sstevel@tonic-gate 	/* kstats - kernel statistics for the Services Layer */
571*0Sstevel@tonic-gate 	s1394_kstat_t		*hal_kstats;
572*0Sstevel@tonic-gate 	kstat_t			*hal_ksp;
573*0Sstevel@tonic-gate 
574*0Sstevel@tonic-gate 	/* CSR STATE register bits (DREQ and ABDICATE) */
575*0Sstevel@tonic-gate 	uint_t			disable_requests_bit;
576*0Sstevel@tonic-gate 	uint_t			abdicate_bus_mgr_bit;
577*0Sstevel@tonic-gate 
578*0Sstevel@tonic-gate 	boolean_t		initiated_bus_reset;
579*0Sstevel@tonic-gate 	int			initiated_br_reason;
580*0Sstevel@tonic-gate 	uint32_t		num_bus_reset_till_fail;
581*0Sstevel@tonic-gate 
582*0Sstevel@tonic-gate 	/* IRM and Bus Manager */
583*0Sstevel@tonic-gate 	int			IRM_node;
584*0Sstevel@tonic-gate 	kmutex_t		bus_mgr_node_mutex;
585*0Sstevel@tonic-gate 	kcondvar_t		bus_mgr_node_cv;
586*0Sstevel@tonic-gate 	int			bus_mgr_node;
587*0Sstevel@tonic-gate 	boolean_t		incumbent_bus_mgr;
588*0Sstevel@tonic-gate 	timeout_id_t		bus_mgr_timeout_id;
589*0Sstevel@tonic-gate 	timeout_id_t		bus_mgr_query_timeout_id;
590*0Sstevel@tonic-gate 
591*0Sstevel@tonic-gate 	/* 1394 Bus stats */
592*0Sstevel@tonic-gate 	int			gap_count;
593*0Sstevel@tonic-gate 	int			optimum_gap_count;
594*0Sstevel@tonic-gate 	uint8_t			slowest_node_speed;
595*0Sstevel@tonic-gate 
596*0Sstevel@tonic-gate 	/* Local Config ROM */
597*0Sstevel@tonic-gate 	kmutex_t		local_config_rom_mutex;
598*0Sstevel@tonic-gate 	uint32_t		*local_config_rom;
599*0Sstevel@tonic-gate 	uint32_t		*temp_config_rom_buf;
600*0Sstevel@tonic-gate 	s1394_config_rom_t	*root_directory;
601*0Sstevel@tonic-gate 	uint_t			free_space;
602*0Sstevel@tonic-gate 	uint_t			config_rom_update_amount;
603*0Sstevel@tonic-gate 	boolean_t		config_rom_timer_set;
604*0Sstevel@tonic-gate 	timeout_id_t		config_rom_timer;
605*0Sstevel@tonic-gate 
606*0Sstevel@tonic-gate 	/* Cycle Master - CYCLE_TOO_LONG timer */
607*0Sstevel@tonic-gate 	kmutex_t		cm_timer_mutex;
608*0Sstevel@tonic-gate 	boolean_t		cm_timer_set;
609*0Sstevel@tonic-gate 	timeout_id_t		cm_timer;
610*0Sstevel@tonic-gate 
611*0Sstevel@tonic-gate 	/* Incoming (AR) request and 1394 address space */
612*0Sstevel@tonic-gate 	kmutex_t		addr_space_free_mutex;
613*0Sstevel@tonic-gate 	s1394_addr_space_blk_t	*addr_space_free_list;
614*0Sstevel@tonic-gate 	kmutex_t		addr_space_used_mutex;
615*0Sstevel@tonic-gate 	s1394_addr_space_blk_t	*addr_space_used_tree;
616*0Sstevel@tonic-gate 	uint64_t		physical_addr_lo;
617*0Sstevel@tonic-gate 	uint64_t		physical_addr_hi;
618*0Sstevel@tonic-gate 	uint64_t		csr_addr_lo;
619*0Sstevel@tonic-gate 	uint64_t		csr_addr_hi;
620*0Sstevel@tonic-gate 	uint64_t		normal_addr_lo;
621*0Sstevel@tonic-gate 	uint64_t		normal_addr_hi;
622*0Sstevel@tonic-gate 	uint64_t		posted_write_addr_lo;
623*0Sstevel@tonic-gate 	uint64_t		posted_write_addr_hi;
624*0Sstevel@tonic-gate 
625*0Sstevel@tonic-gate 	/* Outgoing (AT) request queues */
626*0Sstevel@tonic-gate 	kmutex_t		outstanding_q_mutex;
627*0Sstevel@tonic-gate 	cmd1394_cmd_t		*outstanding_q_head;
628*0Sstevel@tonic-gate 	cmd1394_cmd_t		*outstanding_q_tail;
629*0Sstevel@tonic-gate 	kmutex_t		pending_q_mutex;
630*0Sstevel@tonic-gate 	cmd1394_cmd_t		*pending_q_head;
631*0Sstevel@tonic-gate 	cmd1394_cmd_t		*pending_q_tail;
632*0Sstevel@tonic-gate 
633*0Sstevel@tonic-gate 	/* SelfID buffers */
634*0Sstevel@tonic-gate 	void			*selfid_buf0;
635*0Sstevel@tonic-gate 	void			*selfid_buf1;
636*0Sstevel@tonic-gate 	int			current_buffer;
637*0Sstevel@tonic-gate 	s1394_selfid_pkt_t	*selfid_ptrs[IEEE1394_MAX_NODES];
638*0Sstevel@tonic-gate 
639*0Sstevel@tonic-gate 	/* Topology trees and local bus stats */
640*0Sstevel@tonic-gate 	kmutex_t		topology_tree_mutex;
641*0Sstevel@tonic-gate 	uint32_t		cfgroms_being_read;
642*0Sstevel@tonic-gate 	s1394_node_t		*topology_tree;
643*0Sstevel@tonic-gate 	s1394_node_t		*old_tree;
644*0Sstevel@tonic-gate 	uint32_t		generation_count;
645*0Sstevel@tonic-gate 	ushort_t		number_of_nodes;
646*0Sstevel@tonic-gate 	ushort_t		node_id;
647*0Sstevel@tonic-gate 	boolean_t		topology_tree_valid;
648*0Sstevel@tonic-gate 	boolean_t		topology_tree_processed;
649*0Sstevel@tonic-gate 	uint32_t		old_generation_count;
650*0Sstevel@tonic-gate 	ushort_t		old_number_of_nodes;
651*0Sstevel@tonic-gate 	ushort_t		old_node_id;
652*0Sstevel@tonic-gate 	s1394_node_t		current_tree[IEEE1394_MAX_NODES];
653*0Sstevel@tonic-gate 	s1394_node_t		last_valid_tree[IEEE1394_MAX_NODES];
654*0Sstevel@tonic-gate 	boolean_t		old_tree_valid;
655*0Sstevel@tonic-gate 
656*0Sstevel@tonic-gate 	/* TOPOLOGY_MAP backing store buffer */
657*0Sstevel@tonic-gate 	uint32_t		*CSR_topology_map;
658*0Sstevel@tonic-gate 
659*0Sstevel@tonic-gate 	/* Speed Map */
660*0Sstevel@tonic-gate 	uint8_t		speed_map[IEEE1394_MAX_NODES][IEEE1394_MAX_NODES];
661*0Sstevel@tonic-gate 
662*0Sstevel@tonic-gate 	/* Stack, Queue, and Node Number list */
663*0Sstevel@tonic-gate 	void 			*hal_stack[IEEE1394_MAX_NODES];
664*0Sstevel@tonic-gate 	int			hal_stack_depth;
665*0Sstevel@tonic-gate 	void 			*hal_queue[IEEE1394_MAX_NODES];
666*0Sstevel@tonic-gate 	int   			hal_queue_front;
667*0Sstevel@tonic-gate 	int   			hal_queue_back;
668*0Sstevel@tonic-gate 	int			hal_node_number_list[IEEE1394_MAX_NODES];
669*0Sstevel@tonic-gate 	int 			hal_node_number_list_size;
670*0Sstevel@tonic-gate 
671*0Sstevel@tonic-gate 	/* Isoch CEC list */
672*0Sstevel@tonic-gate 	kmutex_t		isoch_cec_list_mutex;
673*0Sstevel@tonic-gate 	s1394_isoch_cec_t	*isoch_cec_list_head;
674*0Sstevel@tonic-gate 	s1394_isoch_cec_t	*isoch_cec_list_tail;
675*0Sstevel@tonic-gate 
676*0Sstevel@tonic-gate 	struct kmem_cache	*hal_kmem_cachep;
677*0Sstevel@tonic-gate 
678*0Sstevel@tonic-gate 	ndi_event_hdl_t		hal_ndi_event_hdl;
679*0Sstevel@tonic-gate 
680*0Sstevel@tonic-gate 	callb_cpr_t		hal_cprinfo;
681*0Sstevel@tonic-gate 
682*0Sstevel@tonic-gate 	/* FCP controllers and targets */
683*0Sstevel@tonic-gate 	s1394_fa_hal_t		hal_fa[S1394_FA_NTYPES];
684*0Sstevel@tonic-gate 
685*0Sstevel@tonic-gate 	/* CMP support */
686*0Sstevel@tonic-gate 	s1394_cmp_hal_t		hal_cmp;
687*0Sstevel@tonic-gate };
688*0Sstevel@tonic-gate 
689*0Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("No lock needed to start/stop timer", \
690*0Sstevel@tonic-gate 	s1394_hal_s::cm_timer))
691*0Sstevel@tonic-gate 
692*0Sstevel@tonic-gate /* defines for br_thread_ev_type */
693*0Sstevel@tonic-gate #define	BR_THR_CFGROM_SCAN		0x00000001	/* start reading */
694*0Sstevel@tonic-gate #define	BR_THR_GO_AWAY			0x00000002	/* clean & exit */
695*0Sstevel@tonic-gate 
696*0Sstevel@tonic-gate /*
697*0Sstevel@tonic-gate  * FCP command and response address space
698*0Sstevel@tonic-gate  */
699*0Sstevel@tonic-gate #define	IEC61883_FCP_BASE_ADDR	0xFFFFF0000B00
700*0Sstevel@tonic-gate #define	IEC61883_FCP_CMD_ADDR	IEC61883_FCP_BASE_ADDR
701*0Sstevel@tonic-gate #define	IEC61883_FCP_CMD_SIZE	0x200
702*0Sstevel@tonic-gate #define	IEC61883_FCP_RESP_ADDR	(IEC61883_FCP_CMD_ADDR + IEC61883_FCP_CMD_SIZE)
703*0Sstevel@tonic-gate #define	IEC61883_FCP_RESP_SIZE	0x200
704*0Sstevel@tonic-gate #define	IEC61883_FCP_END_ADDR (IEC61883_FCP_RESP_ADDR + IEC61883_FCP_RESP_SIZE)
705*0Sstevel@tonic-gate 
706*0Sstevel@tonic-gate /* CMP master plugs */
707*0Sstevel@tonic-gate #define	IEC61883_CMP_OMPR_ADDR		0xFFFFF0000900
708*0Sstevel@tonic-gate #define	IEC61883_CMP_IMPR_ADDR		0xFFFFF0000980
709*0Sstevel@tonic-gate #define	IEC61883_CMP_OMPR_INIT_VAL	0xBFFFFF00
710*0Sstevel@tonic-gate #define	IEC61883_CMP_IMPR_INIT_VAL	0x80FFFF00
711*0Sstevel@tonic-gate #define	IEC61883_CMP_OMPR_LOCK_MASK	0x3FFFFF00
712*0Sstevel@tonic-gate #define	IEC61883_CMP_IMPR_LOCK_MASK	0x00FFFF00
713*0Sstevel@tonic-gate 
714*0Sstevel@tonic-gate /* s1394_addr_space_blk_t */
715*0Sstevel@tonic-gate struct s1394_addr_space_blk_s {
716*0Sstevel@tonic-gate 	/* Pointers and coloring for Red-Black tree */
717*0Sstevel@tonic-gate 	s1394_addr_space_blk_t		*asb_parent;
718*0Sstevel@tonic-gate 	s1394_addr_space_blk_t		*asb_left;
719*0Sstevel@tonic-gate 	s1394_addr_space_blk_t		*asb_right;
720*0Sstevel@tonic-gate 	uint32_t			asb_color;
721*0Sstevel@tonic-gate 	boolean_t			free_kmem_bufp;
722*0Sstevel@tonic-gate 
723*0Sstevel@tonic-gate 	/* Addr Blk info - callbacks, permissions, backing store, etc. */
724*0Sstevel@tonic-gate 	uint64_t			addr_lo;
725*0Sstevel@tonic-gate 	uint64_t			addr_hi;
726*0Sstevel@tonic-gate 	uint32_t			addr_reserved;
727*0Sstevel@tonic-gate 	t1394_addr_enable_t		addr_enable;
728*0Sstevel@tonic-gate 	t1394_addr_type_t		addr_type;
729*0Sstevel@tonic-gate 	t1394_addr_evts_t		addr_events;
730*0Sstevel@tonic-gate 	caddr_t				kmem_bufp;
731*0Sstevel@tonic-gate 	void				*addr_arg;
732*0Sstevel@tonic-gate };
733*0Sstevel@tonic-gate 
734*0Sstevel@tonic-gate /* s1394_config_rom_t */
735*0Sstevel@tonic-gate struct s1394_config_rom_s {
736*0Sstevel@tonic-gate 	boolean_t		cfgrom_used;
737*0Sstevel@tonic-gate 	uint32_t		cfgrom_addr_lo;
738*0Sstevel@tonic-gate 	uint32_t		cfgrom_addr_hi;
739*0Sstevel@tonic-gate 
740*0Sstevel@tonic-gate 	uint_t			root_dir_offset;
741*0Sstevel@tonic-gate 
742*0Sstevel@tonic-gate 	s1394_config_rom_t	*cfgrom_next;
743*0Sstevel@tonic-gate 	s1394_config_rom_t	*cfgrom_prev;
744*0Sstevel@tonic-gate };
745*0Sstevel@tonic-gate 
746*0Sstevel@tonic-gate /* s1394_kstat_t */
747*0Sstevel@tonic-gate struct s1394_kstat_s {
748*0Sstevel@tonic-gate 	/* Asynch Receive (AR) requests */
749*0Sstevel@tonic-gate 	uint_t			arreq_quad_rd;
750*0Sstevel@tonic-gate 	uint_t			arreq_blk_rd;
751*0Sstevel@tonic-gate 	uint_t			arreq_quad_wr;
752*0Sstevel@tonic-gate 	uint_t			arreq_blk_wr;
753*0Sstevel@tonic-gate 	uint_t			arreq_lock32;
754*0Sstevel@tonic-gate 	uint_t			arreq_lock64;
755*0Sstevel@tonic-gate 
756*0Sstevel@tonic-gate 	uint_t			arreq_blk_rd_size;
757*0Sstevel@tonic-gate 	uint_t			arreq_blk_wr_size;
758*0Sstevel@tonic-gate 
759*0Sstevel@tonic-gate 	uint_t			arreq_posted_write_error;
760*0Sstevel@tonic-gate 
761*0Sstevel@tonic-gate 	/* Failure responses to AR requests (sent) */
762*0Sstevel@tonic-gate 	uint_t			arresp_quad_rd_fail;
763*0Sstevel@tonic-gate 	uint_t			arresp_blk_rd_fail;
764*0Sstevel@tonic-gate 	uint_t			arresp_quad_wr_fail;
765*0Sstevel@tonic-gate 	uint_t			arresp_blk_wr_fail;
766*0Sstevel@tonic-gate 	uint_t			arresp_lock32_fail;
767*0Sstevel@tonic-gate 	uint_t			arresp_lock64_fail;
768*0Sstevel@tonic-gate 
769*0Sstevel@tonic-gate 	/* Asynch Transmit (AT) requests */
770*0Sstevel@tonic-gate 	uint_t			atreq_quad_rd;
771*0Sstevel@tonic-gate 	uint_t			atreq_blk_rd;
772*0Sstevel@tonic-gate 	uint_t			atreq_quad_wr;
773*0Sstevel@tonic-gate 	uint_t			atreq_blk_wr;
774*0Sstevel@tonic-gate 	uint_t			atreq_lock32;
775*0Sstevel@tonic-gate 	uint_t			atreq_lock64;
776*0Sstevel@tonic-gate 
777*0Sstevel@tonic-gate 	uint_t			atreq_blk_rd_size;
778*0Sstevel@tonic-gate 	uint_t			atreq_blk_wr_size;
779*0Sstevel@tonic-gate 
780*0Sstevel@tonic-gate 	/* Failure responses to AT requests (received) */
781*0Sstevel@tonic-gate 	uint_t			atresp_quad_rd_fail;
782*0Sstevel@tonic-gate 	uint_t			atresp_blk_rd_fail;
783*0Sstevel@tonic-gate 	uint_t			atresp_quad_wr_fail;
784*0Sstevel@tonic-gate 	uint_t			atresp_blk_wr_fail;
785*0Sstevel@tonic-gate 	uint_t			atresp_lock32_fail;
786*0Sstevel@tonic-gate 	uint_t			atresp_lock64_fail;
787*0Sstevel@tonic-gate 
788*0Sstevel@tonic-gate 
789*0Sstevel@tonic-gate 	/* Allocate & free requests */
790*0Sstevel@tonic-gate 	uint_t			cmd_alloc;
791*0Sstevel@tonic-gate 	uint_t			cmd_alloc_fail;
792*0Sstevel@tonic-gate 	uint_t			cmd_free;
793*0Sstevel@tonic-gate 	uint_t			addr_phys_alloc;
794*0Sstevel@tonic-gate 	uint_t			addr_posted_alloc;
795*0Sstevel@tonic-gate 	uint_t			addr_normal_alloc;
796*0Sstevel@tonic-gate 	uint_t			addr_csr_alloc;
797*0Sstevel@tonic-gate 	uint_t			addr_alloc_fail;
798*0Sstevel@tonic-gate 	uint_t			addr_space_free;
799*0Sstevel@tonic-gate 
800*0Sstevel@tonic-gate 	/* Bus reset and miscellaneous */
801*0Sstevel@tonic-gate 	uint_t			bus_reset;
802*0Sstevel@tonic-gate 	uint_t			selfid_complete;
803*0Sstevel@tonic-gate 	uint_t			selfid_buffer_error;
804*0Sstevel@tonic-gate 	uint_t			pending_q_insert;
805*0Sstevel@tonic-gate 	uint64_t		guid;
806*0Sstevel@tonic-gate };
807*0Sstevel@tonic-gate 
808*0Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Statistics", \
809*0Sstevel@tonic-gate 	s1394_kstat_s::{arreq_blk_rd arreq_blk_wr arreq_quad_rd arreq_quad_wr \
810*0Sstevel@tonic-gate 	cmd_free selfid_buffer_error arreq_posted_write_error}))
811*0Sstevel@tonic-gate 
812*0Sstevel@tonic-gate /* s1394_isoch_cec_t */
813*0Sstevel@tonic-gate struct s1394_isoch_cec_s {
814*0Sstevel@tonic-gate 	s1394_isoch_cec_t		*cec_next;
815*0Sstevel@tonic-gate 	s1394_isoch_cec_t		*cec_prev;
816*0Sstevel@tonic-gate 
817*0Sstevel@tonic-gate 	kmutex_t			isoch_cec_mutex;
818*0Sstevel@tonic-gate 
819*0Sstevel@tonic-gate 	/* Isoch CEC member list */
820*0Sstevel@tonic-gate 	s1394_isoch_cec_type_t		cec_type;
821*0Sstevel@tonic-gate 	s1394_isoch_cec_member_t	*cec_member_list_head;
822*0Sstevel@tonic-gate 	s1394_isoch_cec_member_t	*cec_member_list_tail;
823*0Sstevel@tonic-gate 	s1394_isoch_cec_member_t	*cec_member_talker;
824*0Sstevel@tonic-gate 
825*0Sstevel@tonic-gate 	/* Properties given in t1394_alloc_isoch_cec() */
826*0Sstevel@tonic-gate 	t1394_isoch_cec_props_t		cec_alloc_props;
827*0Sstevel@tonic-gate 
828*0Sstevel@tonic-gate 	/* Current state of Isoch CEC */
829*0Sstevel@tonic-gate 	uint_t				filter_min_speed;
830*0Sstevel@tonic-gate 	uint_t				filter_max_speed;
831*0Sstevel@tonic-gate 	uint_t				filter_current_speed;
832*0Sstevel@tonic-gate 	uint64_t			filter_channel_mask;
833*0Sstevel@tonic-gate 	uint_t				bandwidth;
834*0Sstevel@tonic-gate 	t1394_cec_options_t		cec_options;
835*0Sstevel@tonic-gate 	s1394_isoch_cec_state_t		state_transitions;
836*0Sstevel@tonic-gate 	boolean_t			in_callbacks;
837*0Sstevel@tonic-gate 	boolean_t			in_fail_callbacks;
838*0Sstevel@tonic-gate 	kcondvar_t			in_callbacks_cv;
839*0Sstevel@tonic-gate 	boolean_t			cec_want_wakeup;
840*0Sstevel@tonic-gate 
841*0Sstevel@tonic-gate 	boolean_t			realloc_valid;
842*0Sstevel@tonic-gate 	boolean_t			realloc_failed;
843*0Sstevel@tonic-gate 	t1394_isoch_rsrc_error_t	realloc_fail_reason;
844*0Sstevel@tonic-gate 	uint_t				realloc_chnl_num;
845*0Sstevel@tonic-gate 	uint_t				realloc_bandwidth;
846*0Sstevel@tonic-gate 	uint_t				realloc_speed;
847*0Sstevel@tonic-gate };
848*0Sstevel@tonic-gate #define	CEC_IN_ANY_CALLBACKS(cec)	(((cec)->in_callbacks == B_TRUE) || \
849*0Sstevel@tonic-gate 					((cec)->in_fail_callbacks == B_TRUE))
850*0Sstevel@tonic-gate 
851*0Sstevel@tonic-gate #define	CEC_TRANSITION_LEGAL(cec, tran)	((cec)->state_transitions & (tran))
852*0Sstevel@tonic-gate #define	CEC_SET_LEGAL(cec, tran)	((cec)->state_transitions |= (tran))
853*0Sstevel@tonic-gate #define	CEC_SET_ILLEGAL(cec, tran)	((cec)->state_transitions &= ~(tran))
854*0Sstevel@tonic-gate 
855*0Sstevel@tonic-gate 
856*0Sstevel@tonic-gate /* s1394_isoch_cec_member_t */
857*0Sstevel@tonic-gate struct s1394_isoch_cec_member_s {
858*0Sstevel@tonic-gate 	s1394_isoch_cec_member_t	*cec_mem_next;
859*0Sstevel@tonic-gate 	s1394_isoch_cec_member_t	*cec_mem_prev;
860*0Sstevel@tonic-gate 
861*0Sstevel@tonic-gate 	/* Events for Isoch CEC member - given in t1394_join_isoch_cec() */
862*0Sstevel@tonic-gate 	t1394_isoch_cec_evts_t		isoch_cec_evts;
863*0Sstevel@tonic-gate 	opaque_t			isoch_cec_evts_arg;
864*0Sstevel@tonic-gate 	uint64_t			req_channel_mask;
865*0Sstevel@tonic-gate 	uint_t				req_max_speed;
866*0Sstevel@tonic-gate 	t1394_jii_options_t		cec_mem_options;
867*0Sstevel@tonic-gate 	s1394_target_t			*cec_mem_target;
868*0Sstevel@tonic-gate };
869*0Sstevel@tonic-gate 
870*0Sstevel@tonic-gate /* cmd1394_fa_cmd_priv_t - per-command data for fixed address support */
871*0Sstevel@tonic-gate typedef struct s1394_fa_cmd_priv_s {
872*0Sstevel@tonic-gate 	s1394_fa_type_t		type;
873*0Sstevel@tonic-gate 	void			(*completion_callback)();
874*0Sstevel@tonic-gate 	opaque_t		callback_arg;
875*0Sstevel@tonic-gate } s1394_fa_cmd_priv_t;
876*0Sstevel@tonic-gate 
877*0Sstevel@tonic-gate /* s1394_cmd_priv_t */
878*0Sstevel@tonic-gate typedef struct s1394_cmd_priv_s {
879*0Sstevel@tonic-gate 	/* Services Layer private structure for asynch commands */
880*0Sstevel@tonic-gate 	cmd1394_cmd_t		*cmd_priv_next;
881*0Sstevel@tonic-gate 	cmd1394_cmd_t		*cmd_priv_prev;
882*0Sstevel@tonic-gate 
883*0Sstevel@tonic-gate 	uint32_t		cmd_priv_xfer_type;
884*0Sstevel@tonic-gate 	s1394_target_t		*sent_by_target;
885*0Sstevel@tonic-gate 	s1394_hal_t		*sent_on_hal;
886*0Sstevel@tonic-gate 
887*0Sstevel@tonic-gate 	int			lock_req_step;
888*0Sstevel@tonic-gate 	int			temp_num_retries;
889*0Sstevel@tonic-gate 
890*0Sstevel@tonic-gate 	size_t			data_remaining;
891*0Sstevel@tonic-gate 
892*0Sstevel@tonic-gate 	kmutex_t		blocking_mutex;
893*0Sstevel@tonic-gate 	kcondvar_t		blocking_cv;
894*0Sstevel@tonic-gate 	boolean_t		blocking_flag;
895*0Sstevel@tonic-gate 
896*0Sstevel@tonic-gate 	boolean_t		cmd_in_use;
897*0Sstevel@tonic-gate 	boolean_t		posted_write;
898*0Sstevel@tonic-gate 	boolean_t		arreq_valid_addr;
899*0Sstevel@tonic-gate 
900*0Sstevel@tonic-gate 	/*
901*0Sstevel@tonic-gate 	 * Commands can be extended to support additional functionality.
902*0Sstevel@tonic-gate 	 * The only extension at this time is FA (currently used only for FCP).
903*0Sstevel@tonic-gate 	 * The downside here is that every command should carry FA overhead
904*0Sstevel@tonic-gate 	 * even if the target doesn't use FA. However, alternative approaches
905*0Sstevel@tonic-gate 	 * would require separate allocation of FA overhead per command, which
906*0Sstevel@tonic-gate 	 * complicates the code and fragments the memory -- seems not worth it
907*0Sstevel@tonic-gate 	 * given that FA overhead is just a few bytes and there's a limit of
908*0Sstevel@tonic-gate 	 * 256 commands per target.
909*0Sstevel@tonic-gate 	 */
910*0Sstevel@tonic-gate 	int			cmd_ext_type;
911*0Sstevel@tonic-gate 	union {
912*0Sstevel@tonic-gate 		s1394_fa_cmd_priv_t	fa;
913*0Sstevel@tonic-gate 	} cmd_ext;
914*0Sstevel@tonic-gate 
915*0Sstevel@tonic-gate 	h1394_cmd_priv_t	hal_cmd_private;
916*0Sstevel@tonic-gate } s1394_cmd_priv_t;
917*0Sstevel@tonic-gate #define	S1394_GET_CMD_PRIV(cmd)	\
918*0Sstevel@tonic-gate 	((s1394_cmd_priv_t *)((uchar_t *)(cmd) + sizeof (cmd1394_cmd_t)))
919*0Sstevel@tonic-gate 
920*0Sstevel@tonic-gate /* command extension types */
921*0Sstevel@tonic-gate enum {
922*0Sstevel@tonic-gate 	S1394_CMD_EXT_FA	= 1
923*0Sstevel@tonic-gate };
924*0Sstevel@tonic-gate #define	S1394_GET_FA_CMD_PRIV(cmd)	(&(S1394_GET_CMD_PRIV(cmd)->cmd_ext.fa))
925*0Sstevel@tonic-gate 
926*0Sstevel@tonic-gate #define	S1394_IS_CMD_FCP(s_priv) \
927*0Sstevel@tonic-gate 	((s_priv->cmd_ext.fa.type == S1394_FA_TYPE_FCP_CTL) || \
928*0Sstevel@tonic-gate 	(s_priv->cmd_ext.fa.type == S1394_FA_TYPE_FCP_TGT))
929*0Sstevel@tonic-gate 
930*0Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Unique per command", \
931*0Sstevel@tonic-gate 	s1394_cmd_priv_s::cmd_priv_xfer_type))
932*0Sstevel@tonic-gate 
933*0Sstevel@tonic-gate 
934*0Sstevel@tonic-gate /* s1394_state_t */
935*0Sstevel@tonic-gate typedef struct s1394_state_s {
936*0Sstevel@tonic-gate 	/* HAL list */
937*0Sstevel@tonic-gate 	kmutex_t	hal_list_mutex;
938*0Sstevel@tonic-gate 	s1394_hal_t	*hal_head;
939*0Sstevel@tonic-gate 	s1394_hal_t	*hal_tail;
940*0Sstevel@tonic-gate } s1394_state_t;
941*0Sstevel@tonic-gate 
942*0Sstevel@tonic-gate /* Service Layer Global State Pointer */
943*0Sstevel@tonic-gate extern   s1394_state_t  *s1394_statep;
944*0Sstevel@tonic-gate 
945*0Sstevel@tonic-gate 
946*0Sstevel@tonic-gate /* 1394 Services Layer Internals - 1394 Address Space Routines */
947*0Sstevel@tonic-gate int s1394_request_addr_blk(s1394_hal_t *hal, t1394_alloc_addr_t *addr_allocp);
948*0Sstevel@tonic-gate 
949*0Sstevel@tonic-gate int s1394_claim_addr_blk(s1394_hal_t *hal, t1394_alloc_addr_t *addr_allocp);
950*0Sstevel@tonic-gate 
951*0Sstevel@tonic-gate int s1394_free_addr_blk(s1394_hal_t *hal, s1394_addr_space_blk_t *blk);
952*0Sstevel@tonic-gate 
953*0Sstevel@tonic-gate int s1394_reserve_addr_blk(s1394_hal_t *hal, t1394_alloc_addr_t *addr_allocp);
954*0Sstevel@tonic-gate 
955*0Sstevel@tonic-gate int s1394_init_addr_space(s1394_hal_t *hal);
956*0Sstevel@tonic-gate 
957*0Sstevel@tonic-gate void s1394_destroy_addr_space(s1394_hal_t *hal);
958*0Sstevel@tonic-gate 
959*0Sstevel@tonic-gate void s1394_free_list_insert(s1394_hal_t *hal, s1394_addr_space_blk_t *new_blk);
960*0Sstevel@tonic-gate 
961*0Sstevel@tonic-gate s1394_addr_space_blk_t *s1394_used_tree_search(s1394_hal_t *hal,
962*0Sstevel@tonic-gate     uint64_t addr);
963*0Sstevel@tonic-gate 
964*0Sstevel@tonic-gate s1394_addr_space_blk_t *s1394_used_tree_delete(s1394_hal_t *hal,
965*0Sstevel@tonic-gate     s1394_addr_space_blk_t *z);
966*0Sstevel@tonic-gate 
967*0Sstevel@tonic-gate boolean_t s1394_is_posted_write(s1394_hal_t *hal, uint64_t addr);
968*0Sstevel@tonic-gate 
969*0Sstevel@tonic-gate boolean_t s1394_is_physical_addr(s1394_hal_t *hal, uint64_t addr);
970*0Sstevel@tonic-gate 
971*0Sstevel@tonic-gate boolean_t s1394_is_csr_addr(s1394_hal_t *hal, uint64_t addr);
972*0Sstevel@tonic-gate 
973*0Sstevel@tonic-gate boolean_t s1394_is_normal_addr(s1394_hal_t *hal, uint64_t addr);
974*0Sstevel@tonic-gate 
975*0Sstevel@tonic-gate /* 1394 Services Layer Internals - Asynchronous Communications Routines */
976*0Sstevel@tonic-gate int s1394_alloc_cmd(s1394_hal_t *hal, uint_t flags, cmd1394_cmd_t **cmdp);
977*0Sstevel@tonic-gate 
978*0Sstevel@tonic-gate int s1394_free_cmd(s1394_hal_t *hal, cmd1394_cmd_t **cmdp);
979*0Sstevel@tonic-gate 
980*0Sstevel@tonic-gate int s1394_xfer_asynch_command(s1394_hal_t *hal, cmd1394_cmd_t *cmd, int *err);
981*0Sstevel@tonic-gate 
982*0Sstevel@tonic-gate int s1394_setup_asynch_command(s1394_hal_t *hal, s1394_target_t *target,
983*0Sstevel@tonic-gate     cmd1394_cmd_t *cmd, uint32_t xfer_type, int *err);
984*0Sstevel@tonic-gate 
985*0Sstevel@tonic-gate void s1394_insert_q_asynch_cmd(s1394_hal_t *hal, cmd1394_cmd_t *cmd);
986*0Sstevel@tonic-gate 
987*0Sstevel@tonic-gate void s1394_remove_q_asynch_cmd(s1394_hal_t *hal, cmd1394_cmd_t *cmd);
988*0Sstevel@tonic-gate 
989*0Sstevel@tonic-gate void s1394_atreq_cmd_complete(s1394_hal_t *hal, cmd1394_cmd_t *req,
990*0Sstevel@tonic-gate     int status);
991*0Sstevel@tonic-gate 
992*0Sstevel@tonic-gate void s1394_atresp_cmd_complete(s1394_hal_t *hal, cmd1394_cmd_t *resp,
993*0Sstevel@tonic-gate     int status);
994*0Sstevel@tonic-gate 
995*0Sstevel@tonic-gate int s1394_send_response(s1394_hal_t *hal, cmd1394_cmd_t *resp);
996*0Sstevel@tonic-gate 
997*0Sstevel@tonic-gate int s1394_compare_swap(s1394_hal_t *hal, s1394_target_t *target,
998*0Sstevel@tonic-gate     cmd1394_cmd_t *cmd);
999*0Sstevel@tonic-gate 
1000*0Sstevel@tonic-gate int s1394_split_lock_req(s1394_hal_t *hal, s1394_target_t *target,
1001*0Sstevel@tonic-gate     cmd1394_cmd_t *cmd);
1002*0Sstevel@tonic-gate 
1003*0Sstevel@tonic-gate void s1394_pending_q_insert(s1394_hal_t *hal, cmd1394_cmd_t *cmd, uint_t flags);
1004*0Sstevel@tonic-gate 
1005*0Sstevel@tonic-gate void s1394_resend_pending_cmds(s1394_hal_t *hal);
1006*0Sstevel@tonic-gate 
1007*0Sstevel@tonic-gate /* 1394 Services Layer Internals - Bus Reset Routines */
1008*0Sstevel@tonic-gate int s1394_parse_selfid_buffer(s1394_hal_t *hal, void *selfid_buf_addr,
1009*0Sstevel@tonic-gate     uint32_t selfid_size);
1010*0Sstevel@tonic-gate 
1011*0Sstevel@tonic-gate void s1394_sort_selfids(s1394_hal_t *hal);
1012*0Sstevel@tonic-gate 
1013*0Sstevel@tonic-gate void s1394_init_topology_tree(s1394_hal_t *hal, boolean_t copied,
1014*0Sstevel@tonic-gate     ushort_t number_of_nodes);
1015*0Sstevel@tonic-gate 
1016*0Sstevel@tonic-gate int s1394_topology_tree_build(s1394_hal_t *hal);
1017*0Sstevel@tonic-gate 
1018*0Sstevel@tonic-gate void s1394_topology_tree_mark_all_unvisited(s1394_hal_t *hal);
1019*0Sstevel@tonic-gate 
1020*0Sstevel@tonic-gate void s1394_old_tree_mark_all_unvisited(s1394_hal_t *hal);
1021*0Sstevel@tonic-gate 
1022*0Sstevel@tonic-gate void s1394_old_tree_mark_all_unmatched(s1394_hal_t *hal);
1023*0Sstevel@tonic-gate 
1024*0Sstevel@tonic-gate void s1394_copy_old_tree(s1394_hal_t *hal);
1025*0Sstevel@tonic-gate 
1026*0Sstevel@tonic-gate void s1394_match_tree_nodes(s1394_hal_t *hal);
1027*0Sstevel@tonic-gate 
1028*0Sstevel@tonic-gate int s1394_topology_tree_calculate_diameter(s1394_hal_t *hal);
1029*0Sstevel@tonic-gate 
1030*0Sstevel@tonic-gate int s1394_gap_count_optimize(int diameter);
1031*0Sstevel@tonic-gate 
1032*0Sstevel@tonic-gate int s1394_get_current_gap_count(s1394_hal_t *hal);
1033*0Sstevel@tonic-gate 
1034*0Sstevel@tonic-gate void s1394_speed_map_fill(s1394_hal_t *hal);
1035*0Sstevel@tonic-gate 
1036*0Sstevel@tonic-gate uint8_t s1394_speed_map_get(s1394_hal_t *hal, uint32_t from_node,
1037*0Sstevel@tonic-gate     uint32_t to_node);
1038*0Sstevel@tonic-gate 
1039*0Sstevel@tonic-gate void s1394_update_speed_map_link_speeds(s1394_hal_t *hal);
1040*0Sstevel@tonic-gate 
1041*0Sstevel@tonic-gate int s1394_get_isoch_rsrc_mgr(s1394_hal_t *hal);
1042*0Sstevel@tonic-gate 
1043*0Sstevel@tonic-gate void s1394_physical_arreq_setup_all(s1394_hal_t *hal);
1044*0Sstevel@tonic-gate 
1045*0Sstevel@tonic-gate void s1394_physical_arreq_set_one(s1394_target_t *target);
1046*0Sstevel@tonic-gate 
1047*0Sstevel@tonic-gate void s1394_physical_arreq_clear_one(s1394_target_t *target);
1048*0Sstevel@tonic-gate 
1049*0Sstevel@tonic-gate s1394_node_t *s1394_topology_tree_get_root_node(s1394_hal_t *hal);
1050*0Sstevel@tonic-gate 
1051*0Sstevel@tonic-gate /* 1394 Services Layer Internals - CSR and Config ROM Routines */
1052*0Sstevel@tonic-gate int s1394_setup_CSR_space(s1394_hal_t *hal);
1053*0Sstevel@tonic-gate 
1054*0Sstevel@tonic-gate void s1394_CSR_topology_map_update(s1394_hal_t *hal);
1055*0Sstevel@tonic-gate 
1056*0Sstevel@tonic-gate void s1394_CSR_topology_map_disable(s1394_hal_t *hal);
1057*0Sstevel@tonic-gate 
1058*0Sstevel@tonic-gate int s1394_init_local_config_rom(s1394_hal_t *hal);
1059*0Sstevel@tonic-gate 
1060*0Sstevel@tonic-gate void s1394_destroy_local_config_rom(s1394_hal_t *hal);
1061*0Sstevel@tonic-gate 
1062*0Sstevel@tonic-gate int s1394_add_config_rom_entry(s1394_hal_t *hal, uint8_t key,
1063*0Sstevel@tonic-gate     uint32_t *buffer, uint_t size, void **handle, int *status);
1064*0Sstevel@tonic-gate 
1065*0Sstevel@tonic-gate int s1394_remove_config_rom_entry(s1394_hal_t *hal, void **handle,
1066*0Sstevel@tonic-gate     int *status);
1067*0Sstevel@tonic-gate 
1068*0Sstevel@tonic-gate void s1394_update_config_rom_callback(void *arg);
1069*0Sstevel@tonic-gate 
1070*0Sstevel@tonic-gate /* In s1394_dev_disc.c */
1071*0Sstevel@tonic-gate void s1394_br_thread(s1394_hal_t *hal);
1072*0Sstevel@tonic-gate 
1073*0Sstevel@tonic-gate void s1394_free_cfgrom(s1394_hal_t *hal, s1394_node_t *node,
1074*0Sstevel@tonic-gate     s1394_free_cfgrom_t options);
1075*0Sstevel@tonic-gate 
1076*0Sstevel@tonic-gate void s1394_copy_cfgrom(s1394_node_t *to, s1394_node_t *from);
1077*0Sstevel@tonic-gate 
1078*0Sstevel@tonic-gate int s1394_read_rest_of_cfgrom(s1394_hal_t *hal, s1394_node_t *node,
1079*0Sstevel@tonic-gate     s1394_status_t *status);
1080*0Sstevel@tonic-gate 
1081*0Sstevel@tonic-gate void s1394_cfgrom_parse_unit_dir(uint32_t *unit_dir, uint32_t *addr_hi,
1082*0Sstevel@tonic-gate     uint32_t *addr_lo, uint32_t *size_hi, uint32_t *size_lo);
1083*0Sstevel@tonic-gate 
1084*0Sstevel@tonic-gate boolean_t s1394_valid_cfgrom(s1394_hal_t *hal, s1394_node_t *node);
1085*0Sstevel@tonic-gate 
1086*0Sstevel@tonic-gate boolean_t s1394_valid_dir(s1394_hal_t *hal, s1394_node_t *node, uint32_t key,
1087*0Sstevel@tonic-gate     uint32_t *dir);
1088*0Sstevel@tonic-gate 
1089*0Sstevel@tonic-gate void s1394_get_maxpayload(s1394_target_t *target, uint_t *dev_max_payload,
1090*0Sstevel@tonic-gate     uint_t *current_max_payload);
1091*0Sstevel@tonic-gate 
1092*0Sstevel@tonic-gate int s1394_lock_tree(s1394_hal_t *hal);
1093*0Sstevel@tonic-gate 
1094*0Sstevel@tonic-gate void s1394_unlock_tree(s1394_hal_t *hal);
1095*0Sstevel@tonic-gate 
1096*0Sstevel@tonic-gate /* 1394 Services Layer Driver - Hotplug Routines */
1097*0Sstevel@tonic-gate dev_info_t *s1394_devi_find(dev_info_t *pdip, char *name, char *caddr);
1098*0Sstevel@tonic-gate 
1099*0Sstevel@tonic-gate int s1394_update_devinfo_tree(s1394_hal_t *hal, s1394_node_t *node);
1100*0Sstevel@tonic-gate 
1101*0Sstevel@tonic-gate int s1394_offline_node(s1394_hal_t *hal, s1394_node_t *node);
1102*0Sstevel@tonic-gate 
1103*0Sstevel@tonic-gate int s1394_process_topology_tree(s1394_hal_t *hal, int *wait_for_cbs,
1104*0Sstevel@tonic-gate     uint_t *wait_gen);
1105*0Sstevel@tonic-gate 
1106*0Sstevel@tonic-gate int s1394_process_old_tree(s1394_hal_t *hal);
1107*0Sstevel@tonic-gate 
1108*0Sstevel@tonic-gate void s1394_add_target_to_node(s1394_target_t *target);
1109*0Sstevel@tonic-gate 
1110*0Sstevel@tonic-gate void s1394_remove_target_from_node(s1394_target_t *target);
1111*0Sstevel@tonic-gate 
1112*0Sstevel@tonic-gate /* fixed address support */
1113*0Sstevel@tonic-gate int s1394_fa_claim_addr(s1394_hal_t *hal, s1394_fa_type_t type,
1114*0Sstevel@tonic-gate     s1394_fa_descr_t *descr);
1115*0Sstevel@tonic-gate 
1116*0Sstevel@tonic-gate void s1394_fa_free_addr(s1394_hal_t *hal, s1394_fa_type_t type);
1117*0Sstevel@tonic-gate 
1118*0Sstevel@tonic-gate void s1394_fa_list_add(s1394_hal_t *hal, s1394_target_t *target,
1119*0Sstevel@tonic-gate     s1394_fa_type_t type);
1120*0Sstevel@tonic-gate 
1121*0Sstevel@tonic-gate int s1394_fa_list_remove(s1394_hal_t *hal, s1394_target_t *target,
1122*0Sstevel@tonic-gate     s1394_fa_type_t type);
1123*0Sstevel@tonic-gate 
1124*0Sstevel@tonic-gate boolean_t s1394_fa_list_is_empty(s1394_hal_t *hal, s1394_fa_type_t type);
1125*0Sstevel@tonic-gate 
1126*0Sstevel@tonic-gate uint_t s1394_fa_list_gen(s1394_hal_t *hal, s1394_fa_type_t type);
1127*0Sstevel@tonic-gate 
1128*0Sstevel@tonic-gate void s1394_fa_init_cmd(s1394_cmd_priv_t *s_priv, s1394_fa_type_t type);
1129*0Sstevel@tonic-gate 
1130*0Sstevel@tonic-gate void s1394_fa_convert_cmd(s1394_hal_t *hal, cmd1394_cmd_t *cmd);
1131*0Sstevel@tonic-gate 
1132*0Sstevel@tonic-gate void s1394_fa_restore_cmd(s1394_hal_t *hal, cmd1394_cmd_t *cmd);
1133*0Sstevel@tonic-gate 
1134*0Sstevel@tonic-gate void s1394_fa_check_restore_cmd(s1394_hal_t *hal, cmd1394_cmd_t *cmd);
1135*0Sstevel@tonic-gate 
1136*0Sstevel@tonic-gate /* FCP */
1137*0Sstevel@tonic-gate int s1394_fcp_hal_init(s1394_hal_t *hal);
1138*0Sstevel@tonic-gate 
1139*0Sstevel@tonic-gate int s1394_fcp_register_ctl(s1394_target_t *target, t1394_fcp_evts_t *evts);
1140*0Sstevel@tonic-gate 
1141*0Sstevel@tonic-gate int s1394_fcp_register_tgt(s1394_target_t *target, t1394_fcp_evts_t *evts);
1142*0Sstevel@tonic-gate 
1143*0Sstevel@tonic-gate int s1394_fcp_unregister_ctl(s1394_target_t *target);
1144*0Sstevel@tonic-gate 
1145*0Sstevel@tonic-gate int s1394_fcp_unregister_tgt(s1394_target_t *target);
1146*0Sstevel@tonic-gate 
1147*0Sstevel@tonic-gate int s1394_fcp_write_check_cmd(cmd1394_cmd_t *cmd);
1148*0Sstevel@tonic-gate 
1149*0Sstevel@tonic-gate /* CMP */
1150*0Sstevel@tonic-gate int s1394_cmp_register(s1394_target_t *target, t1394_cmp_evts_t *evts);
1151*0Sstevel@tonic-gate 
1152*0Sstevel@tonic-gate int s1394_cmp_unregister(s1394_target_t *target);
1153*0Sstevel@tonic-gate 
1154*0Sstevel@tonic-gate int s1394_cmp_read(s1394_target_t *target, t1394_cmp_reg_t reg, uint32_t *valp);
1155*0Sstevel@tonic-gate 
1156*0Sstevel@tonic-gate int s1394_cmp_cas(s1394_target_t *target, t1394_cmp_reg_t reg, uint32_t arg_val,
1157*0Sstevel@tonic-gate     uint32_t new_val, uint32_t *old_valp);
1158*0Sstevel@tonic-gate 
1159*0Sstevel@tonic-gate /* 1394 Services Layer Internals - Isochronous Communication Routines */
1160*0Sstevel@tonic-gate void s1394_isoch_rsrc_realloc(s1394_hal_t *hal);
1161*0Sstevel@tonic-gate 
1162*0Sstevel@tonic-gate void s1394_isoch_rsrc_realloc_notify(s1394_hal_t *hal);
1163*0Sstevel@tonic-gate 
1164*0Sstevel@tonic-gate int s1394_channel_alloc(s1394_hal_t *hal, uint32_t channel_mask,
1165*0Sstevel@tonic-gate     uint_t generation, uint_t flags, uint32_t *old_channels, int *result);
1166*0Sstevel@tonic-gate 
1167*0Sstevel@tonic-gate int s1394_channel_free(s1394_hal_t *hal, uint32_t channel_mask,
1168*0Sstevel@tonic-gate     uint_t generation, uint_t flags, uint32_t *old_channels, int *result);
1169*0Sstevel@tonic-gate 
1170*0Sstevel@tonic-gate int s1394_bandwidth_alloc(s1394_hal_t *hal, uint32_t bw_alloc_units,
1171*0Sstevel@tonic-gate     uint_t generation, int *result);
1172*0Sstevel@tonic-gate 
1173*0Sstevel@tonic-gate uint_t s1394_compute_bw_alloc_units(s1394_hal_t *hal, uint_t bandwidth,
1174*0Sstevel@tonic-gate     uint_t speed);
1175*0Sstevel@tonic-gate 
1176*0Sstevel@tonic-gate int s1394_bandwidth_free(s1394_hal_t *hal, uint32_t bw_alloc_units,
1177*0Sstevel@tonic-gate     uint_t generation, int *result);
1178*0Sstevel@tonic-gate 
1179*0Sstevel@tonic-gate void s1394_isoch_cec_list_insert(s1394_hal_t *hal, s1394_isoch_cec_t *cec);
1180*0Sstevel@tonic-gate 
1181*0Sstevel@tonic-gate void s1394_isoch_cec_list_remove(s1394_hal_t *hal, s1394_isoch_cec_t *cec);
1182*0Sstevel@tonic-gate 
1183*0Sstevel@tonic-gate void s1394_isoch_cec_member_list_insert(s1394_hal_t *hal,
1184*0Sstevel@tonic-gate     s1394_isoch_cec_t *cec, s1394_isoch_cec_member_t *member);
1185*0Sstevel@tonic-gate 
1186*0Sstevel@tonic-gate void s1394_isoch_cec_member_list_remove(s1394_hal_t *hal,
1187*0Sstevel@tonic-gate     s1394_isoch_cec_t *cec, s1394_isoch_cec_member_t *member);
1188*0Sstevel@tonic-gate 
1189*0Sstevel@tonic-gate /* 1394 Services Layer Internals - Miscellaneous Routines */
1190*0Sstevel@tonic-gate void s1394_cleanup_for_detach(s1394_hal_t *hal, uint_t cleanup_level);
1191*0Sstevel@tonic-gate 
1192*0Sstevel@tonic-gate void s1394_hal_shutdown(s1394_hal_t *hal, boolean_t disable_hal);
1193*0Sstevel@tonic-gate 
1194*0Sstevel@tonic-gate void s1394_initiate_hal_reset(s1394_hal_t *hal, int reason);
1195*0Sstevel@tonic-gate 
1196*0Sstevel@tonic-gate boolean_t s1394_on_br_thread(s1394_hal_t *hal);
1197*0Sstevel@tonic-gate 
1198*0Sstevel@tonic-gate void s1394_destroy_br_thread(s1394_hal_t *hal);
1199*0Sstevel@tonic-gate 
1200*0Sstevel@tonic-gate void s1394_tickle_bus_reset_thread(s1394_hal_t *hal);
1201*0Sstevel@tonic-gate 
1202*0Sstevel@tonic-gate void s1394_block_on_asynch_cmd(cmd1394_cmd_t *cmd);
1203*0Sstevel@tonic-gate 
1204*0Sstevel@tonic-gate int s1394_HAL_asynch_error(s1394_hal_t *hal, cmd1394_cmd_t *cmd,
1205*0Sstevel@tonic-gate     s1394_hal_state_t state);
1206*0Sstevel@tonic-gate 
1207*0Sstevel@tonic-gate boolean_t s1394_mblk_too_small(cmd1394_cmd_t *cmd);
1208*0Sstevel@tonic-gate 
1209*0Sstevel@tonic-gate boolean_t s1394_address_rollover(cmd1394_cmd_t *cmd);
1210*0Sstevel@tonic-gate 
1211*0Sstevel@tonic-gate uint_t s1394_stoi(char *p, int len, int base);
1212*0Sstevel@tonic-gate 
1213*0Sstevel@tonic-gate uint_t s1394_CRC16(uint_t *d, uint_t crc_length);
1214*0Sstevel@tonic-gate 
1215*0Sstevel@tonic-gate uint_t s1394_CRC16_old(uint_t *d, uint_t crc_length);
1216*0Sstevel@tonic-gate 
1217*0Sstevel@tonic-gate int s1394_ioctl(s1394_hal_t *hal, int cmd, intptr_t arg, int mode,
1218*0Sstevel@tonic-gate     cred_t *cred_p, int *rval_p);
1219*0Sstevel@tonic-gate 
1220*0Sstevel@tonic-gate void s1394_check_pwr_mgmt(s1394_hal_t *hal, s1394_target_t *target,
1221*0Sstevel@tonic-gate     boolean_t add);
1222*0Sstevel@tonic-gate 
1223*0Sstevel@tonic-gate int s1394_kstat_init(s1394_hal_t *hal);
1224*0Sstevel@tonic-gate 
1225*0Sstevel@tonic-gate int s1394_kstat_delete(s1394_hal_t *hal);
1226*0Sstevel@tonic-gate 
1227*0Sstevel@tonic-gate int s1394_kstat_update(kstat_t *ksp, int rw);
1228*0Sstevel@tonic-gate 
1229*0Sstevel@tonic-gate void s1394_addr_alloc_kstat(s1394_hal_t *hal, uint64_t addr);
1230*0Sstevel@tonic-gate 
1231*0Sstevel@tonic-gate void s1394_print_node_info(s1394_hal_t *hal);
1232*0Sstevel@tonic-gate 
1233*0Sstevel@tonic-gate s1394_hal_t *s1394_dip_to_hal(dev_info_t *dip);
1234*0Sstevel@tonic-gate 
1235*0Sstevel@tonic-gate s1394_target_t *s1394_target_from_dip(s1394_hal_t *hal, dev_info_t *tdip);
1236*0Sstevel@tonic-gate s1394_target_t *s1394_target_from_dip_locked(s1394_hal_t *hal,
1237*0Sstevel@tonic-gate     dev_info_t *tdip);
1238*0Sstevel@tonic-gate 
1239*0Sstevel@tonic-gate void s1394_destroy_timers(s1394_hal_t *hal);
1240*0Sstevel@tonic-gate 
1241*0Sstevel@tonic-gate void s1394_cycle_too_long_callback(void *arg);
1242*0Sstevel@tonic-gate 
1243*0Sstevel@tonic-gate #ifdef __cplusplus
1244*0Sstevel@tonic-gate }
1245*0Sstevel@tonic-gate #endif
1246*0Sstevel@tonic-gate 
1247*0Sstevel@tonic-gate #endif	/* _SYS_1394_S1394_H */
1248