17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*47cd5876SAlan Perry  * Common Development and Distribution License (the "License").
6*47cd5876SAlan Perry  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*47cd5876SAlan Perry  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _SYS_1394_TARGETS_AV1394_IMPL_H
277c478bd9Sstevel@tonic-gate #define	_SYS_1394_TARGETS_AV1394_IMPL_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * av1394 driver definitions
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/note.h>
347c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
357c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
367c478bd9Sstevel@tonic-gate #include <sys/strsun.h>
377c478bd9Sstevel@tonic-gate #include <sys/mkdev.h>
387c478bd9Sstevel@tonic-gate #include <sys/av/iec61883.h>
397c478bd9Sstevel@tonic-gate #include <sys/1394/t1394.h>
407c478bd9Sstevel@tonic-gate #include <sys/1394/targets/av1394/av1394_isoch.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef __cplusplus
437c478bd9Sstevel@tonic-gate extern "C" {
447c478bd9Sstevel@tonic-gate #endif
457c478bd9Sstevel@tonic-gate 
46*47cd5876SAlan Perry /*
47*47cd5876SAlan Perry  * byte swapping support, stolen from SBP2
48*47cd5876SAlan Perry  */
49*47cd5876SAlan Perry #ifdef _LITTLE_ENDIAN
50*47cd5876SAlan Perry #define	AV_SWAP16(data) \
51*47cd5876SAlan Perry 	((((data) & 0xff) << 8) | ((data) >> 8))
52*47cd5876SAlan Perry 
53*47cd5876SAlan Perry #define	AV_SWAP32(data) \
54*47cd5876SAlan Perry 	(((uint32_t)AV_SWAP16((uint16_t)((data) & 0xffff)) << 16) |   \
55*47cd5876SAlan Perry 	(uint32_t)AV_SWAP16((uint16_t)((data) >> 16)))
56*47cd5876SAlan Perry #else
57*47cd5876SAlan Perry #define	AV_SWAP16(data)	(data)
58*47cd5876SAlan Perry #define	AV_SWAP32(data)	(data)
59*47cd5876SAlan Perry #endif
60*47cd5876SAlan Perry 
61*47cd5876SAlan Perry 
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate  * double-linked list
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate typedef struct av1394_list_item_s {
667c478bd9Sstevel@tonic-gate 	struct av1394_list_item_s	*i_next;
677c478bd9Sstevel@tonic-gate 	struct av1394_list_item_s	*i_prev;
687c478bd9Sstevel@tonic-gate } av1394_list_item_t;
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate typedef struct av1394_list_s {
717c478bd9Sstevel@tonic-gate 	av1394_list_item_t	*l_head;	/* first item */
727c478bd9Sstevel@tonic-gate 	av1394_list_item_t	*l_tail;	/* last item */
737c478bd9Sstevel@tonic-gate 	int			l_cnt;		/* number of items */
747c478bd9Sstevel@tonic-gate } av1394_list_t;
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate /*
787c478bd9Sstevel@tonic-gate  * queue
797c478bd9Sstevel@tonic-gate  */
807c478bd9Sstevel@tonic-gate typedef struct av1394_queue_s {
817c478bd9Sstevel@tonic-gate 	kmutex_t	q_mutex;	/* mutex */
827c478bd9Sstevel@tonic-gate 	av1394_list_t	q_list;		/* list of mblk's */
837c478bd9Sstevel@tonic-gate 	int		q_size;		/* current data size */
847c478bd9Sstevel@tonic-gate 	int		q_max;		/* max data size */
857c478bd9Sstevel@tonic-gate 	kcondvar_t	q_cv;		/* data cv */
867c478bd9Sstevel@tonic-gate } av1394_queue_t;
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(av1394_queue_s::q_mutex, av1394_queue_s))
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate #define	AV1394_ENTERQ(q)	mutex_enter(&(q)->q_mutex)
917c478bd9Sstevel@tonic-gate #define	AV1394_LEAVEQ(q)	mutex_exit(&(q)->q_mutex)
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * asynchronous module definitions
967c478bd9Sstevel@tonic-gate  *
977c478bd9Sstevel@tonic-gate  *
987c478bd9Sstevel@tonic-gate  * command structure
997c478bd9Sstevel@tonic-gate  */
1007c478bd9Sstevel@tonic-gate typedef struct av1394_fcp_cmd_s {
1017c478bd9Sstevel@tonic-gate 	cmd1394_cmd_t	*fc_cmd;	/* 1394 command */
1027c478bd9Sstevel@tonic-gate 	boolean_t	fc_busy;	/* command is in use */
1037c478bd9Sstevel@tonic-gate 	kcondvar_t	fc_busy_cv;	/* busy cv */
1047c478bd9Sstevel@tonic-gate 	boolean_t	fc_xmit;	/* transmit in progress */
1057c478bd9Sstevel@tonic-gate 	kcondvar_t	fc_xmit_cv;	/* transmit completion cv */
1067c478bd9Sstevel@tonic-gate } av1394_fcp_cmd_t;
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate /*
1097c478bd9Sstevel@tonic-gate  * per-instance FCP structure
1107c478bd9Sstevel@tonic-gate  */
1117c478bd9Sstevel@tonic-gate typedef struct av1394_fcp_s {
1127c478bd9Sstevel@tonic-gate 	av1394_fcp_cmd_t	fcp_cmd;	/* outgoing FCP command */
1137c478bd9Sstevel@tonic-gate 	av1394_fcp_cmd_t	fcp_resp;	/* outgoing FCP response */
1147c478bd9Sstevel@tonic-gate } av1394_fcp_t;
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate enum {
1177c478bd9Sstevel@tonic-gate 	AV1394_FCP_ARQ_LEN_MAX	 = 0x200	/* maximum FCP ARQ length */
1187c478bd9Sstevel@tonic-gate };
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate /*
1227c478bd9Sstevel@tonic-gate  * configuration ROM
1237c478bd9Sstevel@tonic-gate  */
1247c478bd9Sstevel@tonic-gate #define	AV1394_CFGROM_INFO_LEN_ADDR	(IEEE1394_CONFIG_ROM_ADDR + 0x00)
1257c478bd9Sstevel@tonic-gate #define	AV1394_CFGROM_BUS_NAME_ADDR	(IEEE1394_CONFIG_ROM_ADDR + 0x04)
1267c478bd9Sstevel@tonic-gate #define	AV1394_CFGROM_EUI64_HI_ADDR	(IEEE1394_CONFIG_ROM_ADDR + 0x0c)
1277c478bd9Sstevel@tonic-gate #define	AV1394_CFGROM_EUI64_LO_ADDR	(IEEE1394_CONFIG_ROM_ADDR + 0x10)
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate /* offsets in quadlets */
1307c478bd9Sstevel@tonic-gate #define	AV1394_CFGROM_BUS_NAME_OFF	1
1317c478bd9Sstevel@tonic-gate #define	AV1394_CFGROM_EUI64_HI_OFF	3
1327c478bd9Sstevel@tonic-gate #define	AV1394_CFGROM_EUI64_LO_OFF	4
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate typedef struct av1394_cfgrom_text_leaf_s {
1357c478bd9Sstevel@tonic-gate 	uint64_t	tl_addr;	/* leaf entry address */
1367c478bd9Sstevel@tonic-gate 	uint32_t	tl_desc_entry;	/* entry described by this leaf */
1377c478bd9Sstevel@tonic-gate } av1394_cfgrom_text_leaf_t;
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate typedef struct av1394_cfgrom_parsed_dir_s {
1407c478bd9Sstevel@tonic-gate 	av1394_cfgrom_text_leaf_t *pd_tl;	/* text leaf array */
1417c478bd9Sstevel@tonic-gate 	int			pd_tl_size;	/* total # of array entries */
1427c478bd9Sstevel@tonic-gate 	int			pd_tl_next;	/* first unused entry index */
1437c478bd9Sstevel@tonic-gate } av1394_cfgrom_parsed_dir_t;
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate typedef struct av1394_cfgrom_parse_arg_s {
1467c478bd9Sstevel@tonic-gate 	int			pa_depth;	/* parser depth */
1477c478bd9Sstevel@tonic-gate 	uint32_t		pa_desc_entry;	/* described entry */
1487c478bd9Sstevel@tonic-gate 	uint8_t			pa_parent_k;	/* parent entry's key value */
1497c478bd9Sstevel@tonic-gate 	uint64_t		pa_addr;	/* directory address */
1507c478bd9Sstevel@tonic-gate 	uint16_t		pa_len;		/* directory length */
1517c478bd9Sstevel@tonic-gate 	av1394_cfgrom_parsed_dir_t *pa_dir;	/* current directory */
1527c478bd9Sstevel@tonic-gate } av1394_cfgrom_parse_arg_t;
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate enum {
1557c478bd9Sstevel@tonic-gate 	AV1394_CFGROM_PARSE_MAX_DEPTH	= 5	/* maximum parse depth */
1567c478bd9Sstevel@tonic-gate };
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate typedef struct av1394_cfgrom_s {
1597c478bd9Sstevel@tonic-gate 	krwlock_t		cr_rwlock;	/* structure lock */
1607c478bd9Sstevel@tonic-gate 	boolean_t		cr_parsed;	/* node ConfigROM was parsed */
1617c478bd9Sstevel@tonic-gate 	av1394_cfgrom_parsed_dir_t cr_root_dir;	/* root directory */
1627c478bd9Sstevel@tonic-gate 	av1394_cfgrom_parsed_dir_t cr_unit_dir;	/* unit directory */
1637c478bd9Sstevel@tonic-gate } av1394_cfgrom_t;
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate /*
1677c478bd9Sstevel@tonic-gate  * async command
1687c478bd9Sstevel@tonic-gate  */
1697c478bd9Sstevel@tonic-gate typedef struct av1394_async_cmd_s {
1707c478bd9Sstevel@tonic-gate 	kmutex_t	ac_mutex;
1717c478bd9Sstevel@tonic-gate 	boolean_t	ac_busy;
1727c478bd9Sstevel@tonic-gate 	kcondvar_t	ac_cv;
1737c478bd9Sstevel@tonic-gate 	cmd1394_cmd_t	*ac_cmd;
1747c478bd9Sstevel@tonic-gate } av1394_async_cmd_t;
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate /*
1777c478bd9Sstevel@tonic-gate  * per-instance soft state structure
1787c478bd9Sstevel@tonic-gate  */
1797c478bd9Sstevel@tonic-gate typedef struct av1394_async_s {
1807c478bd9Sstevel@tonic-gate 	kmutex_t		a_mutex;	/* structure mutex */
1817c478bd9Sstevel@tonic-gate 	int			a_nopen;	/* number of opens */
1827c478bd9Sstevel@tonic-gate 	int			a_oflag;	/* open flags */
1837c478bd9Sstevel@tonic-gate 	t1394_targetinfo_t	a_targetinfo;	/* target info */
1847c478bd9Sstevel@tonic-gate 	uint_t			a_bus_generation; /* bus generation */
1857c478bd9Sstevel@tonic-gate 	av1394_fcp_t		a_fcp;		/* FCP module */
1867c478bd9Sstevel@tonic-gate 	av1394_cfgrom_t		a_cfgrom;	/* config ROM module */
1877c478bd9Sstevel@tonic-gate 	av1394_queue_t		a_rq;		/* read queue */
1887c478bd9Sstevel@tonic-gate 	struct pollhead		a_pollhead;	/* poll(2) support */
1897c478bd9Sstevel@tonic-gate 	short			a_pollevents;	/* polled events */
1907c478bd9Sstevel@tonic-gate } av1394_async_t;
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(av1394_async_s::a_mutex, av1394_async_s))
1937c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(av1394_async_s::{
1947c478bd9Sstevel@tonic-gate 	a_oflag
1957c478bd9Sstevel@tonic-gate }))
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate /* we use special message types for the read queue */
1997c478bd9Sstevel@tonic-gate enum {
2007c478bd9Sstevel@tonic-gate 	AV1394_M_FCP_RESP	= 0x01,	/* FCP response */
2017c478bd9Sstevel@tonic-gate 	AV1394_M_FCP_CMD	= 0x02,	/* FCP command */
2027c478bd9Sstevel@tonic-gate 	AV1394_M_BUS_RESET	= 0x03,	/* bus reset event */
2037c478bd9Sstevel@tonic-gate 	/*
2047c478bd9Sstevel@tonic-gate 	 * For efficiency, we only store 1394 request data on the read queue.
2057c478bd9Sstevel@tonic-gate 	 * ARQ headers (iec61883_arq_t) are generated when an application
2067c478bd9Sstevel@tonic-gate 	 * calls read(2). Because applications may read header separately
2077c478bd9Sstevel@tonic-gate 	 * from the data, we need to mark each mblk when its header was read
2087c478bd9Sstevel@tonic-gate 	 * but not the data - the following flag is used for this purpose.
2097c478bd9Sstevel@tonic-gate 	 */
2107c478bd9Sstevel@tonic-gate 	AV1394_M_NOHDR		= 0x80
2117c478bd9Sstevel@tonic-gate };
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate #define	AV1394_DBTYPE(bp)	(DB_TYPE(bp) & ~AV1394_M_NOHDR)
2147c478bd9Sstevel@tonic-gate #define	AV1394_MARK_NOHDR(bp)	(DB_TYPE(bp) |= AV1394_M_NOHDR)
2157c478bd9Sstevel@tonic-gate #define	AV1394_IS_NOHDR(bp)	(DB_TYPE(bp) & AV1394_M_NOHDR)
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate 
2187c478bd9Sstevel@tonic-gate /*
2197c478bd9Sstevel@tonic-gate  * device state:
2207c478bd9Sstevel@tonic-gate  *
2217c478bd9Sstevel@tonic-gate  *                     AV1394_DEV_DISCONNECTED
2227c478bd9Sstevel@tonic-gate  *                     |                |   ^
2237c478bd9Sstevel@tonic-gate  *                     |                |   |
2247c478bd9Sstevel@tonic-gate  *                  detach       reconnect disconnect
2257c478bd9Sstevel@tonic-gate  *                     |                |   |
2267c478bd9Sstevel@tonic-gate  *                     v                v   |
2277c478bd9Sstevel@tonic-gate  *       AV1394_DEV_INIT ----attach---> AV1394_DEV_ONLINE
2287c478bd9Sstevel@tonic-gate  *      (initial state)  <---detach---  |   ^
2297c478bd9Sstevel@tonic-gate  *                                      |   |
2307c478bd9Sstevel@tonic-gate  *                             cpr suspend cpr resume
2317c478bd9Sstevel@tonic-gate  *                                      |   |
2327c478bd9Sstevel@tonic-gate  *                                      v   |
2337c478bd9Sstevel@tonic-gate  *                        AV1394_DEV_SUSPENDED
2347c478bd9Sstevel@tonic-gate  */
2357c478bd9Sstevel@tonic-gate typedef enum {
2367c478bd9Sstevel@tonic-gate 	AV1394_DEV_INIT		= 0,
2377c478bd9Sstevel@tonic-gate 	AV1394_DEV_ONLINE,
2387c478bd9Sstevel@tonic-gate 	AV1394_DEV_SUSPENDED,
2397c478bd9Sstevel@tonic-gate 	AV1394_DEV_DISCONNECTED
2407c478bd9Sstevel@tonic-gate } av1394_dev_state_t;
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate /*
2437c478bd9Sstevel@tonic-gate  * per-instance soft state structure
2447c478bd9Sstevel@tonic-gate  */
2457c478bd9Sstevel@tonic-gate typedef struct av1394_inst_s {
2467c478bd9Sstevel@tonic-gate 	kmutex_t		av_mutex;	/* structure mutex */
2477c478bd9Sstevel@tonic-gate 	dev_info_t		*av_dip;	/* device information */
2487c478bd9Sstevel@tonic-gate 	int			av_instance;	/* instance number */
2497c478bd9Sstevel@tonic-gate 	av1394_dev_state_t	av_dev_state;	/* device state */
2507c478bd9Sstevel@tonic-gate 	av1394_dev_state_t	av_prev_dev_state; /* previous device state */
2517c478bd9Sstevel@tonic-gate 	t1394_attachinfo_t	av_attachinfo;	/* 1394 attach info */
2527c478bd9Sstevel@tonic-gate 	t1394_handle_t		av_t1394_hdl;	/* 1394 handle */
2537c478bd9Sstevel@tonic-gate 	av1394_async_t		av_a;		/* asynchronous module */
2547c478bd9Sstevel@tonic-gate 	av1394_isoch_t		av_i;		/* isochronous module */
2557c478bd9Sstevel@tonic-gate 	ddi_callback_id_t	av_reset_cb;	/* reset event cb id */
2567c478bd9Sstevel@tonic-gate 	ddi_callback_id_t	av_remove_cb; 	/* remove event cb id */
2577c478bd9Sstevel@tonic-gate 	ddi_callback_id_t	av_insert_cb;	/* insert event cb id */
2587c478bd9Sstevel@tonic-gate } av1394_inst_t;
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(av1394_inst_s::av_mutex, av1394_inst_s::{
2617c478bd9Sstevel@tonic-gate 	av_dip
2627c478bd9Sstevel@tonic-gate 	av_instance
2637c478bd9Sstevel@tonic-gate 	av_attachinfo
2647c478bd9Sstevel@tonic-gate 	av_t1394_hdl
2657c478bd9Sstevel@tonic-gate }))
2667c478bd9Sstevel@tonic-gate /* these are set during attach (single-threaded) and don't change afterwards */
2677c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(av1394_inst_s::{
2687c478bd9Sstevel@tonic-gate 	av_dip
2697c478bd9Sstevel@tonic-gate 	av_instance
2707c478bd9Sstevel@tonic-gate 	av_attachinfo
2717c478bd9Sstevel@tonic-gate 	av_t1394_hdl
2727c478bd9Sstevel@tonic-gate }))
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("one per call", msgb datab cmd1394_cmd
2757c478bd9Sstevel@tonic-gate 	iec61883_arq_t iec61883_isoch_init_t iec61883_plug_init_t))
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate /*
2787c478bd9Sstevel@tonic-gate  * minor <-> instance mapping
2797c478bd9Sstevel@tonic-gate  */
2807c478bd9Sstevel@tonic-gate #define	AV1394_MINOR_TYPE_MASK		(1 << (NBITSMINOR32 - 1))
2817c478bd9Sstevel@tonic-gate #define	AV1394_ISOCH_INST2MINOR(inst)	(inst)
2827c478bd9Sstevel@tonic-gate #define	AV1394_ASYNC_INST2MINOR(inst)	((inst) | AV1394_MINOR_TYPE_MASK)
2837c478bd9Sstevel@tonic-gate #define	AV1394_DEV_IS_ISOCH(dev)	\
2847c478bd9Sstevel@tonic-gate 		((getminor(dev) & AV1394_MINOR_TYPE_MASK) == 0)
2857c478bd9Sstevel@tonic-gate #define	AV1394_DEV_IS_ASYNC(dev)	\
2867c478bd9Sstevel@tonic-gate 		((getminor(dev) & AV1394_MINOR_TYPE_MASK) != 0)
2877c478bd9Sstevel@tonic-gate #define	AV1394_DEV2INST(dev)		\
2887c478bd9Sstevel@tonic-gate 		((getminor(dev)) & ~AV1394_MINOR_TYPE_MASK)
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate /* misc constants */
2917c478bd9Sstevel@tonic-gate enum {
2927c478bd9Sstevel@tonic-gate 	AV1394_CLEANUP_LEVEL_MAX	= 256
2937c478bd9Sstevel@tonic-gate };
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate /* current interface version */
2967c478bd9Sstevel@tonic-gate #define	AV1394_IEC61883_VER		IEC61883_V1_0
2977c478bd9Sstevel@tonic-gate 
2987c478bd9Sstevel@tonic-gate /* misc */
2997c478bd9Sstevel@tonic-gate #define	NELEM(a)	(sizeof (a) / sizeof (*(a)))
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate 
3027c478bd9Sstevel@tonic-gate /* double-linked list */
3037c478bd9Sstevel@tonic-gate void	av1394_list_init(av1394_list_t *lp);
3047c478bd9Sstevel@tonic-gate void	*av1394_list_head(av1394_list_t *lp);
3057c478bd9Sstevel@tonic-gate void	av1394_list_put_tail(av1394_list_t *lp, void *item);
3067c478bd9Sstevel@tonic-gate void	av1394_list_put_head(av1394_list_t *lp, void *item);
3077c478bd9Sstevel@tonic-gate void	*av1394_list_get_head(av1394_list_t *lp);
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate /* queue */
3107c478bd9Sstevel@tonic-gate void	av1394_initq(av1394_queue_t *q, ddi_iblock_cookie_t ibc, int max);
3117c478bd9Sstevel@tonic-gate void	av1394_destroyq(av1394_queue_t *q);
3127c478bd9Sstevel@tonic-gate void	av1394_setmaxq(av1394_queue_t *q, int max);
3137c478bd9Sstevel@tonic-gate int	av1394_getmaxq(av1394_queue_t *q);
3147c478bd9Sstevel@tonic-gate void	av1394_flushq(av1394_queue_t *q);
3157c478bd9Sstevel@tonic-gate int	av1394_putq(av1394_queue_t *q, mblk_t *bp);
3167c478bd9Sstevel@tonic-gate int	av1394_putbq(av1394_queue_t *q, mblk_t *bp);
3177c478bd9Sstevel@tonic-gate mblk_t	*av1394_getq(av1394_queue_t *q);
3187c478bd9Sstevel@tonic-gate mblk_t	*av1394_peekq(av1394_queue_t *q);
3197c478bd9Sstevel@tonic-gate mblk_t	*av1394_peekq_locked(av1394_queue_t *q);
3207c478bd9Sstevel@tonic-gate int	av1394_qwait_sig(av1394_queue_t *q);
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate /* FCP */
3237c478bd9Sstevel@tonic-gate int	av1394_fcp_attach(av1394_inst_t *);
3247c478bd9Sstevel@tonic-gate void	av1394_fcp_detach(av1394_inst_t *);
3257c478bd9Sstevel@tonic-gate int	av1394_fcp_open(av1394_inst_t *, int);
3267c478bd9Sstevel@tonic-gate int	av1394_fcp_close(av1394_inst_t *, int);
3277c478bd9Sstevel@tonic-gate int	av1394_fcp_write(av1394_inst_t *, iec61883_arq_t *, struct uio *);
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate /* config ROM */
3307c478bd9Sstevel@tonic-gate int	av1394_cfgrom_init(av1394_inst_t *);
3317c478bd9Sstevel@tonic-gate void	av1394_cfgrom_fini(av1394_inst_t *);
3327c478bd9Sstevel@tonic-gate void	av1394_cfgrom_close(av1394_inst_t *);
3337c478bd9Sstevel@tonic-gate int	av1394_ioctl_node_get_bus_name(av1394_inst_t *, void *, int);
3347c478bd9Sstevel@tonic-gate int	av1394_ioctl_node_get_uid(av1394_inst_t *, void *, int);
3357c478bd9Sstevel@tonic-gate int	av1394_ioctl_node_get_text_leaf(av1394_inst_t *, void *, int);
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate /* async module */
3387c478bd9Sstevel@tonic-gate int	av1394_async_attach(av1394_inst_t *);
3397c478bd9Sstevel@tonic-gate void	av1394_async_detach(av1394_inst_t *);
3407c478bd9Sstevel@tonic-gate int	av1394_async_cpr_suspend(av1394_inst_t *);
3417c478bd9Sstevel@tonic-gate int	av1394_async_cpr_resume(av1394_inst_t *);
3427c478bd9Sstevel@tonic-gate void	av1394_async_bus_reset(av1394_inst_t *);
3437c478bd9Sstevel@tonic-gate void	av1394_async_disconnect(av1394_inst_t *);
3447c478bd9Sstevel@tonic-gate void	av1394_async_reconnect(av1394_inst_t *);
3457c478bd9Sstevel@tonic-gate int	av1394_async_open(av1394_inst_t *, int);
3467c478bd9Sstevel@tonic-gate int	av1394_async_close(av1394_inst_t *, int);
3477c478bd9Sstevel@tonic-gate int	av1394_async_read(av1394_inst_t *, struct uio *);
3487c478bd9Sstevel@tonic-gate int	av1394_async_write(av1394_inst_t *, struct uio *);
3497c478bd9Sstevel@tonic-gate int	av1394_async_ioctl(av1394_inst_t *, int, intptr_t, int, int *);
3507c478bd9Sstevel@tonic-gate int	av1394_async_poll(av1394_inst_t *, short, int, short *,
3517c478bd9Sstevel@tonic-gate 		struct pollhead **);
3527c478bd9Sstevel@tonic-gate void	av1394_async_putq_rq(av1394_inst_t *, mblk_t *);
3537c478bd9Sstevel@tonic-gate 
3547c478bd9Sstevel@tonic-gate #ifdef __cplusplus
3557c478bd9Sstevel@tonic-gate }
3567c478bd9Sstevel@tonic-gate #endif
3577c478bd9Sstevel@tonic-gate 
3587c478bd9Sstevel@tonic-gate #endif /* _SYS_1394_TARGETS_AV1394_IMPL_H */
359