xref: /titanic_51/usr/src/uts/sun4/sys/sudev.h (revision d3cf9c7d3cb6a89c5ee679d866610bc6baaf2c9a)
1*d3cf9c7dSdf157793 /*
2*d3cf9c7dSdf157793  * CDDL HEADER START
3*d3cf9c7dSdf157793  *
4*d3cf9c7dSdf157793  * The contents of this file are subject to the terms of the
5*d3cf9c7dSdf157793  * Common Development and Distribution License, Version 1.0 only
6*d3cf9c7dSdf157793  * (the "License").  You may not use this file except in compliance
7*d3cf9c7dSdf157793  * with the License.
8*d3cf9c7dSdf157793  *
9*d3cf9c7dSdf157793  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*d3cf9c7dSdf157793  * or http://www.opensolaris.org/os/licensing.
11*d3cf9c7dSdf157793  * See the License for the specific language governing permissions
12*d3cf9c7dSdf157793  * and limitations under the License.
13*d3cf9c7dSdf157793  *
14*d3cf9c7dSdf157793  * When distributing Covered Code, include this CDDL HEADER in each
15*d3cf9c7dSdf157793  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*d3cf9c7dSdf157793  * If applicable, add the following below this CDDL HEADER, with the
17*d3cf9c7dSdf157793  * fields enclosed by brackets "[]" replaced with your own identifying
18*d3cf9c7dSdf157793  * information: Portions Copyright [yyyy] [name of copyright owner]
19*d3cf9c7dSdf157793  *
20*d3cf9c7dSdf157793  * CDDL HEADER END
21*d3cf9c7dSdf157793  */
22*d3cf9c7dSdf157793 /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.	*/
23*d3cf9c7dSdf157793 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T	*/
24*d3cf9c7dSdf157793 /*	  All Rights Reserved 	*/
25*d3cf9c7dSdf157793 
26*d3cf9c7dSdf157793 /*
27*d3cf9c7dSdf157793  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28*d3cf9c7dSdf157793  * Use is subject to license terms.
29*d3cf9c7dSdf157793  */
30*d3cf9c7dSdf157793 
31*d3cf9c7dSdf157793 #ifndef	_SYS_SUDEV_H
32*d3cf9c7dSdf157793 #define	_SYS_SUDEV_H
33*d3cf9c7dSdf157793 
34*d3cf9c7dSdf157793 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35*d3cf9c7dSdf157793 
36*d3cf9c7dSdf157793 #ifdef __cplusplus
37*d3cf9c7dSdf157793 extern "C" {
38*d3cf9c7dSdf157793 #endif
39*d3cf9c7dSdf157793 
40*d3cf9c7dSdf157793 #include <sys/tty.h>
41*d3cf9c7dSdf157793 #include <sys/ksynch.h>
42*d3cf9c7dSdf157793 #include <sys/dditypes.h>
43*d3cf9c7dSdf157793 #include <sys/types.h>
44*d3cf9c7dSdf157793 #include <sys/kstat.h>
45*d3cf9c7dSdf157793 
46*d3cf9c7dSdf157793 /*
47*d3cf9c7dSdf157793  * Definitions for INS8250 / 16550  chips
48*d3cf9c7dSdf157793  */
49*d3cf9c7dSdf157793 
50*d3cf9c7dSdf157793 /* defined as offsets from the data register */
51*d3cf9c7dSdf157793 #define	DAT		0 	/* receive/transmit data */
52*d3cf9c7dSdf157793 #define	ICR		1  	/* interrupt control register */
53*d3cf9c7dSdf157793 #define	ISR		2   	/* interrupt status register */
54*d3cf9c7dSdf157793 #define	LCR		3   	/* line control register */
55*d3cf9c7dSdf157793 #define	MCR		4   	/* modem control register */
56*d3cf9c7dSdf157793 #define	LSR		5   	/* line status register */
57*d3cf9c7dSdf157793 #define	MSR		6   	/* modem status register */
58*d3cf9c7dSdf157793 #define	DLL		0   	/* divisor latch (lsb) */
59*d3cf9c7dSdf157793 #define	DLH		1   	/* divisor latch (msb) */
60*d3cf9c7dSdf157793 #define	FIFOR		ISR	/* FIFO register for 16550 */
61*d3cf9c7dSdf157793 #define	OUTB(offset, value)	ddi_put8(asy->asy_handle, \
62*d3cf9c7dSdf157793 				    asy->asy_ioaddr+offset, value)
63*d3cf9c7dSdf157793 #define	INB(offset)	ddi_get8(asy->asy_handle, asy->asy_ioaddr+offset)
64*d3cf9c7dSdf157793 
65*d3cf9c7dSdf157793 /*
66*d3cf9c7dSdf157793  * INTEL 8210-A/B & 16450/16550 Registers Structure.
67*d3cf9c7dSdf157793  */
68*d3cf9c7dSdf157793 
69*d3cf9c7dSdf157793 /* Line Control Register */
70*d3cf9c7dSdf157793 #define	WLS0		0x01	/* word length select bit 0 */
71*d3cf9c7dSdf157793 #define	WLS1		0x02	/* word length select bit 2 */
72*d3cf9c7dSdf157793 #define	STB		0x04	/* number of stop bits */
73*d3cf9c7dSdf157793 #define	PEN		0x08	/* parity enable */
74*d3cf9c7dSdf157793 #define	EPS		0x10	/* even parity select */
75*d3cf9c7dSdf157793 #define	SETBREAK 	0x40	/* break key */
76*d3cf9c7dSdf157793 #define	DLAB		0x80	/* divisor latch access bit */
77*d3cf9c7dSdf157793 #define	RXLEN   	0x03   	/* # of data bits per received/xmitted char */
78*d3cf9c7dSdf157793 #define	STOP1   	0x00
79*d3cf9c7dSdf157793 #define	STOP2   	0x04
80*d3cf9c7dSdf157793 #define	PAREN   	0x08
81*d3cf9c7dSdf157793 #define	PAREVN  	0x10
82*d3cf9c7dSdf157793 #define	PARMARK 	0x20
83*d3cf9c7dSdf157793 #define	SNDBRK  	0x40
84*d3cf9c7dSdf157793 
85*d3cf9c7dSdf157793 
86*d3cf9c7dSdf157793 #define	BITS5		0x00	/* 5 bits per char */
87*d3cf9c7dSdf157793 #define	BITS6		0x01	/* 6 bits per char */
88*d3cf9c7dSdf157793 #define	BITS7		0x02	/* 7 bits per char */
89*d3cf9c7dSdf157793 #define	BITS8		0x03	/* 8 bits per char */
90*d3cf9c7dSdf157793 
91*d3cf9c7dSdf157793 /* baud rate definitions */
92*d3cf9c7dSdf157793 #define	ASY110		1047	/* 110 baud rate for serial console */
93*d3cf9c7dSdf157793 #define	ASY150		768	/* 150 baud rate for serial console */
94*d3cf9c7dSdf157793 #define	ASY300		384	/* 300 baud rate for serial console */
95*d3cf9c7dSdf157793 #define	ASY600		192	/* 600 baud rate for serial console */
96*d3cf9c7dSdf157793 #define	ASY1200		96	/* 1200 baud rate for serial console */
97*d3cf9c7dSdf157793 #define	ASY2400		48	/* 2400 baud rate for serial console */
98*d3cf9c7dSdf157793 #define	ASY4800		24	/* 4800 baud rate for serial console */
99*d3cf9c7dSdf157793 #define	ASY9600		12	/* 9600 baud rate for serial console */
100*d3cf9c7dSdf157793 
101*d3cf9c7dSdf157793 /* Line Status Register */
102*d3cf9c7dSdf157793 #define	RCA		0x01	/* data ready */
103*d3cf9c7dSdf157793 #define	OVRRUN		0x02	/* overrun error */
104*d3cf9c7dSdf157793 #define	PARERR		0x04	/* parity error */
105*d3cf9c7dSdf157793 #define	FRMERR		0x08	/* framing error */
106*d3cf9c7dSdf157793 #define	BRKDET  	0x10	/* a break has arrived */
107*d3cf9c7dSdf157793 #define	XHRE		0x20	/* tx hold reg is now empty */
108*d3cf9c7dSdf157793 #define	XSRE		0x40	/* tx shift reg is now empty */
109*d3cf9c7dSdf157793 #define	RFBE		0x80	/* rx FIFO Buffer error */
110*d3cf9c7dSdf157793 
111*d3cf9c7dSdf157793 /* Interrupt Id Regisger */
112*d3cf9c7dSdf157793 #define	MSTATUS		0x00	/* modem status changed */
113*d3cf9c7dSdf157793 #define	NOINTERRUPT	0x01	/* no interrupt pending */
114*d3cf9c7dSdf157793 #define	TxRDY		0x02	/* Transmitter Holding Register Empty */
115*d3cf9c7dSdf157793 #define	RxRDY		0x04	/* Receiver Data Available */
116*d3cf9c7dSdf157793 #define	FFTMOUT 	0x0c	/* FIFO timeout - 16550AF */
117*d3cf9c7dSdf157793 #define	RSTATUS 	0x06	/* Receiver Line Status */
118*d3cf9c7dSdf157793 
119*d3cf9c7dSdf157793 /* Interrupt Enable Register */
120*d3cf9c7dSdf157793 #define	RIEN		0x01	/* Received Data Ready */
121*d3cf9c7dSdf157793 #define	TIEN		0x02	/* Tx Hold Register Empty */
122*d3cf9c7dSdf157793 #define	SIEN		0x04	/* Receiver Line Status */
123*d3cf9c7dSdf157793 #define	MIEN		0x08	/* Modem Status */
124*d3cf9c7dSdf157793 
125*d3cf9c7dSdf157793 /* Modem Control Register */
126*d3cf9c7dSdf157793 #define	DTR		0x01	/* Data Terminal Ready */
127*d3cf9c7dSdf157793 #define	RTS		0x02	/* Request To Send */
128*d3cf9c7dSdf157793 #define	OUT1		0x04	/* Aux output - not used */
129*d3cf9c7dSdf157793 #define	OUT2		0x08	/* dis/enable int per INO on ALI1535D+ */
130*d3cf9c7dSdf157793 #define	ASY_LOOP	0x10	/* loopback for diagnostics */
131*d3cf9c7dSdf157793 
132*d3cf9c7dSdf157793 /* Modem Status Register */
133*d3cf9c7dSdf157793 #define	DCTS		0x01	/* Delta Clear To Send */
134*d3cf9c7dSdf157793 #define	DDSR		0x02	/* Delta Data Set Ready */
135*d3cf9c7dSdf157793 #define	DRI		0x04	/* Trail Edge Ring Indicator */
136*d3cf9c7dSdf157793 #define	DDCD		0x08	/* Delta Data Carrier Detect */
137*d3cf9c7dSdf157793 #define	CTS		0x10	/* Clear To Send */
138*d3cf9c7dSdf157793 #define	DSR		0x20	/* Data Set Ready */
139*d3cf9c7dSdf157793 #define	RI		0x40	/* Ring Indicator */
140*d3cf9c7dSdf157793 #define	DCD		0x80	/* Data Carrier Detect */
141*d3cf9c7dSdf157793 
142*d3cf9c7dSdf157793 #define	DELTAS(x)	((x)&(DCTS|DDSR|DRI|DDCD))
143*d3cf9c7dSdf157793 #define	STATES(x)	((x)(CTS|DSR|RI|DCD))
144*d3cf9c7dSdf157793 
145*d3cf9c7dSdf157793 /* flags for FCR (FIFO Control register) */
146*d3cf9c7dSdf157793 #define	FIFO_OFF	0x00	/* fifo disabled */
147*d3cf9c7dSdf157793 #define	FIFO_ON		0x01	/* fifo enabled */
148*d3cf9c7dSdf157793 #define	FIFOEN		0x8f	/* fifo enabled, w/ 8 byte trigger */
149*d3cf9c7dSdf157793 #define	FIFORCLR	0x8b	/* Clear receiver FIFO only */
150*d3cf9c7dSdf157793 
151*d3cf9c7dSdf157793 #define	FIFORXFLSH	0x02	/* flush receiver FIFO */
152*d3cf9c7dSdf157793 #define	FIFOTXFLSH	0x04	/* flush transmitter FIFO */
153*d3cf9c7dSdf157793 #define	FIFODMA		0x08	/* DMA mode 1 */
154*d3cf9c7dSdf157793 #define	FIFO_TRIG_1	0x00	/* 1 byte trigger level */
155*d3cf9c7dSdf157793 #define	FIFO_TRIG_4	0x40	/* 4 byte trigger level */
156*d3cf9c7dSdf157793 #define	FIFO_TRIG_8	0x80	/* 8 byte trigger level */
157*d3cf9c7dSdf157793 #define	FIFO_TRIG_14	0xC0	/* 14 byte trigger level */
158*d3cf9c7dSdf157793 
159*d3cf9c7dSdf157793 /*
160*d3cf9c7dSdf157793  * Defines for ioctl calls (VP/ix)
161*d3cf9c7dSdf157793  */
162*d3cf9c7dSdf157793 
163*d3cf9c7dSdf157793 #define	AIOC		('A'<<8)
164*d3cf9c7dSdf157793 #define	AIOCINTTYPE	(AIOC|60)	/* set interrupt type */
165*d3cf9c7dSdf157793 #define	AIOCDOSMODE	(AIOC|61)	/* set DOS mode */
166*d3cf9c7dSdf157793 #define	AIOCNONDOSMODE	(AIOC|62)	/* reset DOS mode */
167*d3cf9c7dSdf157793 #define	AIOCSERIALOUT	(AIOC|63)	/* serial device data write */
168*d3cf9c7dSdf157793 #define	AIOCSERIALIN	(AIOC|64)	/* serial device data read */
169*d3cf9c7dSdf157793 #define	AIOCSETSS	(AIOC|65)	/* set start/stop chars */
170*d3cf9c7dSdf157793 #define	AIOCINFO	(AIOC|66)	/* tell usr what device we are */
171*d3cf9c7dSdf157793 
172*d3cf9c7dSdf157793 /* Ioctl alternate names used by VP/ix */
173*d3cf9c7dSdf157793 #define	VPC_SERIAL_DOS		AIOCDOSMODE
174*d3cf9c7dSdf157793 #define	VPC_SERIAL_NONDOS	AIOCNONDOSMODE
175*d3cf9c7dSdf157793 #define	VPC_SERIAL_INFO		AIOCINFO
176*d3cf9c7dSdf157793 #define	VPC_SERIAL_OUT		AIOCSERIALOUT
177*d3cf9c7dSdf157793 #define	VPC_SERIAL_IN		AIOCSERIALIN
178*d3cf9c7dSdf157793 
179*d3cf9c7dSdf157793 /* Serial in/out requests */
180*d3cf9c7dSdf157793 #define	SO_DIVLLSB	1
181*d3cf9c7dSdf157793 #define	SO_DIVLMSB	2
182*d3cf9c7dSdf157793 #define	SO_LCR		3
183*d3cf9c7dSdf157793 #define	SO_MCR		4
184*d3cf9c7dSdf157793 #define	SI_MSR		1
185*d3cf9c7dSdf157793 #define	SIO_MASK(elem)		(1<<((elem)-1))
186*d3cf9c7dSdf157793 
187*d3cf9c7dSdf157793 #define	OVERRUN		040000
188*d3cf9c7dSdf157793 #define	FRERROR		020000
189*d3cf9c7dSdf157793 #define	PERROR		010000
190*d3cf9c7dSdf157793 #define	S_ERRORS	(PERROR|OVERRUN|FRERROR)
191*d3cf9c7dSdf157793 
192*d3cf9c7dSdf157793 /*
193*d3cf9c7dSdf157793  * Ring buffer and async line management definitions.
194*d3cf9c7dSdf157793  */
195*d3cf9c7dSdf157793 #define	RINGBITS	16		/* # of bits in ring ptrs */
196*d3cf9c7dSdf157793 #define	RINGSIZE	(1<<RINGBITS)   /* size of ring */
197*d3cf9c7dSdf157793 #define	RINGMASK	(RINGSIZE-1)
198*d3cf9c7dSdf157793 #define	RINGFRAC	12		/* fraction of ring to force flush */
199*d3cf9c7dSdf157793 
200*d3cf9c7dSdf157793 #define	RING_INIT(ap)  ((ap)->async_rput = (ap)->async_rget = 0)
201*d3cf9c7dSdf157793 #define	RING_CNT(ap)   (((ap)->async_rput - (ap)->async_rget) & RINGMASK)
202*d3cf9c7dSdf157793 #define	RING_FRAC(ap)  ((int)RING_CNT(ap) >= (int)(RINGSIZE/RINGFRAC))
203*d3cf9c7dSdf157793 #define	RING_POK(ap, n) ((int)RING_CNT(ap) < (int)(RINGSIZE-(n)))
204*d3cf9c7dSdf157793 #define	RING_PUT(ap, c) \
205*d3cf9c7dSdf157793 	((ap)->async_ring[(ap)->async_rput++ & RINGMASK] =  (uchar_t)(c))
206*d3cf9c7dSdf157793 #define	RING_UNPUT(ap) ((ap)->async_rput--)
207*d3cf9c7dSdf157793 #define	RING_GOK(ap, n) ((int)RING_CNT(ap) >= (int)(n))
208*d3cf9c7dSdf157793 #define	RING_GET(ap)   ((ap)->async_ring[(ap)->async_rget++ & RINGMASK])
209*d3cf9c7dSdf157793 #define	RING_EAT(ap, n) ((ap)->async_rget += (n))
210*d3cf9c7dSdf157793 #define	RING_MARK(ap, c, s) \
211*d3cf9c7dSdf157793 	((ap)->async_ring[(ap)->async_rput++ & RINGMASK] = ((uchar_t)(c)|(s)))
212*d3cf9c7dSdf157793 #define	RING_UNMARK(ap) \
213*d3cf9c7dSdf157793 	((ap)->async_ring[((ap)->async_rget) & RINGMASK] &= ~S_ERRORS)
214*d3cf9c7dSdf157793 #define	RING_ERR(ap, c) \
215*d3cf9c7dSdf157793 	((ap)->async_ring[((ap)->async_rget) & RINGMASK] & (c))
216*d3cf9c7dSdf157793 
217*d3cf9c7dSdf157793 /*
218*d3cf9c7dSdf157793  * Serial kstats structure and macro to increment an individual kstat
219*d3cf9c7dSdf157793  */
220*d3cf9c7dSdf157793 struct serial_kstats {
221*d3cf9c7dSdf157793 		kstat_named_t	ringover;	/* ring buffer overflow */
222*d3cf9c7dSdf157793 		kstat_named_t	siloover;	/* silo overflow */
223*d3cf9c7dSdf157793 };
224*d3cf9c7dSdf157793 
225*d3cf9c7dSdf157793 #define	INC64_KSTAT(asy, stat) (asy)->kstats.stat.value.ui64++;
226*d3cf9c7dSdf157793 
227*d3cf9c7dSdf157793 /*
228*d3cf9c7dSdf157793  * Hardware channel common data. One structure per port.
229*d3cf9c7dSdf157793  * Each of the fields in this structure is required to be protected by a
230*d3cf9c7dSdf157793  * mutex lock at the highest priority at which it can be altered.
231*d3cf9c7dSdf157793  * The asy_flags, and asy_next fields can be altered by interrupt
232*d3cf9c7dSdf157793  * handling code that must be protected by the mutex whose handle is
233*d3cf9c7dSdf157793  * stored in asy_excl_hi.  All others can be protected by the asy_excl
234*d3cf9c7dSdf157793  * mutex, which is lower priority and adaptive.
235*d3cf9c7dSdf157793  */
236*d3cf9c7dSdf157793 struct asycom {
237*d3cf9c7dSdf157793 	int		asy_flags;	/* random flags  */
238*d3cf9c7dSdf157793 					/* protected by asy_excl_hi lock */
239*d3cf9c7dSdf157793 	uint_t		asy_hwtype;	/* HW type: ASY82510, etc. */
240*d3cf9c7dSdf157793 	uint_t		asy_use_fifo;	/* HW FIFO use it or not ?? */
241*d3cf9c7dSdf157793 	uint_t		asy_fifo_buf;	/* With FIFO = 16, otherwise = 1 */
242*d3cf9c7dSdf157793 	uchar_t		*asy_ioaddr;	/* i/o address of ASY port */
243*d3cf9c7dSdf157793 	uint_t		asy_vect;	/* IRQ number */
244*d3cf9c7dSdf157793 	boolean_t	suspended;	/* TRUE if driver suspended */
245*d3cf9c7dSdf157793 	caddr_t		asy_priv;	/* protocol private data */
246*d3cf9c7dSdf157793 	dev_info_t	*asy_dip;	/* dev_info */
247*d3cf9c7dSdf157793 	long		asy_unit;	/* which port */
248*d3cf9c7dSdf157793 	ddi_iblock_cookie_t asy_iblock;
249*d3cf9c7dSdf157793 	kmutex_t	*asy_excl;	/* asy adaptive mutex */
250*d3cf9c7dSdf157793 	kmutex_t	*asy_excl_hi;	/* asy spinlock mutex */
251*d3cf9c7dSdf157793 	ddi_acc_handle_t asy_handle;    /* ddi_get/put handle */
252*d3cf9c7dSdf157793 	ushort_t	asy_rsc_console;	/* RSC console port */
253*d3cf9c7dSdf157793 	ushort_t	asy_rsc_control;	/* RSC control port */
254*d3cf9c7dSdf157793 	ushort_t	asy_lom_console;	/* LOM console port */
255*d3cf9c7dSdf157793 	uint_t		asy_xmit_count;	/* Count the no of xmits in one intr */
256*d3cf9c7dSdf157793 	uint_t		asy_out_of_band_xmit; /* Out of band xmission */
257*d3cf9c7dSdf157793 	uint_t		asy_rx_count;	/* No. of bytes rx'eved in one intr */
258*d3cf9c7dSdf157793 	uchar_t		asy_device_type; /* Currently used for this device */
259*d3cf9c7dSdf157793 	uchar_t		asy_trig_level;	/* Receive FIFO trig level */
260*d3cf9c7dSdf157793 	kmutex_t	*asy_soft_lock;	/* soft lock for gaurding softpend. */
261*d3cf9c7dSdf157793 	int		asysoftpend;	/* Flag indicating soft int pending. */
262*d3cf9c7dSdf157793 	ddi_softintr_t asy_softintr_id;
263*d3cf9c7dSdf157793 	ddi_iblock_cookie_t asy_soft_iblock;
264*d3cf9c7dSdf157793 	int		asy_baud_divisor_factor; /* for different chips */
265*d3cf9c7dSdf157793 	int		asy_ocflags; /* old cflags used in asy_program() */
266*d3cf9c7dSdf157793 	uint_t		asy_cached_msr; /* a cache for the MSR register */
267*d3cf9c7dSdf157793 	int		asy_speed_cap; /* maximum baud rate */
268*d3cf9c7dSdf157793 	kstat_t		*sukstat;	/* ptr to serial kstats */
269*d3cf9c7dSdf157793 	struct serial_kstats kstats;	/* serial kstats structure */
270*d3cf9c7dSdf157793 	boolean_t	inperim;	/* in streams q perimeter */
271*d3cf9c7dSdf157793 };
272*d3cf9c7dSdf157793 
273*d3cf9c7dSdf157793 /*
274*d3cf9c7dSdf157793  * Asychronous protocol private data structure for ASY.
275*d3cf9c7dSdf157793  * Each of the fields in the structure is required to be protected by
276*d3cf9c7dSdf157793  * the lower priority lock except the fields that are set only at
277*d3cf9c7dSdf157793  * base level but cleared (with out lock) at interrupt level.
278*d3cf9c7dSdf157793  */
279*d3cf9c7dSdf157793 struct asyncline {
280*d3cf9c7dSdf157793 	int		async_flags;	/* random flags */
281*d3cf9c7dSdf157793 	kcondvar_t	async_flags_cv; /* condition variable for flags */
282*d3cf9c7dSdf157793 	dev_t		async_dev;	/* device major/minor numbers */
283*d3cf9c7dSdf157793 	mblk_t		*async_xmitblk;	/* transmit: active msg block */
284*d3cf9c7dSdf157793 	struct asycom	*async_common;	/* device common data */
285*d3cf9c7dSdf157793 	tty_common_t 	async_ttycommon; /* tty driver common data */
286*d3cf9c7dSdf157793 	bufcall_id_t	async_wbufcid;	/* id for pending write-side bufcall */
287*d3cf9c7dSdf157793 	timeout_id_t	async_polltid;	/* softint poll timeout id */
288*d3cf9c7dSdf157793 
289*d3cf9c7dSdf157793 	/*
290*d3cf9c7dSdf157793 	 * The following fields are protected by the asy_excl_hi lock.
291*d3cf9c7dSdf157793 	 * Some, such as async_flowc, are set only at the base level and
292*d3cf9c7dSdf157793 	 * cleared (without the lock) only by the interrupt level.
293*d3cf9c7dSdf157793 	 */
294*d3cf9c7dSdf157793 	uchar_t		*async_optr;	/* output pointer */
295*d3cf9c7dSdf157793 	int		async_ocnt;	/* output count */
296*d3cf9c7dSdf157793 	uint_t		async_rput;	/* producing pointer for input */
297*d3cf9c7dSdf157793 	uint_t		async_rget;	/* consuming pointer for input */
298*d3cf9c7dSdf157793 	uchar_t		async_flowc;	/* flow control char to send */
299*d3cf9c7dSdf157793 
300*d3cf9c7dSdf157793 	/*
301*d3cf9c7dSdf157793 	 * Each character stuffed into the ring has two bytes associated
302*d3cf9c7dSdf157793 	 * with it.  The first byte is used to indicate special conditions
303*d3cf9c7dSdf157793 	 * and the second byte is the actual data.  The ring buffer
304*d3cf9c7dSdf157793 	 * needs to be defined as ushort_t to accomodate this.
305*d3cf9c7dSdf157793 	 */
306*d3cf9c7dSdf157793 	ushort_t	async_ring[RINGSIZE];
307*d3cf9c7dSdf157793 
308*d3cf9c7dSdf157793 	short		async_break;	/* break count */
309*d3cf9c7dSdf157793 
310*d3cf9c7dSdf157793 	union {
311*d3cf9c7dSdf157793 		struct {
312*d3cf9c7dSdf157793 			uchar_t _hw;	/* overrun (hw) */
313*d3cf9c7dSdf157793 			uchar_t _sw;	/* overrun (sw) */
314*d3cf9c7dSdf157793 		} _a;
315*d3cf9c7dSdf157793 		ushort_t uover_overrun;
316*d3cf9c7dSdf157793 	} async_uover;
317*d3cf9c7dSdf157793 #define	async_overrun		async_uover._a.uover_overrun
318*d3cf9c7dSdf157793 #define	async_hw_overrun	async_uover._a._hw
319*d3cf9c7dSdf157793 #define	async_sw_overrun	async_uover._a._sw
320*d3cf9c7dSdf157793 	short		async_ext;	/* modem status change count */
321*d3cf9c7dSdf157793 	short		async_work;	/* work to do flag */
322*d3cf9c7dSdf157793 	uchar_t		async_queue_full; /* Streams Queue Full */
323*d3cf9c7dSdf157793 	uchar_t		async_ringbuf_overflow; /* when ring buffer overflows */
324*d3cf9c7dSdf157793 	timeout_id_t	async_timer;	/* close drain progress timer */
325*d3cf9c7dSdf157793 };
326*d3cf9c7dSdf157793 
327*d3cf9c7dSdf157793 /* definitions for async_flags field */
328*d3cf9c7dSdf157793 #define	ASYNC_EXCL_OPEN	 0x10000000	/* exclusive open */
329*d3cf9c7dSdf157793 #define	ASYNC_WOPEN	 0x00000001	/* waiting for open to complete */
330*d3cf9c7dSdf157793 #define	ASYNC_ISOPEN	 0x00000002	/* open is complete */
331*d3cf9c7dSdf157793 #define	ASYNC_OUT	 0x00000004	/* line being used for dialout */
332*d3cf9c7dSdf157793 #define	ASYNC_CARR_ON	 0x00000008	/* carrier on last time we looked */
333*d3cf9c7dSdf157793 #define	ASYNC_STOPPED	 0x00000010	/* output is stopped */
334*d3cf9c7dSdf157793 #define	ASYNC_DELAY	 0x00000020	/* waiting for delay to finish */
335*d3cf9c7dSdf157793 #define	ASYNC_BREAK	 0x00000040	/* waiting for break to finish */
336*d3cf9c7dSdf157793 #define	ASYNC_BUSY	 0x00000080	/* waiting for transmission to finish */
337*d3cf9c7dSdf157793 #define	ASYNC_DRAINING	 0x00000100	/* waiting for output to drain */
338*d3cf9c7dSdf157793 #define	ASYNC_SERVICEIMM 0x00000200	/* queue soft interrupt as soon as */
339*d3cf9c7dSdf157793 #define	ASYNC_HW_IN_FLOW 0x00000400	/* input flow control in effect */
340*d3cf9c7dSdf157793 #define	ASYNC_HW_OUT_FLW 0x00000800	/* output flow control in effect */
341*d3cf9c7dSdf157793 #define	ASYNC_PROGRESS	 0x00001000	/* made progress on output effort */
342*d3cf9c7dSdf157793 #define	ASYNC_CLOSING	 0x00002000	/* closing the stream */
343*d3cf9c7dSdf157793 
344*d3cf9c7dSdf157793 /* asy_hwtype definitions */
345*d3cf9c7dSdf157793 #define	ASY82510	0x1
346*d3cf9c7dSdf157793 #define	ASY16550AF	0x2
347*d3cf9c7dSdf157793 #define	ASY8250		0x3		/* 8250 or 16450 or 16550 */
348*d3cf9c7dSdf157793 
349*d3cf9c7dSdf157793 /* definitions for asy_flags field */
350*d3cf9c7dSdf157793 #define	ASY_NEEDSOFT	0x00000001
351*d3cf9c7dSdf157793 #define	ASY_DOINGSOFT	0x00000002
352*d3cf9c7dSdf157793 #define	ASY_PPS		0x00000004
353*d3cf9c7dSdf157793 #define	ASY_PPS_EDGE	0x00000008
354*d3cf9c7dSdf157793 #define	ASY_IGNORE_CD	0x00000040
355*d3cf9c7dSdf157793 
356*d3cf9c7dSdf157793 /*
357*d3cf9c7dSdf157793  * Different devices this driver supports and what it is used to drive
358*d3cf9c7dSdf157793  * currently
359*d3cf9c7dSdf157793  */
360*d3cf9c7dSdf157793 #define	ASY_KEYBOARD 	0x01
361*d3cf9c7dSdf157793 #define	ASY_MOUSE	0x02
362*d3cf9c7dSdf157793 #define	ASY_SERIAL	0x03
363*d3cf9c7dSdf157793 
364*d3cf9c7dSdf157793 /*
365*d3cf9c7dSdf157793  * RSC_DEVICE defines the bit in the minor device number that specifies
366*d3cf9c7dSdf157793  * the tty line is to be used for console/controlling a RSC device.
367*d3cf9c7dSdf157793  */
368*d3cf9c7dSdf157793 #define	RSC_DEVICE	(1 << (NBITSMINOR32 - 4))
369*d3cf9c7dSdf157793 
370*d3cf9c7dSdf157793 /*
371*d3cf9c7dSdf157793  * OUTLINE defines the high-order flag bit in the minor device number that
372*d3cf9c7dSdf157793  * controls use of a tty line for dialin and dialout simultaneously.
373*d3cf9c7dSdf157793  */
374*d3cf9c7dSdf157793 #define	OUTLINE		(1 << (NBITSMINOR32 - 1))
375*d3cf9c7dSdf157793 #define	UNIT(x)		(getminor(x) & ~(OUTLINE | RSC_DEVICE))
376*d3cf9c7dSdf157793 
377*d3cf9c7dSdf157793 /* suggested number of soft state instances */
378*d3cf9c7dSdf157793 #define	SU_INITIAL_SOFT_ITEMS	0x02
379*d3cf9c7dSdf157793 
380*d3cf9c7dSdf157793 /*
381*d3cf9c7dSdf157793  * ASYSETSOFT macro to pend a soft interrupt if one isn't already pending.
382*d3cf9c7dSdf157793  */
383*d3cf9c7dSdf157793 
384*d3cf9c7dSdf157793 #define	ASYSETSOFT(asy)	{		\
385*d3cf9c7dSdf157793 	if (mutex_tryenter(asy->asy_soft_lock)) {	\
386*d3cf9c7dSdf157793 		asy->asy_flags |= ASY_NEEDSOFT;	\
387*d3cf9c7dSdf157793 		if (!asy->asysoftpend) {		\
388*d3cf9c7dSdf157793 			asy->asysoftpend = 1;	\
389*d3cf9c7dSdf157793 			mutex_exit(asy->asy_soft_lock);\
390*d3cf9c7dSdf157793 			ddi_trigger_softintr(asy->asy_softintr_id);\
391*d3cf9c7dSdf157793 		} else					\
392*d3cf9c7dSdf157793 			mutex_exit(asy->asy_soft_lock);\
393*d3cf9c7dSdf157793 	}						\
394*d3cf9c7dSdf157793 }
395*d3cf9c7dSdf157793 
396*d3cf9c7dSdf157793 #ifdef __cplusplus
397*d3cf9c7dSdf157793 }
398*d3cf9c7dSdf157793 #endif
399*d3cf9c7dSdf157793 
400*d3cf9c7dSdf157793 #endif	/* _SYS_SUDEV_H */
401