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