xref: /onnv-gate/usr/src/uts/common/sys/1394/t1394.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 1999-2002 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_T1394_H
28*0Sstevel@tonic-gate #define	_SYS_1394_T1394_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  * t1394.h
34*0Sstevel@tonic-gate  *    Contains all of the prototypes, defines, and structures necessary
35*0Sstevel@tonic-gate  *    for building drivers using the Solaris 1394 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 
43*0Sstevel@tonic-gate #include <sys/1394/s1394_impl.h>
44*0Sstevel@tonic-gate #include <sys/1394/cmd1394.h>
45*0Sstevel@tonic-gate #include <sys/1394/id1394.h>
46*0Sstevel@tonic-gate #include <sys/1394/ixl1394.h>
47*0Sstevel@tonic-gate #include <sys/1394/ieee1394.h>
48*0Sstevel@tonic-gate #include <sys/1394/ieee1212.h>
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate #ifdef	__cplusplus
51*0Sstevel@tonic-gate extern "C" {
52*0Sstevel@tonic-gate #endif
53*0Sstevel@tonic-gate 
54*0Sstevel@tonic-gate /*
55*0Sstevel@tonic-gate  * Macro to convert a byte stream into a big endian quadlet or octlet or
56*0Sstevel@tonic-gate  * back the other way.  All data is treated as byte streams over the 1394
57*0Sstevel@tonic-gate  * bus.  These macros will convert the data to a big endian "integer" on
58*0Sstevel@tonic-gate  * x86 platforms, and it will do nothing if it is not on x86.
59*0Sstevel@tonic-gate  */
60*0Sstevel@tonic-gate #ifdef _LITTLE_ENDIAN
61*0Sstevel@tonic-gate #define	T1394_DATA32(DATA)	ddi_swap32(DATA)
62*0Sstevel@tonic-gate #define	T1394_DATA64(DATA)	ddi_swap64(DATA)
63*0Sstevel@tonic-gate #else
64*0Sstevel@tonic-gate #define	T1394_DATA32(DATA)	(DATA)
65*0Sstevel@tonic-gate #define	T1394_DATA64(DATA)	(DATA)
66*0Sstevel@tonic-gate #endif
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate /* The various "handles" returned by the 1394 Framework */
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate /* Target handle type */
71*0Sstevel@tonic-gate typedef struct target_handle	*t1394_handle_t;
72*0Sstevel@tonic-gate /* Address handle type */
73*0Sstevel@tonic-gate typedef struct address_handle	*t1394_addr_handle_t;
74*0Sstevel@tonic-gate /* Isoch single handle type */
75*0Sstevel@tonic-gate typedef struct isoch_handle	*t1394_isoch_single_handle_t;
76*0Sstevel@tonic-gate /* Isoch CEC handle type */
77*0Sstevel@tonic-gate typedef struct isoch_handle	*t1394_isoch_cec_handle_t;
78*0Sstevel@tonic-gate /* Config ROM handle type */
79*0Sstevel@tonic-gate typedef struct cfgrom_handle	*t1394_cfgrom_handle_t;
80*0Sstevel@tonic-gate 
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate /*
83*0Sstevel@tonic-gate  * t1394_localinfo_t
84*0Sstevel@tonic-gate  *    is filled in and returned by the 1394 Framework at attach time
85*0Sstevel@tonic-gate  *    (in the t1394_attachinfo_t structure returned from t1394_attach())
86*0Sstevel@tonic-gate  *    to provide the local host nodeID and the current bus generation.
87*0Sstevel@tonic-gate  */
88*0Sstevel@tonic-gate typedef struct t1394_localinfo_s {
89*0Sstevel@tonic-gate 	uint_t			bus_generation;
90*0Sstevel@tonic-gate 	uint_t			local_nodeID;
91*0Sstevel@tonic-gate } t1394_localinfo_t;
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate /*
94*0Sstevel@tonic-gate  * t1394_attachinfo_t
95*0Sstevel@tonic-gate  *    is filled in and returned by the 1394 Framework at attach time
96*0Sstevel@tonic-gate  *    (returned from the call to t1394_attach()).  This structure contains
97*0Sstevel@tonic-gate  *    the t1394_localinfo_t structure described above, as well as the
98*0Sstevel@tonic-gate  *    iblock cookie and the attributes necessary for DMA allocations, etc.
99*0Sstevel@tonic-gate  */
100*0Sstevel@tonic-gate typedef struct t1394_attachinfo_s {
101*0Sstevel@tonic-gate 	ddi_iblock_cookie_t 	iblock_cookie;
102*0Sstevel@tonic-gate 	ddi_device_acc_attr_t	acc_attr;
103*0Sstevel@tonic-gate 	ddi_dma_attr_t		dma_attr;
104*0Sstevel@tonic-gate 	t1394_localinfo_t	localinfo;
105*0Sstevel@tonic-gate } t1394_attachinfo_t;
106*0Sstevel@tonic-gate 
107*0Sstevel@tonic-gate 
108*0Sstevel@tonic-gate /*
109*0Sstevel@tonic-gate  * t1394_addr_enable_t
110*0Sstevel@tonic-gate  *    is used in the t1394_alloc_addr_t structure, passed to
111*0Sstevel@tonic-gate  *    t1394_alloc_addr(), to indicate what types of (incoming)
112*0Sstevel@tonic-gate  *    asynchronous requests will be allowed in a given address block.
113*0Sstevel@tonic-gate  *    If, for example, an address block is intended to be read-only,
114*0Sstevel@tonic-gate  *    then only the T1394_ADDR_RDENBL bit should be enabled at allocation
115*0Sstevel@tonic-gate  *    time.  Then, when incoming requests of an inappropriate type (write
116*0Sstevel@tonic-gate  *    or lock requests, in this case) arrive, the 1394 Framework can
117*0Sstevel@tonic-gate  *    automatically respond to them with TYPE_ERROR in the response
118*0Sstevel@tonic-gate  *    without having to notify the target driver.
119*0Sstevel@tonic-gate  */
120*0Sstevel@tonic-gate typedef enum {
121*0Sstevel@tonic-gate 	T1394_ADDR_RDENBL =	(1 << 0),
122*0Sstevel@tonic-gate 	T1394_ADDR_WRENBL =	(1 << 1),
123*0Sstevel@tonic-gate 	T1394_ADDR_LKENBL =	(1 << 2)
124*0Sstevel@tonic-gate } t1394_addr_enable_t;
125*0Sstevel@tonic-gate 
126*0Sstevel@tonic-gate /*
127*0Sstevel@tonic-gate  * t1394_addr_type_t
128*0Sstevel@tonic-gate  *    is used in the t1394_alloc_addr_t structure, passed to
129*0Sstevel@tonic-gate  *    t1394_alloc_addr(), to indicate what type of address block the
130*0Sstevel@tonic-gate  *    target driver would like to allocate.
131*0Sstevel@tonic-gate  *    T1394_ADDR_POSTED_WRITE indicates posted write memory, where
132*0Sstevel@tonic-gate  *    incoming write requests are automatically acknowledged as complete.
133*0Sstevel@tonic-gate  *    T1394_ADDR_NORMAL indicates memory, unlike the posted write area,
134*0Sstevel@tonic-gate  *    where all requests regardless of type are ack_pended upon receipt
135*0Sstevel@tonic-gate  *    and are subsequently responded to.
136*0Sstevel@tonic-gate  *    T1394_ADDR_CSR memory range is generally used by target drivers
137*0Sstevel@tonic-gate  *    that are implementing a well-defined protocol.
138*0Sstevel@tonic-gate  *    And T1394_ADDR_FIXED is used to indicate to t1394_alloc_addr()
139*0Sstevel@tonic-gate  *    that a specific set of addresses are needed.  Unlike the other three
140*0Sstevel@tonic-gate  *    types, this type of request is used to choose a specific address or
141*0Sstevel@tonic-gate  *    range of addresses in 1394 address space.
142*0Sstevel@tonic-gate  */
143*0Sstevel@tonic-gate typedef enum {
144*0Sstevel@tonic-gate 	T1394_ADDR_POSTED_WRITE	= 0,
145*0Sstevel@tonic-gate 	T1394_ADDR_NORMAL	= 1,
146*0Sstevel@tonic-gate 	T1394_ADDR_CSR		= 2,
147*0Sstevel@tonic-gate 	T1394_ADDR_FIXED	= 3
148*0Sstevel@tonic-gate } t1394_addr_type_t;
149*0Sstevel@tonic-gate 
150*0Sstevel@tonic-gate /*
151*0Sstevel@tonic-gate  * t1394_addr_evts_t
152*0Sstevel@tonic-gate  *    is used in the t1394_alloc_addr_t structure, passed to
153*0Sstevel@tonic-gate  *    t1394_alloc_addr(), to specify callback routines for the
154*0Sstevel@tonic-gate  *    allocated address block.  When a request of the appropriate type
155*0Sstevel@tonic-gate  *    (read/write/lock) is received to a target driver's address
156*0Sstevel@tonic-gate  *    block, the appropriate callback routine is consulted and if it is
157*0Sstevel@tonic-gate  *    non-NULL it is called and passed a cmd1394_cmd_t structure used to
158*0Sstevel@tonic-gate  *    describe the incoming asynch request.
159*0Sstevel@tonic-gate  */
160*0Sstevel@tonic-gate typedef struct t1394_addr_evts {
161*0Sstevel@tonic-gate 	void	(*recv_read_request)(cmd1394_cmd_t *req);
162*0Sstevel@tonic-gate 	void	(*recv_write_request)(cmd1394_cmd_t *req);
163*0Sstevel@tonic-gate 	void	(*recv_lock_request)(cmd1394_cmd_t *req);
164*0Sstevel@tonic-gate } t1394_addr_evts_t;
165*0Sstevel@tonic-gate 
166*0Sstevel@tonic-gate /*
167*0Sstevel@tonic-gate  * t1394_alloc_addr_t
168*0Sstevel@tonic-gate  *    is passed to t1394_alloc_addr(), when 1394 address space is being
169*0Sstevel@tonic-gate  *    allocated, to describe the type of address space.  The target driver
170*0Sstevel@tonic-gate  *    is responsible for specifying the aa_enable, aa_type, and aa_evts
171*0Sstevel@tonic-gate  *    fields described above as well as the size of the allocated block.
172*0Sstevel@tonic-gate  *    Additionally, the target driver may specify backing store
173*0Sstevel@tonic-gate  *    (aa_kmem_bufp), a specific address (in aa_address if aa_type is
174*0Sstevel@tonic-gate  *    T1394_ADDR_FIXED), and a callback argument (in aa_arg) to be
175*0Sstevel@tonic-gate  *    passed to the target in any of its callback routines.
176*0Sstevel@tonic-gate  *    When it returns, t1394_alloc_addr() will return in aa_address the
177*0Sstevel@tonic-gate  *    starting address of the requested block of 1394 address space and
178*0Sstevel@tonic-gate  *    and address block handle (aa_hdl) used to free the address block
179*0Sstevel@tonic-gate  *    in a call to t1394_free_addr().
180*0Sstevel@tonic-gate  */
181*0Sstevel@tonic-gate typedef struct t1394_alloc_addr {
182*0Sstevel@tonic-gate 	t1394_addr_type_t	aa_type;	/* IN: address region */
183*0Sstevel@tonic-gate 	size_t			aa_length;	/* IN: # bytes requested */
184*0Sstevel@tonic-gate 	t1394_addr_enable_t	aa_enable;	/* IN: request enables */
185*0Sstevel@tonic-gate 	t1394_addr_evts_t	aa_evts;	/* IN: event callbacks */
186*0Sstevel@tonic-gate 	opaque_t		aa_arg;		/* IN: evt callback arg */
187*0Sstevel@tonic-gate 	caddr_t			aa_kmem_bufp;	/* IN: backing-store buf */
188*0Sstevel@tonic-gate 	uint64_t		aa_address;	/* IN/OUT: alloced address */
189*0Sstevel@tonic-gate 	t1394_addr_handle_t	aa_hdl;		/* OUT: returned to target */
190*0Sstevel@tonic-gate } t1394_alloc_addr_t;
191*0Sstevel@tonic-gate 
192*0Sstevel@tonic-gate /*
193*0Sstevel@tonic-gate  * t1394_fcp_evts_t
194*0Sstevel@tonic-gate  *    is used in t1394_fcp_register_controller(). FCP only allows writes.
195*0Sstevel@tonic-gate  */
196*0Sstevel@tonic-gate typedef struct t1394_fcp_evts {
197*0Sstevel@tonic-gate 	int		(*fcp_write_request)(cmd1394_cmd_t *req);
198*0Sstevel@tonic-gate 	opaque_t	fcp_arg;
199*0Sstevel@tonic-gate } t1394_fcp_evts_t;
200*0Sstevel@tonic-gate 
201*0Sstevel@tonic-gate /* values returned by the FCP callback */
202*0Sstevel@tonic-gate enum {
203*0Sstevel@tonic-gate 	T1394_REQ_CLAIMED,	/* request is recognized by the target */
204*0Sstevel@tonic-gate 	T1394_REQ_UNCLAIMED	/* request is not recognized by the target */
205*0Sstevel@tonic-gate };
206*0Sstevel@tonic-gate 
207*0Sstevel@tonic-gate /*
208*0Sstevel@tonic-gate  * t1394_cmp_reg_t
209*0Sstevel@tonic-gate  *    CMP register types
210*0Sstevel@tonic-gate  */
211*0Sstevel@tonic-gate typedef enum {
212*0Sstevel@tonic-gate 	T1394_CMP_OMPR,		/* oMPR */
213*0Sstevel@tonic-gate 	T1394_CMP_IMPR		/* iMPR */
214*0Sstevel@tonic-gate } t1394_cmp_reg_t;
215*0Sstevel@tonic-gate 
216*0Sstevel@tonic-gate /*
217*0Sstevel@tonic-gate  * t1394_cmp_evts_t
218*0Sstevel@tonic-gate  *    is used in t1394_cmp_register().
219*0Sstevel@tonic-gate  */
220*0Sstevel@tonic-gate typedef struct t1394_cmp_evts {
221*0Sstevel@tonic-gate 	void		(*cmp_reg_change)(opaque_t, t1394_cmp_reg_t);
222*0Sstevel@tonic-gate 	opaque_t	cmp_arg;
223*0Sstevel@tonic-gate } t1394_cmp_evts_t;
224*0Sstevel@tonic-gate 
225*0Sstevel@tonic-gate /*
226*0Sstevel@tonic-gate  * t1394_isoch_rsrc_error_t
227*0Sstevel@tonic-gate  *    is used in the rsrc_fail_target() callback to indicate the reason
228*0Sstevel@tonic-gate  *    for the resource allocation failure.  T1394_RSRC_BANDWIDTH indicates
229*0Sstevel@tonic-gate  *    that insufficient bandwidth was available for the requested allocation,
230*0Sstevel@tonic-gate  *    and T1394_RSRC_CHANNEL indicates that none of the requested channels
231*0Sstevel@tonic-gate  *    were available.
232*0Sstevel@tonic-gate  */
233*0Sstevel@tonic-gate typedef enum {
234*0Sstevel@tonic-gate 	T1394_RSRC_BANDWIDTH	= 1,
235*0Sstevel@tonic-gate 	T1394_RSRC_CHANNEL	= 2
236*0Sstevel@tonic-gate } t1394_isoch_rsrc_error_t;
237*0Sstevel@tonic-gate 
238*0Sstevel@tonic-gate /*
239*0Sstevel@tonic-gate  * t1394_isoch_singleinfo_t
240*0Sstevel@tonic-gate  *    is passed to the t1394_alloc_isoch_single() routine.  A target
241*0Sstevel@tonic-gate  *    driver will use this structure to indicate the channels it supports,
242*0Sstevel@tonic-gate  *    the maximum speed for the isochronous channel, the amount of
243*0Sstevel@tonic-gate  *    bandwidth required, and the callback (and callback arg) to be used
244*0Sstevel@tonic-gate  *    when notifying the target of resource reallocation failures.
245*0Sstevel@tonic-gate  */
246*0Sstevel@tonic-gate typedef struct t1394_isoch_singleinfo_s {
247*0Sstevel@tonic-gate 	uint64_t	si_channel_mask;	/* channels supported */
248*0Sstevel@tonic-gate 	uint_t		si_speed;		/* 1394 speed for the channel */
249*0Sstevel@tonic-gate 	uint_t		si_bandwidth;		/* max bytes per cycle */
250*0Sstevel@tonic-gate 	void		(*rsrc_fail_target)(
251*0Sstevel@tonic-gate 			    t1394_isoch_single_handle_t	t1394_single_hdl,
252*0Sstevel@tonic-gate 			    opaque_t			single_evt_arg,
253*0Sstevel@tonic-gate 			    t1394_isoch_rsrc_error_t	fail_args);
254*0Sstevel@tonic-gate 	opaque_t	single_evt_arg;
255*0Sstevel@tonic-gate } t1394_isoch_singleinfo_t;
256*0Sstevel@tonic-gate 
257*0Sstevel@tonic-gate /*
258*0Sstevel@tonic-gate  * t1394_isoch_single_out_t
259*0Sstevel@tonic-gate  *    is filled in and returned to the target by the
260*0Sstevel@tonic-gate  *    t1394_alloc_isoch_single() routine.  It indicates the number of the
261*0Sstevel@tonic-gate  *    channel that was actually allocated for the target driver.  This
262*0Sstevel@tonic-gate  *    channel number will typically be used by a target driver to setup
263*0Sstevel@tonic-gate  *    isochronous DMA or other resources.
264*0Sstevel@tonic-gate  */
265*0Sstevel@tonic-gate typedef struct t1394_isoch_single_out_s {
266*0Sstevel@tonic-gate 	uint_t		channel_num;	/* number for the allocated channel */
267*0Sstevel@tonic-gate } t1394_isoch_single_out_t;
268*0Sstevel@tonic-gate 
269*0Sstevel@tonic-gate /*
270*0Sstevel@tonic-gate  * t1394_setup_target_args_t
271*0Sstevel@tonic-gate  *    is used in the setup_target() callback to indicate the channel number
272*0Sstevel@tonic-gate  *    and channel speed for the isochronous channel coordinated by the
273*0Sstevel@tonic-gate  *    Isoch CEC routines.
274*0Sstevel@tonic-gate  */
275*0Sstevel@tonic-gate typedef struct t1394_setup_target_args_s {
276*0Sstevel@tonic-gate 	uint_t		channel_num;	/* number for the allocated channel */
277*0Sstevel@tonic-gate 	uint_t		channel_speed;	/* 1394 speed for the channel */
278*0Sstevel@tonic-gate } t1394_setup_target_args_t;
279*0Sstevel@tonic-gate 
280*0Sstevel@tonic-gate /*
281*0Sstevel@tonic-gate  * t1394_cec_options_t
282*0Sstevel@tonic-gate  *    is used in the t1394_isoch_cec_props_t structure, passed to
283*0Sstevel@tonic-gate  *    t1394_alloc_isoch_cec().  As the cec_options field in that
284*0Sstevel@tonic-gate  *    structure, it can be used to request that the 1394 Framework
285*0Sstevel@tonic-gate  *    NOT automatically reallocate the same isochronous channel and
286*0Sstevel@tonic-gate  *    bandwidth, if a bus reset happens.  The default behavior is to
287*0Sstevel@tonic-gate  *    let the 1394 Framework attempt to reallocate the same channel and
288*0Sstevel@tonic-gate  *    bandwidth the target had after a bus reset, but some target drivers
289*0Sstevel@tonic-gate  *    may not require this functionality and they therefore have the option
290*0Sstevel@tonic-gate  *    to decline this service.
291*0Sstevel@tonic-gate  */
292*0Sstevel@tonic-gate typedef enum {
293*0Sstevel@tonic-gate 	T1394_NO_IRM_ALLOC	= (1 << 0)
294*0Sstevel@tonic-gate } t1394_cec_options_t;
295*0Sstevel@tonic-gate 
296*0Sstevel@tonic-gate /*
297*0Sstevel@tonic-gate  * t1394_isoch_cec_props_t
298*0Sstevel@tonic-gate  *    is used in calls to the t1394_alloc_isoch_cec() routine.  The
299*0Sstevel@tonic-gate  *    minimum and maximum speeds, channels supported, and the amount
300*0Sstevel@tonic-gate  *    of bandwidth necessary for the channel are specified.  These
301*0Sstevel@tonic-gate  *    characteristics of the Isoch CEC are specified at allocation time
302*0Sstevel@tonic-gate  *    and are used to pass or fail targets that try to join the Isoch
303*0Sstevel@tonic-gate  *    CEC later.
304*0Sstevel@tonic-gate  */
305*0Sstevel@tonic-gate typedef struct t1394_isoch_cec_props_s {
306*0Sstevel@tonic-gate 	uint_t			cec_min_speed;	  /* min speed supported */
307*0Sstevel@tonic-gate 	uint_t			cec_max_speed;	  /* max speed supported */
308*0Sstevel@tonic-gate 	uint64_t		cec_channel_mask; /* channels supported  */
309*0Sstevel@tonic-gate 	uint_t			cec_bandwidth;	  /* max bytes per cycle */
310*0Sstevel@tonic-gate 	t1394_cec_options_t	cec_options;
311*0Sstevel@tonic-gate } t1394_isoch_cec_props_t;
312*0Sstevel@tonic-gate 
313*0Sstevel@tonic-gate /*
314*0Sstevel@tonic-gate  * t1394_isoch_cec_evts_t
315*0Sstevel@tonic-gate  *    is used in the t1394_join_isochinfo_t structure, passed to
316*0Sstevel@tonic-gate  *    t1394_join_isoch_cec().  This structure is a list of callbacks
317*0Sstevel@tonic-gate  *    for each of the various events the Isoch CEC is responsible for
318*0Sstevel@tonic-gate  *    coordinating.
319*0Sstevel@tonic-gate  *    The setup_target() callback is called after the isochronous
320*0Sstevel@tonic-gate  *    channel and bandwidth for the Isoch CEC have been allocated
321*0Sstevel@tonic-gate  *    (as a result of a call to t1394_setup_isoch_cec()) to inform the
322*0Sstevel@tonic-gate  *    member targets of the channel number and speed.
323*0Sstevel@tonic-gate  *    The start_target() callback is called for all member targets
324*0Sstevel@tonic-gate  *    as a result of a call to t1394_start_isoch_cec().
325*0Sstevel@tonic-gate  *    The stop_target() callback is called for all member targets
326*0Sstevel@tonic-gate  *    as a result of a call to t1394_stop_isoch_cec().
327*0Sstevel@tonic-gate  *    The rsrc_fail_target() callback (as mentioned above) is called
328*0Sstevel@tonic-gate  *    to indicate that the 1394 Framework was unable to reallocate
329*0Sstevel@tonic-gate  *    isochronous resources and the reason for the failure.
330*0Sstevel@tonic-gate  *    And the teardown_target() callback is called as a result of
331*0Sstevel@tonic-gate  *    a call to t1394_teardown_isoch_cec() to indicate that the
332*0Sstevel@tonic-gate  *    isochronous channel and bandwidth are being freed up.
333*0Sstevel@tonic-gate  */
334*0Sstevel@tonic-gate typedef struct t1394_isoch_cec_evts_s {
335*0Sstevel@tonic-gate 	int	(*setup_target)(
336*0Sstevel@tonic-gate 		    t1394_isoch_cec_handle_t		t1394_isoch_cec_hdl,
337*0Sstevel@tonic-gate 		    opaque_t				isoch_cec_evts_arg,
338*0Sstevel@tonic-gate 		    t1394_setup_target_args_t		*setup_args);
339*0Sstevel@tonic-gate 	int	(*start_target)(
340*0Sstevel@tonic-gate 		    t1394_isoch_cec_handle_t		t1394_isoch_cec_hdl,
341*0Sstevel@tonic-gate 		    opaque_t				isoch_cec_evts_arg);
342*0Sstevel@tonic-gate 	void	(*stop_target)(
343*0Sstevel@tonic-gate 		    t1394_isoch_cec_handle_t		t1394_isoch_cec_hdl,
344*0Sstevel@tonic-gate 		    opaque_t				isoch_cec_evts_arg);
345*0Sstevel@tonic-gate 	void	(*rsrc_fail_target)(
346*0Sstevel@tonic-gate 		    t1394_isoch_cec_handle_t		t1394_isoch_cec_hdl,
347*0Sstevel@tonic-gate 		    opaque_t				isoch_cec_evts_arg,
348*0Sstevel@tonic-gate 		    t1394_isoch_rsrc_error_t		fail_args);
349*0Sstevel@tonic-gate 	void	(*teardown_target)(
350*0Sstevel@tonic-gate 		    t1394_isoch_cec_handle_t		t1394_isoch_cec_hdl,
351*0Sstevel@tonic-gate 		    opaque_t				isoch_cec_evts_arg);
352*0Sstevel@tonic-gate } t1394_isoch_cec_evts_t;
353*0Sstevel@tonic-gate 
354*0Sstevel@tonic-gate /*
355*0Sstevel@tonic-gate  * t1394_jii_options_t
356*0Sstevel@tonic-gate  *    is used in the t1394_join_isochinfo_t structure, passed to
357*0Sstevel@tonic-gate  *    t1394_join_isoch_cec().  As the jii_options field in that
358*0Sstevel@tonic-gate  *    structure, it is used to indicate to the 1394 Framework
359*0Sstevel@tonic-gate  *    that the member target is the talker on the channel.  There can
360*0Sstevel@tonic-gate  *    be no more than one talker per Isoch CEC, and a member target
361*0Sstevel@tonic-gate  *    may fail in t1394_join_isoch_cec() because there is already a
362*0Sstevel@tonic-gate  *    talker on the Isoch CEC.
363*0Sstevel@tonic-gate  */
364*0Sstevel@tonic-gate typedef enum {
365*0Sstevel@tonic-gate 	T1394_TALKER		= (1 << 0)
366*0Sstevel@tonic-gate } t1394_jii_options_t;
367*0Sstevel@tonic-gate 
368*0Sstevel@tonic-gate /*
369*0Sstevel@tonic-gate  * t1394_join_isochinfo_t
370*0Sstevel@tonic-gate  *    is used in calls to the t1394_join_isoch_cec() routine.  The
371*0Sstevel@tonic-gate  *    req_channel_mask field indicate the channels that a member
372*0Sstevel@tonic-gate  *    target can support.  If these channels are inconsistent with
373*0Sstevel@tonic-gate  *    the characteristics passed in at allocation or with the current
374*0Sstevel@tonic-gate  *    characteristics of the other members of the Isoch CEC, then the
375*0Sstevel@tonic-gate  *    t1394_join_isoch_cec() call will fail.
376*0Sstevel@tonic-gate  *    The req_max_speed field is used similarly.  If the member target's
377*0Sstevel@tonic-gate  *    maximum speed is inconsistent with the other members of the
378*0Sstevel@tonic-gate  *    Isoch CEC, then the t1394_join_isoch_cec() will fail.
379*0Sstevel@tonic-gate  *    In addition to the above fields, a joining member target will pass
380*0Sstevel@tonic-gate  *    the jii_options (indicate talker or listener), the callbacks and
381*0Sstevel@tonic-gate  *    the callback arg (see above).
382*0Sstevel@tonic-gate  */
383*0Sstevel@tonic-gate typedef struct t1394_join_isochinfo_s {
384*0Sstevel@tonic-gate 	uint64_t		req_channel_mask; /* target chnls supported */
385*0Sstevel@tonic-gate 	uint_t			req_max_speed;	  /* target max_speed */
386*0Sstevel@tonic-gate 	t1394_jii_options_t	jii_options;
387*0Sstevel@tonic-gate 	opaque_t		isoch_cec_evts_arg;
388*0Sstevel@tonic-gate 	t1394_isoch_cec_evts_t	isoch_cec_evts;
389*0Sstevel@tonic-gate } t1394_join_isochinfo_t;
390*0Sstevel@tonic-gate 
391*0Sstevel@tonic-gate 
392*0Sstevel@tonic-gate /*
393*0Sstevel@tonic-gate  * t1394_targetinfo_t
394*0Sstevel@tonic-gate  *    is used in calls to the t1394_get_targetinfo() routine.  The
395*0Sstevel@tonic-gate  *    structure returned to the target contains current_max_payload,
396*0Sstevel@tonic-gate  *    the default maximum block size that the host device will use in
397*0Sstevel@tonic-gate  *    asynchronous block reads and writes to the target's device.
398*0Sstevel@tonic-gate  *    It also contains current_max_speed,  the default maximum speed at
399*0Sstevel@tonic-gate  *    which the host device will communicate with the target's device.
400*0Sstevel@tonic-gate  *    The structure also contains the target driver's target nodeID,
401*0Sstevel@tonic-gate  *    the number assigned to the device for the current bus
402*0Sstevel@tonic-gate  *    generation.  It will contain T1394_INVALID_NODEID if the target
403*0Sstevel@tonic-gate  *    device is no longer connected to the 1394 Serial Bus.
404*0Sstevel@tonic-gate  */
405*0Sstevel@tonic-gate typedef struct t1394_targetinfo_s {
406*0Sstevel@tonic-gate 	uint_t			current_max_payload;
407*0Sstevel@tonic-gate 	uint_t			current_max_speed;
408*0Sstevel@tonic-gate 	uint_t			target_nodeID;
409*0Sstevel@tonic-gate } t1394_targetinfo_t;
410*0Sstevel@tonic-gate #define	T1394_INVALID_NODEID	0xFFFF
411*0Sstevel@tonic-gate 
412*0Sstevel@tonic-gate /*
413*0Sstevel@tonic-gate  * t1394_cfgrom_entryinfo_t
414*0Sstevel@tonic-gate  *    is used in calls to the t1394_add_cfgrom_entry() routine.  The
415*0Sstevel@tonic-gate  *    t1394_cfgrom_entryinfo_t structure contains the information necessary
416*0Sstevel@tonic-gate  *    to add the Config ROM entry.  The ce_buffer and ce_size are used to
417*0Sstevel@tonic-gate  *    describe the data to be added, and the ce_key is used to indicate
418*0Sstevel@tonic-gate  *    what type of entry in the Config ROM buffer the data represents
419*0Sstevel@tonic-gate  *    (see ieee1212.h fro key types).
420*0Sstevel@tonic-gate  */
421*0Sstevel@tonic-gate typedef struct t1394_cfgrom_entryinfo_s {
422*0Sstevel@tonic-gate 	uint_t			ce_key;		/* key for Root Dir. entry */
423*0Sstevel@tonic-gate 	size_t			ce_size;	/* size of the buffer */
424*0Sstevel@tonic-gate 	uint32_t		*ce_buffer;	/* buffer for Config ROM data */
425*0Sstevel@tonic-gate } t1394_cfgrom_entryinfo_t;
426*0Sstevel@tonic-gate 
427*0Sstevel@tonic-gate 
428*0Sstevel@tonic-gate 
429*0Sstevel@tonic-gate /*
430*0Sstevel@tonic-gate  * ATTACH and DETACH:
431*0Sstevel@tonic-gate  *    These are the calls into 1394 Framework used during target driver
432*0Sstevel@tonic-gate  *    attach() and detach().  The t1394_attach() routine takes a dip and
433*0Sstevel@tonic-gate  *    a version (T1394_VERSION_V1) as its input arguments, and it fills
434*0Sstevel@tonic-gate  *    in and returns a t1394_attachinfo_t structure (described above) and
435*0Sstevel@tonic-gate  *    the t1394_handle_t.  This target handle is used in all subsequent
436*0Sstevel@tonic-gate  *    calls into the 1394 Framework.
437*0Sstevel@tonic-gate  *    The t1394_detach() routine is called from a target driver's detach()
438*0Sstevel@tonic-gate  *    routine to unregister itself from the 1394 Framework.
439*0Sstevel@tonic-gate  */
440*0Sstevel@tonic-gate int t1394_attach(dev_info_t *dip, int version, uint_t flags,
441*0Sstevel@tonic-gate     t1394_attachinfo_t *attachinfo, t1394_handle_t *t1394_hdl);
442*0Sstevel@tonic-gate /* Version value */
443*0Sstevel@tonic-gate #define	T1394_VERSION_V1	1
444*0Sstevel@tonic-gate 
445*0Sstevel@tonic-gate int t1394_detach(t1394_handle_t *t1394_hdl, uint_t flags);
446*0Sstevel@tonic-gate 
447*0Sstevel@tonic-gate 
448*0Sstevel@tonic-gate /*
449*0Sstevel@tonic-gate  * OUTGOING ASYNCHRONOUS COMMANDS:
450*0Sstevel@tonic-gate  *    These are the calls into 1394 Framework used for allocating/freeing
451*0Sstevel@tonic-gate  *    and sending (outgoing) asynchronous requests.  The t1394_alloc_cmd()
452*0Sstevel@tonic-gate  *    routine takes a target driver's handle as an input argument and
453*0Sstevel@tonic-gate  *    returns the cmd1394_cmd_t structure necessary for sending asynch
454*0Sstevel@tonic-gate  *    requests.  The flags parameter is used to indicate whether or not the
455*0Sstevel@tonic-gate  *    1394 Framework may sleep while allocating memory for the command.
456*0Sstevel@tonic-gate  *    The t1394_free_cmd() routine is used to free up commands allocated
457*0Sstevel@tonic-gate  *    by t1394_alloc_cmd().  Commands should not be in use at the time
458*0Sstevel@tonic-gate  *    t1394_free_cmd() is called or the call may fail (return DDI_FAILURE).
459*0Sstevel@tonic-gate  *    After an asynch command has been allocated and filled in (see
460*0Sstevel@tonic-gate  *    the cmd1394.h file for more details) to indicate the type of request,
461*0Sstevel@tonic-gate  *    what types of options are necessary, callback functions and/or data
462*0Sstevel@tonic-gate  *    (if necessary), the command is passed to either t1394_read(),
463*0Sstevel@tonic-gate  *    t1394_write(), or t1394_lock().  These routines will return DDI_SUCCESS
464*0Sstevel@tonic-gate  *    or DDI_FAILURE depending on whether the command has been successfully
465*0Sstevel@tonic-gate  *    accepted by the 1394 Framework.  If the command is a "blocking"
466*0Sstevel@tonic-gate  *    command, the function will not return until the command has completed.
467*0Sstevel@tonic-gate  *    If, however, a callback has been specified in the command, that
468*0Sstevel@tonic-gate  *    function will be called when the command completes.
469*0Sstevel@tonic-gate  */
470*0Sstevel@tonic-gate int t1394_alloc_cmd(t1394_handle_t t1394_hdl, uint_t flags,
471*0Sstevel@tonic-gate     cmd1394_cmd_t **cmdp);
472*0Sstevel@tonic-gate /* Flags passed to t1394_alloc_cmd() */
473*0Sstevel@tonic-gate #define	T1394_ALLOC_CMD_NOSLEEP		0x00000001 /* don't sleep in alloc */
474*0Sstevel@tonic-gate #define	T1394_ALLOC_CMD_FCP_COMMAND	0x00010000 /* FCP command */
475*0Sstevel@tonic-gate #define	T1394_ALLOC_CMD_FCP_RESPONSE	0x00020000 /* FCP response */
476*0Sstevel@tonic-gate 
477*0Sstevel@tonic-gate int t1394_free_cmd(t1394_handle_t t1394_hdl, uint_t flags,
478*0Sstevel@tonic-gate     cmd1394_cmd_t **cmdp);
479*0Sstevel@tonic-gate 
480*0Sstevel@tonic-gate int t1394_read(t1394_handle_t t1394_hdl, cmd1394_cmd_t *cmd);
481*0Sstevel@tonic-gate 
482*0Sstevel@tonic-gate int t1394_write(t1394_handle_t t1394_hdl, cmd1394_cmd_t *cmd);
483*0Sstevel@tonic-gate 
484*0Sstevel@tonic-gate int t1394_lock(t1394_handle_t t1394_hdl, cmd1394_cmd_t *cmd);
485*0Sstevel@tonic-gate 
486*0Sstevel@tonic-gate 
487*0Sstevel@tonic-gate /*
488*0Sstevel@tonic-gate  * 1394 ADDRESS SPACE AND INCOMING ASYNCHRONOUS COMMANDS:
489*0Sstevel@tonic-gate  *    These are the calls into the 1394 Framework used for allocating/freeing
490*0Sstevel@tonic-gate  *    1394 address space and handling incoming asynchronous requests.  The
491*0Sstevel@tonic-gate  *    t1394_alloc_addr() routine is used to allocate 1394 address space.  It
492*0Sstevel@tonic-gate  *    is passed the target handle and a t1394_alloc_addr_t structure
493*0Sstevel@tonic-gate  *    (described above).
494*0Sstevel@tonic-gate  *    The t1394_free_addr() routine is used to free any allocated address
495*0Sstevel@tonic-gate  *    space that the target may have.  Typically, this will be done in a
496*0Sstevel@tonic-gate  *    target driver's detach() routine (before calling t1394_detach()).
497*0Sstevel@tonic-gate  *    The t1394_recv_request_done() routine is used after a target has
498*0Sstevel@tonic-gate  *    received and handled an incoming asynch request.  It is used to send
499*0Sstevel@tonic-gate  *    a response to the request.  After the command is sent to
500*0Sstevel@tonic-gate  *    t1394_recv_request_done(), it should not be modified or used because
501*0Sstevel@tonic-gate  *    the 1394 Framework may free it up without notifying the target driver.
502*0Sstevel@tonic-gate  */
503*0Sstevel@tonic-gate int t1394_alloc_addr(t1394_handle_t t1394_hdl, t1394_alloc_addr_t *addr_allocp,
504*0Sstevel@tonic-gate     uint_t flags, int *result);
505*0Sstevel@tonic-gate /* Results codes returned by t1394_alloc_addr() */
506*0Sstevel@tonic-gate #define	T1394_EALLOC_ADDR		(-400)
507*0Sstevel@tonic-gate #define	T1394_EADDR_FIRST		T1394_EALLOC_ADDR
508*0Sstevel@tonic-gate #define	T1394_EADDR_LAST		T1394_EALLOC_ADDR
509*0Sstevel@tonic-gate /*
510*0Sstevel@tonic-gate  * NOTE: Make sure T1394_EADDR_LAST is updated if a new error code is
511*0Sstevel@tonic-gate  * added. t1394_errmsg.c uses *FIRST and *LAST as bounds checks.
512*0Sstevel@tonic-gate  */
513*0Sstevel@tonic-gate 
514*0Sstevel@tonic-gate int t1394_free_addr(t1394_handle_t t1394_hdl, t1394_addr_handle_t *addr_hdl,
515*0Sstevel@tonic-gate     uint_t flags);
516*0Sstevel@tonic-gate 
517*0Sstevel@tonic-gate int t1394_recv_request_done(t1394_handle_t t1394_hdl, cmd1394_cmd_t *resp,
518*0Sstevel@tonic-gate     uint_t flags);
519*0Sstevel@tonic-gate 
520*0Sstevel@tonic-gate 
521*0Sstevel@tonic-gate /*
522*0Sstevel@tonic-gate  * FCP SERVICES:
523*0Sstevel@tonic-gate  *    Function Control Protocol (FCP) is defined in IEC 61883-1 and supported
524*0Sstevel@tonic-gate  *    by the 1394 Framework. While target drivers could use t1394_alloc_addr()
525*0Sstevel@tonic-gate  *    and standard asynchronous services, only one driver could use FCP at a
526*0Sstevel@tonic-gate  *    time, because the FCP addresses have fixed values. To allow sharing of
527*0Sstevel@tonic-gate  *    FCP address space, the following Framework services should be used.
528*0Sstevel@tonic-gate  *
529*0Sstevel@tonic-gate  *    t1394_fcp_register_controller() registers the target as an FCP controller,
530*0Sstevel@tonic-gate  *    which allows it to write into target's FCP command register and receive
531*0Sstevel@tonic-gate  *    write requests into host's FCP response register. It takes a valid
532*0Sstevel@tonic-gate  *    t1394_handle_t argument, hence it should be called after t1394_attach().
533*0Sstevel@tonic-gate  *    t1394_fcp_unregister_controller() unregisters the target.
534*0Sstevel@tonic-gate  *
535*0Sstevel@tonic-gate  *    t1394_fcp_register_target() and t1394_fcp_unregister_target() are
536*0Sstevel@tonic-gate  *    target counterparts of the above controller functions.
537*0Sstevel@tonic-gate  */
538*0Sstevel@tonic-gate 
539*0Sstevel@tonic-gate int t1394_fcp_register_controller(t1394_handle_t t1394_hdl,
540*0Sstevel@tonic-gate     t1394_fcp_evts_t *evts, uint_t flags);
541*0Sstevel@tonic-gate 
542*0Sstevel@tonic-gate int t1394_fcp_unregister_controller(t1394_handle_t t1394_hdl);
543*0Sstevel@tonic-gate 
544*0Sstevel@tonic-gate int t1394_fcp_register_target(t1394_handle_t t1394_hdl,
545*0Sstevel@tonic-gate     t1394_fcp_evts_t *evts, uint_t flags);
546*0Sstevel@tonic-gate 
547*0Sstevel@tonic-gate int t1394_fcp_unregister_target(t1394_handle_t t1394_hdl);
548*0Sstevel@tonic-gate 
549*0Sstevel@tonic-gate 
550*0Sstevel@tonic-gate /*
551*0Sstevel@tonic-gate  * CMP services:
552*0Sstevel@tonic-gate  *    Connection Management Procedures (CMP) is defined in IEC 61883-1 and
553*0Sstevel@tonic-gate  *    supported by the 1394 Framework by providing the drivers with shared
554*0Sstevel@tonic-gate  *    access to iMPR and oMPR registers, which are created by the Framework
555*0Sstevel@tonic-gate  *    when t1394_cmp_register() is called and destroyed when
556*0Sstevel@tonic-gate  *    t1394_cmp_unregister() is called. These registers can be read using
557*0Sstevel@tonic-gate  *    t1394_cmp_read() function and compare-swapped using t1394_cmp_cas().
558*0Sstevel@tonic-gate  *
559*0Sstevel@tonic-gate  *    oPCR and iPCR registers can be allocated by the drivers using
560*0Sstevel@tonic-gate  *    t1394_alloc_addr() function.
561*0Sstevel@tonic-gate  */
562*0Sstevel@tonic-gate int t1394_cmp_register(t1394_handle_t t1394_hdl, t1394_cmp_evts_t *evts,
563*0Sstevel@tonic-gate     uint_t flags);
564*0Sstevel@tonic-gate 
565*0Sstevel@tonic-gate int t1394_cmp_unregister(t1394_handle_t t1394_hdl);
566*0Sstevel@tonic-gate 
567*0Sstevel@tonic-gate int t1394_cmp_read(t1394_handle_t t1394_hdl, t1394_cmp_reg_t reg,
568*0Sstevel@tonic-gate     uint32_t *valp);
569*0Sstevel@tonic-gate 
570*0Sstevel@tonic-gate int t1394_cmp_cas(t1394_handle_t t1394_hdl, t1394_cmp_reg_t reg,
571*0Sstevel@tonic-gate     uint32_t arg_val, uint32_t new_val, uint32_t *old_valp);
572*0Sstevel@tonic-gate 
573*0Sstevel@tonic-gate 
574*0Sstevel@tonic-gate /*
575*0Sstevel@tonic-gate  * ISOCHRONOUS SERVICES:
576*0Sstevel@tonic-gate  *    These are the calls into the 1394 Framework used for isochronous
577*0Sstevel@tonic-gate  *    services. The t1394_alloc_isoch_single() routine takes a target
578*0Sstevel@tonic-gate  *    handle and a t1394_isoch_singleinfo_t structure (see above).  It will
579*0Sstevel@tonic-gate  *    attempt to setup an isochronous channel (which will be automatically
580*0Sstevel@tonic-gate  *    reallocated after bus resets), and it will return the channel number
581*0Sstevel@tonic-gate  *    of the allocated channel in the t1394_isoch_single_out_t structure.
582*0Sstevel@tonic-gate  *    Additionally, it returns a t1394_isoch_single_handle_t structure
583*0Sstevel@tonic-gate  *    which is passed to t1394_free_isoch_single() when the isochronous
584*0Sstevel@tonic-gate  *    channel is no longer required.
585*0Sstevel@tonic-gate  *    The t1394_alloc_isoch_cec() and t1394_free_isoch_cec() are used to
586*0Sstevel@tonic-gate  *    allocate and free an Isoch Channel Event Coordinator (CEC).  Target
587*0Sstevel@tonic-gate  *    drivers pass a t1394_isoch_cec_props_t structure (described above)
588*0Sstevel@tonic-gate  *    to specify the initial characteristics of the Isoch CEC.
589*0Sstevel@tonic-gate  *    Targets will subsequently join the Isoch CEC with t1394_join_isoch_cec()
590*0Sstevel@tonic-gate  *    before setting up the channel with t1394_setup_isoch_cec().
591*0Sstevel@tonic-gate  *    Calls to t1394_join_isoch_cec() are used by targets who wish to join
592*0Sstevel@tonic-gate  *    the Isoch CEC and receive all of the channel event notifications.
593*0Sstevel@tonic-gate  *    When they want to leave target drivers call t1394_leave_isoch_cec().
594*0Sstevel@tonic-gate  *    The t1394_setup_isoch_cec(), as described above, is used to setup the
595*0Sstevel@tonic-gate  *    the isochronous channel and bandwidth and to notify all member targets
596*0Sstevel@tonic-gate  *    of the allocated channel number and speed.  After targets have finished
597*0Sstevel@tonic-gate  *    using the isoch channel, the resources can be torn down with a call to
598*0Sstevel@tonic-gate  *    t1394_teardown_isoch_cec().
599*0Sstevel@tonic-gate  *    Additionally, the t1394_start_isoch_cec() and t1394_stop_isoch_cec()
600*0Sstevel@tonic-gate  *    routines can be used by member targets to coordinate additional events,
601*0Sstevel@tonic-gate  *    such as the starting and stopping of isochronous DMA or other resources.
602*0Sstevel@tonic-gate  */
603*0Sstevel@tonic-gate int t1394_alloc_isoch_single(t1394_handle_t t1394_hdl,
604*0Sstevel@tonic-gate     t1394_isoch_singleinfo_t *sii, uint_t flags,
605*0Sstevel@tonic-gate     t1394_isoch_single_out_t *output_args,
606*0Sstevel@tonic-gate     t1394_isoch_single_handle_t *t1394_single_hdl, int *result);
607*0Sstevel@tonic-gate 
608*0Sstevel@tonic-gate void t1394_free_isoch_single(t1394_handle_t t1394_hdl,
609*0Sstevel@tonic-gate     t1394_isoch_single_handle_t *t1394_single_hdl, uint_t flags);
610*0Sstevel@tonic-gate 
611*0Sstevel@tonic-gate int t1394_alloc_isoch_cec(t1394_handle_t t1394_hdl,
612*0Sstevel@tonic-gate     t1394_isoch_cec_props_t *props, uint_t flags,
613*0Sstevel@tonic-gate     t1394_isoch_cec_handle_t *t1394_isoch_cec_hdl);
614*0Sstevel@tonic-gate 
615*0Sstevel@tonic-gate int t1394_free_isoch_cec(t1394_handle_t t1394_hdl, uint_t flags,
616*0Sstevel@tonic-gate     t1394_isoch_cec_handle_t *t1394_isoch_cec_hdl);
617*0Sstevel@tonic-gate 
618*0Sstevel@tonic-gate int t1394_join_isoch_cec(t1394_handle_t t1394_hdl,
619*0Sstevel@tonic-gate     t1394_isoch_cec_handle_t t1394_isoch_cec_hdl, uint_t flags,
620*0Sstevel@tonic-gate     t1394_join_isochinfo_t *join_isoch_info);
621*0Sstevel@tonic-gate 
622*0Sstevel@tonic-gate int t1394_leave_isoch_cec(t1394_handle_t t1394_hdl,
623*0Sstevel@tonic-gate     t1394_isoch_cec_handle_t t1394_isoch_cec_hdl, uint_t flags);
624*0Sstevel@tonic-gate 
625*0Sstevel@tonic-gate int t1394_setup_isoch_cec(t1394_handle_t t1394_hdl,
626*0Sstevel@tonic-gate     t1394_isoch_cec_handle_t t1394_isoch_cec_hdl, uint_t flags, int *result);
627*0Sstevel@tonic-gate 
628*0Sstevel@tonic-gate /* Results codes returned by t1394_setup_isoch_cec() */
629*0Sstevel@tonic-gate #define	T1394_ENO_BANDWIDTH	(-500)
630*0Sstevel@tonic-gate #define	T1394_ENO_CHANNEL	(-501)
631*0Sstevel@tonic-gate #define	T1394_ETARGET		(-502)
632*0Sstevel@tonic-gate #define	T1394_CEC_ERR_FIRST	T1394_ENO_BANDWIDTH
633*0Sstevel@tonic-gate #define	T1394_CEC_ERR_LAST	T1394_ETARGET
634*0Sstevel@tonic-gate /*
635*0Sstevel@tonic-gate  * NOTE: Make sure T1394_ERR_LAST is updated if a new error code is
636*0Sstevel@tonic-gate  * added. t1394_errmsg.c uses *FIRST and *LAST as bounds checks.
637*0Sstevel@tonic-gate  */
638*0Sstevel@tonic-gate 
639*0Sstevel@tonic-gate int t1394_start_isoch_cec(t1394_handle_t t1394_hdl,
640*0Sstevel@tonic-gate     t1394_isoch_cec_handle_t t1394_isoch_cec_hdl, uint_t flags);
641*0Sstevel@tonic-gate 
642*0Sstevel@tonic-gate int t1394_stop_isoch_cec(t1394_handle_t t1394_hdl,
643*0Sstevel@tonic-gate     t1394_isoch_cec_handle_t t1394_isoch_cec_hdl, uint_t flags);
644*0Sstevel@tonic-gate 
645*0Sstevel@tonic-gate int t1394_teardown_isoch_cec(t1394_handle_t t1394_hdl,
646*0Sstevel@tonic-gate     t1394_isoch_cec_handle_t t1394_isoch_cec_hdl, uint_t flags);
647*0Sstevel@tonic-gate 
648*0Sstevel@tonic-gate 
649*0Sstevel@tonic-gate /*
650*0Sstevel@tonic-gate  * ISOCHRONOUS DMA (LOCAL ISOCH DMA) SERVICES:
651*0Sstevel@tonic-gate  *    These are the calls into the 1394 Framework used for local
652*0Sstevel@tonic-gate  *    isochronous DMA services. The t1394_alloc_isoch_dma() routine
653*0Sstevel@tonic-gate  *    takes a target handle and an id1394_isoch_dmainfo_t structure
654*0Sstevel@tonic-gate  *    (see id1394.h for details) as its input arguments and returns a
655*0Sstevel@tonic-gate  *    t1394_isoch_dma_handle_t that the target driver will use with all
656*0Sstevel@tonic-gate  *    other local host DMA calls.  After allocating a local host DMA
657*0Sstevel@tonic-gate  *    resource, a target driver may start and stop it as often as desired
658*0Sstevel@tonic-gate  *    using the t1394_start_isoch_dma() and t1394_stop_isoch_dma() calls.
659*0Sstevel@tonic-gate  *    The t1394_start_isoch_dma() takes an id1394_isoch_dma_ctrlinfo_t
660*0Sstevel@tonic-gate  *    structure (also discussed in more detail in id1394.h) as an
661*0Sstevel@tonic-gate  *    additional argument to indicate among other things the conditions
662*0Sstevel@tonic-gate  *    under which the host DMA will be started.
663*0Sstevel@tonic-gate  *    The t1394_free_isoch_dma() is used, not surprisingly, to free up
664*0Sstevel@tonic-gate  *    allocate isoch DMA resources.
665*0Sstevel@tonic-gate  *    And the t1394_update_isoch_dma() routine is used to update a running
666*0Sstevel@tonic-gate  *    isochronous stream.  By creating and passing a temporary IXL command
667*0Sstevel@tonic-gate  *    or set of commands and both the kernel virtual addresses of the
668*0Sstevel@tonic-gate  *    temporary and original commands, a target driver can request that the
669*0Sstevel@tonic-gate  *    1394 Framework replace the original field contents with those in the
670*0Sstevel@tonic-gate  *    temporary command and update the corresponding hardware DMA elements.
671*0Sstevel@tonic-gate  */
672*0Sstevel@tonic-gate int t1394_alloc_isoch_dma(t1394_handle_t t1394_hdl,
673*0Sstevel@tonic-gate     id1394_isoch_dmainfo_t *idi, uint_t flags,
674*0Sstevel@tonic-gate     t1394_isoch_dma_handle_t *t1394_idma_hdl, int *result);
675*0Sstevel@tonic-gate 
676*0Sstevel@tonic-gate /*
677*0Sstevel@tonic-gate  * Results codes returned by t1394_alloc_isoch_dma(). See ixl1394.h for possible
678*0Sstevel@tonic-gate  * IXL1394 compilation errors.
679*0Sstevel@tonic-gate  * NOTE: Make sure T1394_IDMA_ERR_LAST is updated if a new error code is
680*0Sstevel@tonic-gate  * added.
681*0Sstevel@tonic-gate  */
682*0Sstevel@tonic-gate #define	T1394_EIDMA_NO_RESRCS	(-600)
683*0Sstevel@tonic-gate #define	T1394_EIDMA_CONFLICT	(-601)
684*0Sstevel@tonic-gate #define	T1394_IDMA_ERR_FIRST	T1394_EIDMA_NO_RESRCS
685*0Sstevel@tonic-gate #define	T1394_IDMA_ERR_LAST	T1394_EIDMA_CONFLICT
686*0Sstevel@tonic-gate 
687*0Sstevel@tonic-gate void t1394_free_isoch_dma(t1394_handle_t t1394_hdl, uint_t flags,
688*0Sstevel@tonic-gate     t1394_isoch_dma_handle_t *t1394_idma_hdl);
689*0Sstevel@tonic-gate 
690*0Sstevel@tonic-gate int t1394_start_isoch_dma(t1394_handle_t t1394_hdl,
691*0Sstevel@tonic-gate     t1394_isoch_dma_handle_t t1394_idma_hdl,
692*0Sstevel@tonic-gate     id1394_isoch_dma_ctrlinfo_t *idma_ctrlinfo, uint_t flags, int *result);
693*0Sstevel@tonic-gate 
694*0Sstevel@tonic-gate void t1394_stop_isoch_dma(t1394_handle_t t1394_hdl,
695*0Sstevel@tonic-gate     t1394_isoch_dma_handle_t t1394_idma_hdl, uint_t flags);
696*0Sstevel@tonic-gate 
697*0Sstevel@tonic-gate /* See ixl1394.h for possible IXL1394 t1394_update_isoch_dma() errors. */
698*0Sstevel@tonic-gate int t1394_update_isoch_dma(t1394_handle_t t1394_hdl,
699*0Sstevel@tonic-gate     t1394_isoch_dma_handle_t t1394_idma_hdl,
700*0Sstevel@tonic-gate     id1394_isoch_dma_updateinfo_t *idma_updateinfo, uint_t flags, int *result);
701*0Sstevel@tonic-gate 
702*0Sstevel@tonic-gate 
703*0Sstevel@tonic-gate /*
704*0Sstevel@tonic-gate  * MISCELLANEOUS SERVICES:
705*0Sstevel@tonic-gate  *    These are the calls into the 1394 Framework used for miscellaneous
706*0Sstevel@tonic-gate  *    services, including getting target information and topology map,
707*0Sstevel@tonic-gate  *    adding to and removing from local Config ROM, initiating bus resets,
708*0Sstevel@tonic-gate  *    etc.  The t1394_get_targetinfo() routine is used to get information
709*0Sstevel@tonic-gate  *    about the target driver's device and about current bus conditions
710*0Sstevel@tonic-gate  *    that might be useful to a target.  By passing the target handle and
711*0Sstevel@tonic-gate  *    current bus generation, a target driver can expect to receive a filled
712*0Sstevel@tonic-gate  *    in t1394_targetinfo_t structure (see above) that contains the
713*0Sstevel@tonic-gate  *    current_max_payload, current_max_speed, and device's nodeID.
714*0Sstevel@tonic-gate  *    The t1394_initiate_bus_reset() routine can be used by target drivers
715*0Sstevel@tonic-gate  *    to initiate a bus reset.  This call should be used only when it is
716*0Sstevel@tonic-gate  *    absolutely imperative, however, as bus resets affect all devices on
717*0Sstevel@tonic-gate  *    the 1394 Serial Bus and excessive use of bus resets can have an
718*0Sstevel@tonic-gate  *    adverse effect on overall bus performance.
719*0Sstevel@tonic-gate  *    The t1394_get_topology_map() will return the TOPOLOGY_MAP (see
720*0Sstevel@tonic-gate  *    IEEE 1394-1995, Section 8.3.2.4.1) which is a list of SelfID packets
721*0Sstevel@tonic-gate  *    from the current bus generation.
722*0Sstevel@tonic-gate  *    The t1394_CRC16() call is used to calculate cyclic redundancy checks
723*0Sstevel@tonic-gate  *    (CRCs) necessary for use in Config ROM buffers.
724*0Sstevel@tonic-gate  *    The t1394_add_cfgrom_entry() and t1394_rem_cfgrom_entry() calls are
725*0Sstevel@tonic-gate  *    used, respectively, to add and remove entries from the local host
726*0Sstevel@tonic-gate  *    Config ROM buffer.  (See above for a description of the
727*0Sstevel@tonic-gate  *    t1394_cfgrom_entryinfo_t structure.)
728*0Sstevel@tonic-gate  *    And the t1394_errmsg() routine is used to convert result codes which
729*0Sstevel@tonic-gate  *    have been returned by the 1394 Framework into character strings for
730*0Sstevel@tonic-gate  *    use in error messages.
731*0Sstevel@tonic-gate  */
732*0Sstevel@tonic-gate int t1394_get_targetinfo(t1394_handle_t t1394_hdl, uint_t bus_generation,
733*0Sstevel@tonic-gate     uint_t flags, t1394_targetinfo_t *targetinfo);
734*0Sstevel@tonic-gate 
735*0Sstevel@tonic-gate void t1394_initiate_bus_reset(t1394_handle_t t1394_hdl, uint_t flags);
736*0Sstevel@tonic-gate 
737*0Sstevel@tonic-gate int t1394_get_topology_map(t1394_handle_t t1394_hdl, uint_t bus_generation,
738*0Sstevel@tonic-gate     size_t tm_length, uint_t flags, uint32_t *tm_buffer);
739*0Sstevel@tonic-gate 
740*0Sstevel@tonic-gate uint_t t1394_CRC16(uint32_t *d, size_t crc_length, uint_t flags);
741*0Sstevel@tonic-gate 
742*0Sstevel@tonic-gate int t1394_add_cfgrom_entry(t1394_handle_t t1394_hdl,
743*0Sstevel@tonic-gate     t1394_cfgrom_entryinfo_t *cfgrom_entryinfo, uint_t flags,
744*0Sstevel@tonic-gate     t1394_cfgrom_handle_t *t1394_cfgrom_hdl, int *result);
745*0Sstevel@tonic-gate /* Results codes returned by t1394_add_cfgrom_entry() */
746*0Sstevel@tonic-gate #define	T1394_ECFGROM_FULL		(-700)
747*0Sstevel@tonic-gate #define	T1394_EINVALID_PARAM		(-701)
748*0Sstevel@tonic-gate #define	T1394_EINVALID_CONTEXT		(-702)
749*0Sstevel@tonic-gate #define	T1394_NOERROR			(-703)
750*0Sstevel@tonic-gate #define	T1394_ECFG_FIRST		T1394_ECFGROM_FULL
751*0Sstevel@tonic-gate #define	T1394_ECFG_LAST			T1394_NOERROR
752*0Sstevel@tonic-gate /*
753*0Sstevel@tonic-gate  * NOTE: Make sure T1394_ECFG_LAST is updated if a new error code is
754*0Sstevel@tonic-gate  * added. t1394_errmsg.c uses *FIRST and *LAST as bounds checks.
755*0Sstevel@tonic-gate  */
756*0Sstevel@tonic-gate 
757*0Sstevel@tonic-gate int t1394_rem_cfgrom_entry(t1394_handle_t t1394_hdl, uint_t flags,
758*0Sstevel@tonic-gate     t1394_cfgrom_handle_t *t1394_cfgrom_hdl, int *result);
759*0Sstevel@tonic-gate 
760*0Sstevel@tonic-gate const char *t1394_errmsg(int result, uint_t flags);
761*0Sstevel@tonic-gate 
762*0Sstevel@tonic-gate #ifdef __cplusplus
763*0Sstevel@tonic-gate }
764*0Sstevel@tonic-gate #endif
765*0Sstevel@tonic-gate 
766*0Sstevel@tonic-gate #endif	/* _SYS_1394_T1394_H */
767