xref: /titanic_52/usr/src/uts/common/sys/ser_sync.h (revision 4b22b9337f359bfd063322244f5336cc7c6ffcfa)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1991,1997-1998 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_SYS_SER_SYNC_H
28 #define	_SYS_SER_SYNC_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Initial port setup parameters for sync lines
34  */
35 
36 #include <sys/stream.h>
37 #include <sys/time_impl.h>
38 #include <sys/ioccom.h>
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 #define	zIOC	('z' << 8)
45 
46 #define	S_IOCGETMODE	(zIOC|01)	/* return struct scc_mode */
47 #define	S_IOCSETMODE	(zIOC|02)	/* set SCC from struct scc_mode */
48 #define	S_IOCGETSTATS	(zIOC|03)	/* return sync data stats */
49 #define	S_IOCCLRSTATS	(zIOC|04)	/* clear sync stats */
50 #define	S_IOCGETSPEED	(zIOC|05)	/* return int baudrate */
51 #define	S_IOCGETMRU	(zIOC|06)	/* return int max receive unit */
52 #define	S_IOCSETMRU	(zIOC|07)	/* set max receive unit */
53 #define	S_IOCGETMTU	(zIOC|010)	/* return int max transmission unit */
54 #define	S_IOCSETMTU	(zIOC|011)	/* set max transmission unit */
55 #define	S_IOCGETMCTL	(zIOC|012)	/* return current CD/CTS state */
56 #define	S_IOCSETDTR	(zIOC|013)	/* Drive DTR signal */
57 
58 /* reason codes for IOCSETMODE */
59 #define	SMERR_TXC	0x0001		/* transmit clock source not valid */
60 #define	SMERR_RXC	0x0002		/* receive clock source not valid */
61 #define	SMERR_IFLAGS	0x0004		/* inversion flags not valid */
62 #define	SMERR_HDX	0x0008		/* CONN_HDX set without CONN_IBM */
63 #define	SMERR_MPT	0x0010		/* CONN_MPT set without CONN_IBM */
64 #define	SMERR_LPBKS	0x0020		/* invalid loopback/echo combination */
65 #define	SMERR_BAUDRATE	0x0040		/* baudrate translates to 0 timeconst */
66 #define	SMERR_PLL	0x0080		/* PLL set with BRG or w/o NRZI */
67 
68 /*
69  * Definitions for modes of operations of
70  * synchronous lines, both RS-232 and RS-449
71  */
72 struct scc_mode {
73 	char	sm_txclock;	/* enum - transmit clock sources */
74 	char	sm_rxclock;	/* enum - receive clock sources */
75 	char    sm_iflags;	/* data and clock invert flags: see hsparam.h */
76 	uchar_t	sm_config;	/* see CONN defines below */
77 	int	sm_baudrate;
78 	int	sm_retval;	/* SMERR codes go here, query with GETMODE */
79 };
80 
81 /*
82  * defines for txclock
83  */
84 #define	TXC_IS_TXC	0	/* use incoming transmit clock */
85 #define	TXC_IS_RXC	1	/* use incoming receive clock */
86 #define	TXC_IS_BAUD	2	/* use baud rate generator */
87 #define	TXC_IS_PLL	3	/* use phase-lock loop output */
88 
89 /*
90  * defines for rxclock
91  */
92 #define	RXC_IS_RXC	0	/* use incoming receive clock */
93 #define	RXC_IS_TXC	1	/* use incoming transmit clock */
94 #define	RXC_IS_BAUD	2	/* use baud rate - only good for loopback */
95 #define	RXC_IS_PLL	3	/* use phase-lock loop */
96 
97 /*
98  * defines for clock/data inversion: from hsparam.h
99  */
100 #define	TXC_IS_SYSCLK	4
101 #define	RXC_IS_SYSCLK	4
102 #define	TXC_IS_INVERT	5
103 #define	RXC_IS_INVERT	5
104 #define	TRXD_NO_INVERT	0
105 #define	RXD_IS_INVERT	1
106 #define	TXD_IS_INVERT	2
107 #define	TRXD_IS_INVERT	3
108 
109 /*
110  * defines for config
111  */
112 #define	CONN_HDX    0x01    /* half-duplex if set, else full-duplex */
113 #define	CONN_MPT    0x02    /* multipoint if set, else point-point */
114 #define	CONN_IBM    0x04    /* set up in IBM-SDLC mode */
115 #define	CONN_SIGNAL 0x08    /* report modem signal changes asynchronously */
116 #define	CONN_NRZI   0x10    /* boolean - use NRZI */
117 #define	CONN_LPBK   0x20    /* do internal loopback */
118 #define	CONN_ECHO   0x40    /* place in auto echo mode */
119 
120 struct sl_status {
121 	int		type;
122 	int		status;
123 	timestruc_t	tstamp;
124 };
125 
126 #if defined(_SYSCALL32)
127 
128 struct sl_status32 {
129 	int32_t		type;
130 	int32_t		status;
131 	timestruc32_t	tstamp;
132 };
133 
134 #endif	/* _SYSCALL32 */
135 
136 /*
137  * defines for type field in sl_status
138  */
139 #define	SLS_MDMSTAT	0x01	/* Non-IBM modem line status change */
140 #define	SLS_LINKERR	0x02	/* IBM mode Link Error, usually modem line. */
141 
142 /*
143  * defines for status field in sl_status
144  * DO NOT change the values for CS_(DCD|CTS)_(UP|DOWN)!!!
145  */
146 #define	CS_DCD_DOWN   	0x08
147 #define	CS_DCD_UP   	0x0c
148 #define	CS_DCD_DROP   	0x10
149 #define	CS_CTS_DOWN	0x20
150 #define	CS_CTS_UP	0x30
151 #define	CS_CTS_DROP   	0x40
152 #define	CS_CTS_TO   	0x80
153 #define	CS_DCD		CS_DCD_DOWN
154 #define	CS_CTS		CS_CTS_DOWN
155 
156 /*
157  * Event statistics reported by hardware.
158  */
159 struct sl_stats {
160 	int	ipack;		/* input packets */
161 	int	opack;		/* output packets */
162 	int	ichar;		/* input bytes */
163 	int	ochar;		/* output bytes */
164 	int	abort;		/* abort received */
165 	int	crc;		/* CRC error */
166 	int	cts;		/* CTS timeouts */
167 	int	dcd;		/* Carrier drops */
168 	int	overrun;	/* receiver overrun */
169 	int	underrun;	/* xmitter underrun */
170 	int	ierror;		/* input error (rxbad) */
171 	int	oerror;		/* output error (watchdog timeout) */
172 	int	nobuffers;	/* no active receive block available */
173 };
174 
175 
176 
177 /*
178  * Per-stream structure.  Each of these points to only one device instance,
179  * but there may be more than one doing so.  If marked as ST_CLONE, it has
180  * been opened throught the clone device, and cannot have the data path.
181  */
182 struct ser_str {
183 	queue_t		*str_rq;	/* This stream's read queue */
184 	caddr_t		str_com;	/* Back pointer to device struct */
185 	int		str_inst;	/* Device instance (unit) number */
186 	int		str_state;	/* see below */
187 };
188 
189 /*
190  * Synchronous Protocol Private Data Structure
191  */
192 #define	ZSH_MAX_RSTANDBY	6
193 #define	ZSH_RDONE_MAX		20
194 struct syncline {
195 	struct ser_str	sl_stream;	/* data path device points thru here */
196 	struct scc_mode	sl_mode;	/* clock, etc. modes */
197 	struct sl_stats	sl_st;		/* Data and error statistics */
198 	mblk_t		*sl_rhead;	/* receive: head of active message */
199 	mblk_t		*sl_ractb;	/* receive: active message block */
200 	mblk_t		*sl_rstandby[ZSH_MAX_RSTANDBY];
201 					/* receive: standby message blocks */
202 	mblk_t		*sl_xhead;	/* transmit: head of active message */
203 	mblk_t		*sl_xactb;	/* transmit: active message block */
204 	mblk_t		*sl_xstandby;	/* transmit: next available message */
205 	mblk_t		*sl_rdone[ZSH_RDONE_MAX];
206 					/* complete messages to be sent up */
207 	int		sl_rdone_wptr;
208 	int		sl_rdone_rptr;
209 	mblk_t		*sl_mstat;	/* most recent modem status change */
210 	bufcall_id_t	sl_bufcid;	/* pending bufcall ID */
211 	timeout_id_t	sl_wd_id;	/* watchdog timeout ID */
212 	int		sl_wd_count;	/* watchdog counter */
213 	int		sl_ocnt;	/* output message size */
214 	int		sl_mru;		/* Maximum Receive Unit */
215 	int		sl_bad_count_int;
216 	uchar_t		sl_rr0;		/* saved RR0 */
217 	uchar_t		sl_address;	/* station address */
218 	uchar_t		sl_txstate;	/* transmit state */
219 	uchar_t		sl_flags;	/* see below */
220 	uchar_t		sl_m_error;
221 	volatile uchar_t sl_soft_active; /*  */
222 };
223 
224 /*
225  * Bit definitions for sl_txstate.
226  */
227 #define	TX_OFF		0x0		/* Not available */
228 #define	TX_IDLE		0x1		/* Initialized */
229 #define	TX_RTS		0x2		/* IBM: RTS up, okay to transmit */
230 #define	TX_ACTIVE	0x4		/* Transmission in progress */
231 #define	TX_CRC		0x8		/* Sent all Data */
232 #define	TX_FLAG		0x10		/* Sent CRC bytes */
233 #define	TX_LAST		0x20		/* End-Of-Frame, OK to start new msg */
234 #define	TX_ABORTED	0x40		/* Transmit was aborted */
235 
236 /*
237  * Bit definitions for sl_flags.
238  */
239 #define	SF_FDXPTP	0x1	/* Full duplex AND Point-To-Point */
240 #define	SF_XMT_INPROG	0x2	/* Write queue is not empty */
241 #define	SF_LINKERR	0x4	/* Underrun or CTS/DCD drop */
242 #define	SF_FLUSH_WQ	0x8	/*  */
243 #define	SF_INITIALIZED	0x10	/* This channel programmed for this protocol */
244 #define	SF_PHONY	0x20	/* Dummy frame has been sent to close frame */
245 #define	SF_ZSH_START	0x40	/*  */
246 /*
247  * Bit definitions for str_state.
248  */
249 #define	STR_CLONE	1	/* This was opened thru clone device */
250 
251 extern int hz;
252 #define	SIO_WATCHDOG_TICK	(2 * hz)	/* Two second timeout */
253 #define	SIO_WATCHDOG_ON		(zss->sl_wd_id > 0)	/* Is it on? */
254 
255 
256 #ifdef	__cplusplus
257 }
258 #endif
259 
260 #endif	/* !_SYS_SER_SYNC_H */
261