1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_USB_USBSER_KEYSPAN_PIPE_H
27 #define	_SYS_USB_USBSER_KEYSPAN_PIPE_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * USB pipe management (mostly device-neutral)
33  */
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * pipe structure
41  */
42 typedef struct keyspan_pipe {
43 	kmutex_t		pipe_mutex;	/* structure lock */
44 	keyspan_state_t		*pipe_ksp;	/* backpointer to state */
45 	usb_pipe_handle_t	pipe_handle;	/* pipe handle */
46 	usb_ep_descr_t		pipe_ep_descr;	/* endpoint descriptor */
47 	usb_pipe_policy_t	pipe_policy;	/* pipe policy */
48 	int			pipe_state;	/* pipe state */
49 	usb_log_handle_t	pipe_lh;	/* log handle */
50 } keyspan_pipe_t;
51 
52 _NOTE(MUTEX_PROTECTS_DATA(keyspan_pipe::pipe_mutex, keyspan_pipe))
53 _NOTE(DATA_READABLE_WITHOUT_LOCK(keyspan_pipe::{
54 	pipe_ksp
55 	pipe_handle
56 	pipe_lh
57 	pipe_ep_descr
58 	pipe_policy
59 }))
60 
61 /* pipe states */
62 enum {
63 	KEYSPAN_PIPE_NOT_INIT = 0,
64 	KEYSPAN_PIPE_CLOSED,
65 	KEYSPAN_PIPE_OPEN
66 };
67 
68 
69 int	keyspan_init_pipes(keyspan_state_t *);
70 int	keyspan_init_pipes_usa49wg(keyspan_state_t *);
71 void	keyspan_fini_pipes(keyspan_state_t *);
72 int	keyspansp_open_pipes(keyspan_state_t *);
73 void	keyspansp_close_pipes(keyspan_state_t *);
74 int	keyspan_open_dev_pipes(keyspan_state_t *);
75 void	keyspan_close_dev_pipes(keyspan_state_t *);
76 int	keyspan_open_port_pipes(keyspan_port_t *);
77 void	keyspan_close_port_pipes(keyspan_port_t *);
78 int	keyspan_reopen_pipes(keyspan_state_t *);
79 void	keyspan_close_pipes(keyspan_state_t *);
80 void	keyspan_close_open_pipes(keyspan_state_t *esp);
81 
82 int	keyspan_receive_data(keyspan_pipe_t *, int, void *);
83 int	keyspan_send_data(keyspan_pipe_t *, mblk_t **, void *);
84 int	keyspan_send_data_port0(keyspan_pipe_t *, mblk_t **, void *);
85 
86 int	keyspan_receive_status(keyspan_state_t	*);
87 void	keyspan_pipe_start_polling(keyspan_pipe_t *);
88 
89 #ifdef	__cplusplus
90 }
91 #endif
92 
93 #endif	/* _SYS_USB_USBSER_KEYSPAN_PIPE_H */
94