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