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 2008 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
30/*
31 * USB pipe management (mostly device-neutral)
32 */
33
34#ifdef	__cplusplus
35extern "C" {
36#endif
37
38/*
39 * pipe structure
40 */
41typedef struct keyspan_pipe {
42	kmutex_t		pipe_mutex;	/* structure lock */
43	keyspan_state_t		*pipe_ksp;	/* backpointer to state */
44	usb_pipe_handle_t	pipe_handle;	/* pipe handle */
45	usb_ep_descr_t		pipe_ep_descr;	/* endpoint descriptor */
46	usb_pipe_policy_t	pipe_policy;	/* pipe policy */
47	int			pipe_state;	/* pipe state */
48	usb_log_handle_t	pipe_lh;	/* log handle */
49} keyspan_pipe_t;
50
51_NOTE(MUTEX_PROTECTS_DATA(keyspan_pipe::pipe_mutex, keyspan_pipe))
52_NOTE(DATA_READABLE_WITHOUT_LOCK(keyspan_pipe::{
53	pipe_ksp
54	pipe_handle
55	pipe_lh
56	pipe_ep_descr
57	pipe_policy
58}))
59
60/* pipe states */
61enum {
62	KEYSPAN_PIPE_NOT_INIT = 0,
63	KEYSPAN_PIPE_CLOSED,
64	KEYSPAN_PIPE_OPEN
65};
66
67
68int	keyspan_init_pipes(keyspan_state_t *);
69int	keyspan_init_pipes_usa49wg(keyspan_state_t *);
70void	keyspan_fini_pipes(keyspan_state_t *);
71int	keyspansp_open_pipes(keyspan_state_t *);
72void	keyspansp_close_pipes(keyspan_state_t *);
73int	keyspan_open_dev_pipes(keyspan_state_t *);
74void	keyspan_close_dev_pipes(keyspan_state_t *);
75int	keyspan_open_port_pipes(keyspan_port_t *);
76void	keyspan_close_port_pipes(keyspan_port_t *);
77int	keyspan_reopen_pipes(keyspan_state_t *);
78void	keyspan_close_pipes(keyspan_state_t *);
79void	keyspan_close_open_pipes(keyspan_state_t *esp);
80
81int	keyspan_receive_data(keyspan_pipe_t *, int, void *);
82int	keyspan_send_data(keyspan_pipe_t *, mblk_t **, void *);
83int	keyspan_send_data_port0(keyspan_pipe_t *, mblk_t **, void *);
84
85int	keyspan_receive_status(keyspan_state_t	*);
86void	keyspan_pipe_start_polling(keyspan_pipe_t *);
87
88#ifdef	__cplusplus
89}
90#endif
91
92#endif	/* _SYS_USB_USBSER_KEYSPAN_PIPE_H */
93