1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ 23*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ 24*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate /* 27*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 28*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 29*7c478bd9Sstevel@tonic-gate */ 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #ifndef _SYS_ASY_H 32*7c478bd9Sstevel@tonic-gate #define _SYS_ASY_H 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 37*7c478bd9Sstevel@tonic-gate extern "C" { 38*7c478bd9Sstevel@tonic-gate #endif 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #include <sys/tty.h> 41*7c478bd9Sstevel@tonic-gate #include <sys/ksynch.h> 42*7c478bd9Sstevel@tonic-gate #include <sys/dditypes.h> 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate #define COM1_IOADDR 0x3f8 45*7c478bd9Sstevel@tonic-gate #define COM2_IOADDR 0x2f8 46*7c478bd9Sstevel@tonic-gate #define COM3_IOADDR 0x3e8 47*7c478bd9Sstevel@tonic-gate #define COM4_IOADDR 0x2e8 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate /* 50*7c478bd9Sstevel@tonic-gate * Definitions for INS8250 / 16550 chips 51*7c478bd9Sstevel@tonic-gate */ 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate /* defined as offsets from the data register */ 54*7c478bd9Sstevel@tonic-gate #define DAT 0 /* receive/transmit data */ 55*7c478bd9Sstevel@tonic-gate #define ICR 1 /* interrupt control register */ 56*7c478bd9Sstevel@tonic-gate #define ISR 2 /* interrupt status register */ 57*7c478bd9Sstevel@tonic-gate #define LCR 3 /* line control register */ 58*7c478bd9Sstevel@tonic-gate #define MCR 4 /* modem control register */ 59*7c478bd9Sstevel@tonic-gate #define LSR 5 /* line status register */ 60*7c478bd9Sstevel@tonic-gate #define MSR 6 /* modem status register */ 61*7c478bd9Sstevel@tonic-gate #define SCR 7 /* scratch register */ 62*7c478bd9Sstevel@tonic-gate #define DLL 0 /* divisor latch (lsb) */ 63*7c478bd9Sstevel@tonic-gate #define DLH 1 /* divisor latch (msb) */ 64*7c478bd9Sstevel@tonic-gate #define FIFOR ISR /* FIFO register for 16550 */ 65*7c478bd9Sstevel@tonic-gate #define EFR ISR /* Enhanced feature register for 16650 */ 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate /* 68*7c478bd9Sstevel@tonic-gate * INTEL 8210-A/B & 16450/16550 Registers Structure. 69*7c478bd9Sstevel@tonic-gate */ 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate /* Line Control Register */ 72*7c478bd9Sstevel@tonic-gate #define WLS0 0x01 /* word length select bit 0 */ 73*7c478bd9Sstevel@tonic-gate #define WLS1 0x02 /* word length select bit 2 */ 74*7c478bd9Sstevel@tonic-gate #define STB 0x04 /* number of stop bits */ 75*7c478bd9Sstevel@tonic-gate #define PEN 0x08 /* parity enable */ 76*7c478bd9Sstevel@tonic-gate #define EPS 0x10 /* even parity select */ 77*7c478bd9Sstevel@tonic-gate #define SETBREAK 0x40 /* break key */ 78*7c478bd9Sstevel@tonic-gate #define DLAB 0x80 /* divisor latch access bit */ 79*7c478bd9Sstevel@tonic-gate #define RXLEN 0x03 /* # of data bits per received/xmitted char */ 80*7c478bd9Sstevel@tonic-gate #define STOP1 0x00 81*7c478bd9Sstevel@tonic-gate #define STOP2 0x04 82*7c478bd9Sstevel@tonic-gate #define PAREN 0x08 83*7c478bd9Sstevel@tonic-gate #define PAREVN 0x10 84*7c478bd9Sstevel@tonic-gate #define PARMARK 0x20 85*7c478bd9Sstevel@tonic-gate #define SNDBRK 0x40 86*7c478bd9Sstevel@tonic-gate #define EFRACCESS 0xBF /* magic value for 16650 EFR access */ 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate #define BITS5 0x00 /* 5 bits per char */ 89*7c478bd9Sstevel@tonic-gate #define BITS6 0x01 /* 6 bits per char */ 90*7c478bd9Sstevel@tonic-gate #define BITS7 0x02 /* 7 bits per char */ 91*7c478bd9Sstevel@tonic-gate #define BITS8 0x03 /* 8 bits per char */ 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate /* Line Status Register */ 94*7c478bd9Sstevel@tonic-gate #define RCA 0x01 /* data ready */ 95*7c478bd9Sstevel@tonic-gate #define OVRRUN 0x02 /* overrun error */ 96*7c478bd9Sstevel@tonic-gate #define PARERR 0x04 /* parity error */ 97*7c478bd9Sstevel@tonic-gate #define FRMERR 0x08 /* framing error */ 98*7c478bd9Sstevel@tonic-gate #define BRKDET 0x10 /* a break has arrived */ 99*7c478bd9Sstevel@tonic-gate #define XHRE 0x20 /* tx hold reg is now empty */ 100*7c478bd9Sstevel@tonic-gate #define XSRE 0x40 /* tx shift reg is now empty */ 101*7c478bd9Sstevel@tonic-gate #define RFBE 0x80 /* rx FIFO Buffer error */ 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate /* Interrupt Id Regisger */ 104*7c478bd9Sstevel@tonic-gate #define MSTATUS 0x00 /* modem status changed */ 105*7c478bd9Sstevel@tonic-gate #define NOINTERRUPT 0x01 /* no interrupt pending */ 106*7c478bd9Sstevel@tonic-gate #define TxRDY 0x02 /* Transmitter Holding Register Empty */ 107*7c478bd9Sstevel@tonic-gate #define RxRDY 0x04 /* Receiver Data Available */ 108*7c478bd9Sstevel@tonic-gate #define FFTMOUT 0x0c /* FIFO timeout - 16550AF */ 109*7c478bd9Sstevel@tonic-gate #define RSTATUS 0x06 /* Receiver Line Status */ 110*7c478bd9Sstevel@tonic-gate 111*7c478bd9Sstevel@tonic-gate /* Interrupt Enable Register */ 112*7c478bd9Sstevel@tonic-gate #define RIEN 0x01 /* Received Data Ready */ 113*7c478bd9Sstevel@tonic-gate #define TIEN 0x02 /* Tx Hold Register Empty */ 114*7c478bd9Sstevel@tonic-gate #define SIEN 0x04 /* Receiver Line Status */ 115*7c478bd9Sstevel@tonic-gate #define MIEN 0x08 /* Modem Status */ 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate /* Modem Control Register */ 118*7c478bd9Sstevel@tonic-gate #define DTR 0x01 /* Data Terminal Ready */ 119*7c478bd9Sstevel@tonic-gate #define RTS 0x02 /* Request To Send */ 120*7c478bd9Sstevel@tonic-gate #define OUT1 0x04 /* Aux output - not used */ 121*7c478bd9Sstevel@tonic-gate #define OUT2 0x08 /* turns intr to 386 on/off */ 122*7c478bd9Sstevel@tonic-gate #define ASY_LOOP 0x10 /* loopback for diagnostics */ 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate /* Modem Status Register */ 125*7c478bd9Sstevel@tonic-gate #define DCTS 0x01 /* Delta Clear To Send */ 126*7c478bd9Sstevel@tonic-gate #define DDSR 0x02 /* Delta Data Set Ready */ 127*7c478bd9Sstevel@tonic-gate #define DRI 0x04 /* Trail Edge Ring Indicator */ 128*7c478bd9Sstevel@tonic-gate #define DDCD 0x08 /* Delta Data Carrier Detect */ 129*7c478bd9Sstevel@tonic-gate #define CTS 0x10 /* Clear To Send */ 130*7c478bd9Sstevel@tonic-gate #define DSR 0x20 /* Data Set Ready */ 131*7c478bd9Sstevel@tonic-gate #define RI 0x40 /* Ring Indicator */ 132*7c478bd9Sstevel@tonic-gate #define DCD 0x80 /* Data Carrier Detect */ 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate #define DELTAS(x) ((x)&(DCTS|DDSR|DRI|DDCD)) 135*7c478bd9Sstevel@tonic-gate #define STATES(x) ((x)&(CTS|DSR|RI|DCD)) 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate /* flags for FCR (FIFO Control register) */ 138*7c478bd9Sstevel@tonic-gate #define FIFO_OFF 0x00 /* fifo disabled */ 139*7c478bd9Sstevel@tonic-gate #define FIFO_ON 0x01 /* fifo enabled */ 140*7c478bd9Sstevel@tonic-gate #define FIFORXFLSH 0x02 /* flush receiver FIFO */ 141*7c478bd9Sstevel@tonic-gate #define FIFOTXFLSH 0x04 /* flush transmitter FIFO */ 142*7c478bd9Sstevel@tonic-gate #define FIFODMA 0x08 /* DMA mode 1 */ 143*7c478bd9Sstevel@tonic-gate #define FIFOEXTRA1 0x10 /* Longer fifos on some 16650's */ 144*7c478bd9Sstevel@tonic-gate #define FIFOEXTRA2 0x20 /* Longer fifos on some 16650's and 16750 */ 145*7c478bd9Sstevel@tonic-gate #define FIFO_TRIG_1 0x00 /* 1 byte trigger level */ 146*7c478bd9Sstevel@tonic-gate #define FIFO_TRIG_4 0x40 /* 4 byte trigger level */ 147*7c478bd9Sstevel@tonic-gate #define FIFO_TRIG_8 0x80 /* 8 byte trigger level */ 148*7c478bd9Sstevel@tonic-gate #define FIFO_TRIG_14 0xC0 /* 14 byte trigger level */ 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate /* Serial in/out requests */ 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate #define OVERRUN 040000 153*7c478bd9Sstevel@tonic-gate #define FRERROR 020000 154*7c478bd9Sstevel@tonic-gate #define PERROR 010000 155*7c478bd9Sstevel@tonic-gate #define S_ERRORS (PERROR|OVERRUN|FRERROR) 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate /* EFR - Enhanced feature register for 16650 */ 158*7c478bd9Sstevel@tonic-gate #define ENHENABLE 0x10 159*7c478bd9Sstevel@tonic-gate 160*7c478bd9Sstevel@tonic-gate /* SCR - scratch register */ 161*7c478bd9Sstevel@tonic-gate #define SCRTEST 0x5a /* arbritrary value for testing SCR register */ 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate /* 164*7c478bd9Sstevel@tonic-gate * Ring buffer and async line management definitions. 165*7c478bd9Sstevel@tonic-gate */ 166*7c478bd9Sstevel@tonic-gate #define RINGBITS 10 /* # of bits in ring ptrs */ 167*7c478bd9Sstevel@tonic-gate #define RINGSIZE (1<<RINGBITS) /* size of ring */ 168*7c478bd9Sstevel@tonic-gate #define RINGMASK (RINGSIZE-1) 169*7c478bd9Sstevel@tonic-gate #define RINGFRAC 8 /* fraction of ring to force flush */ 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate #define RING_INIT(ap) ((ap)->async_rput = (ap)->async_rget = 0) 172*7c478bd9Sstevel@tonic-gate #define RING_CNT(ap) (((ap)->async_rput >= (ap)->async_rget) ? \ 173*7c478bd9Sstevel@tonic-gate ((ap)->async_rput - (ap)->async_rget):\ 174*7c478bd9Sstevel@tonic-gate ((0x10000 - (ap)->async_rget) + (ap)->async_rput)) 175*7c478bd9Sstevel@tonic-gate #define RING_FRAC(ap) ((int)RING_CNT(ap) >= (int)(RINGSIZE/RINGFRAC)) 176*7c478bd9Sstevel@tonic-gate #define RING_POK(ap, n) ((int)RING_CNT(ap) < (int)(RINGSIZE-(n))) 177*7c478bd9Sstevel@tonic-gate #define RING_PUT(ap, c) \ 178*7c478bd9Sstevel@tonic-gate ((ap)->async_ring[(ap)->async_rput++ & RINGMASK] = (uchar_t)(c)) 179*7c478bd9Sstevel@tonic-gate #define RING_UNPUT(ap) ((ap)->async_rput--) 180*7c478bd9Sstevel@tonic-gate #define RING_GOK(ap, n) ((int)RING_CNT(ap) >= (int)(n)) 181*7c478bd9Sstevel@tonic-gate #define RING_GET(ap) ((ap)->async_ring[(ap)->async_rget++ & RINGMASK]) 182*7c478bd9Sstevel@tonic-gate #define RING_EAT(ap, n) ((ap)->async_rget += (n)) 183*7c478bd9Sstevel@tonic-gate #define RING_MARK(ap, c, s) \ 184*7c478bd9Sstevel@tonic-gate ((ap)->async_ring[(ap)->async_rput++ & RINGMASK] = ((uchar_t)(c)|(s))) 185*7c478bd9Sstevel@tonic-gate #define RING_UNMARK(ap) \ 186*7c478bd9Sstevel@tonic-gate ((ap)->async_ring[((ap)->async_rget) & RINGMASK] &= ~S_ERRORS) 187*7c478bd9Sstevel@tonic-gate #define RING_ERR(ap, c) \ 188*7c478bd9Sstevel@tonic-gate ((ap)->async_ring[((ap)->async_rget) & RINGMASK] & (c)) 189*7c478bd9Sstevel@tonic-gate 190*7c478bd9Sstevel@tonic-gate /* 191*7c478bd9Sstevel@tonic-gate * Asy tracing macros. These are a bit similar to some macros in sys/vtrace.h . 192*7c478bd9Sstevel@tonic-gate * 193*7c478bd9Sstevel@tonic-gate * XXX - Needs review: would it be better to use the macros in sys/vtrace.h ? 194*7c478bd9Sstevel@tonic-gate */ 195*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 196*7c478bd9Sstevel@tonic-gate #define DEBUGWARN0(fac, format) \ 197*7c478bd9Sstevel@tonic-gate if (debug & (fac)) \ 198*7c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, format) 199*7c478bd9Sstevel@tonic-gate #define DEBUGNOTE0(fac, format) \ 200*7c478bd9Sstevel@tonic-gate if (debug & (fac)) \ 201*7c478bd9Sstevel@tonic-gate cmn_err(CE_NOTE, format) 202*7c478bd9Sstevel@tonic-gate #define DEBUGNOTE1(fac, format, arg1) \ 203*7c478bd9Sstevel@tonic-gate if (debug & (fac)) \ 204*7c478bd9Sstevel@tonic-gate cmn_err(CE_NOTE, format, arg1) 205*7c478bd9Sstevel@tonic-gate #define DEBUGNOTE2(fac, format, arg1, arg2) \ 206*7c478bd9Sstevel@tonic-gate if (debug & (fac)) \ 207*7c478bd9Sstevel@tonic-gate cmn_err(CE_NOTE, format, arg1, arg2) 208*7c478bd9Sstevel@tonic-gate #define DEBUGNOTE3(fac, format, arg1, arg2, arg3) \ 209*7c478bd9Sstevel@tonic-gate if (debug & (fac)) \ 210*7c478bd9Sstevel@tonic-gate cmn_err(CE_NOTE, format, arg1, arg2, arg3) 211*7c478bd9Sstevel@tonic-gate #define DEBUGCONT0(fac, format) \ 212*7c478bd9Sstevel@tonic-gate if (debug & (fac)) \ 213*7c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, format) 214*7c478bd9Sstevel@tonic-gate #define DEBUGCONT1(fac, format, arg1) \ 215*7c478bd9Sstevel@tonic-gate if (debug & (fac)) \ 216*7c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, format, arg1) 217*7c478bd9Sstevel@tonic-gate #define DEBUGCONT2(fac, format, arg1, arg2) \ 218*7c478bd9Sstevel@tonic-gate if (debug & (fac)) \ 219*7c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, format, arg1, arg2) 220*7c478bd9Sstevel@tonic-gate #define DEBUGCONT3(fac, format, arg1, arg2, arg3) \ 221*7c478bd9Sstevel@tonic-gate if (debug & (fac)) \ 222*7c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, format, arg1, arg2, arg3) 223*7c478bd9Sstevel@tonic-gate #define DEBUGCONT4(fac, format, arg1, arg2, arg3, arg4) \ 224*7c478bd9Sstevel@tonic-gate if (debug & (fac)) \ 225*7c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, format, arg1, arg2, arg3, arg4) 226*7c478bd9Sstevel@tonic-gate #define DEBUGCONT10(fac, format, \ 227*7c478bd9Sstevel@tonic-gate arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) \ 228*7c478bd9Sstevel@tonic-gate if (debug & (fac)) \ 229*7c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, format, \ 230*7c478bd9Sstevel@tonic-gate arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) 231*7c478bd9Sstevel@tonic-gate #else 232*7c478bd9Sstevel@tonic-gate #define DEBUGWARN0(fac, format) 233*7c478bd9Sstevel@tonic-gate #define DEBUGNOTE0(fac, format) 234*7c478bd9Sstevel@tonic-gate #define DEBUGNOTE1(fac, format, arg1) 235*7c478bd9Sstevel@tonic-gate #define DEBUGNOTE2(fac, format, arg1, arg2) 236*7c478bd9Sstevel@tonic-gate #define DEBUGNOTE3(fac, format, arg1, arg2, arg3) 237*7c478bd9Sstevel@tonic-gate #define DEBUGCONT0(fac, format) 238*7c478bd9Sstevel@tonic-gate #define DEBUGCONT1(fac, format, arg1) 239*7c478bd9Sstevel@tonic-gate #define DEBUGCONT2(fac, format, arg1, arg2) 240*7c478bd9Sstevel@tonic-gate #define DEBUGCONT3(fac, format, arg1, arg2, arg3) 241*7c478bd9Sstevel@tonic-gate #define DEBUGCONT4(fac, format, arg1, arg2, arg3, arg4) 242*7c478bd9Sstevel@tonic-gate #define DEBUGCONT10(fac, format, \ 243*7c478bd9Sstevel@tonic-gate arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) 244*7c478bd9Sstevel@tonic-gate #endif 245*7c478bd9Sstevel@tonic-gate 246*7c478bd9Sstevel@tonic-gate /* 247*7c478bd9Sstevel@tonic-gate * Hardware channel common data. One structure per port. 248*7c478bd9Sstevel@tonic-gate * Each of the fields in this structure is required to be protected by a 249*7c478bd9Sstevel@tonic-gate * mutex lock at the highest priority at which it can be altered. 250*7c478bd9Sstevel@tonic-gate * The asy_flags, and asy_next fields can be altered by interrupt 251*7c478bd9Sstevel@tonic-gate * handling code that must be protected by the mutex whose handle is 252*7c478bd9Sstevel@tonic-gate * stored in asy_excl_hi. All others can be protected by the asy_excl 253*7c478bd9Sstevel@tonic-gate * mutex, which is lower priority and adaptive. 254*7c478bd9Sstevel@tonic-gate */ 255*7c478bd9Sstevel@tonic-gate 256*7c478bd9Sstevel@tonic-gate struct asycom { 257*7c478bd9Sstevel@tonic-gate int asy_flags; /* random flags */ 258*7c478bd9Sstevel@tonic-gate /* protected by asy_excl_hi lock */ 259*7c478bd9Sstevel@tonic-gate uint_t asy_hwtype; /* HW type: ASY16550A, etc. */ 260*7c478bd9Sstevel@tonic-gate uint_t asy_use_fifo; /* HW FIFO use it or not ?? */ 261*7c478bd9Sstevel@tonic-gate uint_t asy_fifo_buf; /* With FIFO = 16, otherwise = 1 */ 262*7c478bd9Sstevel@tonic-gate uint_t asy_flags2; /* flags which don't change, no lock */ 263*7c478bd9Sstevel@tonic-gate uint8_t *asy_ioaddr; /* i/o address of ASY port */ 264*7c478bd9Sstevel@tonic-gate struct asyncline *asy_priv; /* protocol private data -- asyncline */ 265*7c478bd9Sstevel@tonic-gate dev_info_t *asy_dip; /* dev_info */ 266*7c478bd9Sstevel@tonic-gate int asy_unit; /* which port */ 267*7c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t asy_iblock; 268*7c478bd9Sstevel@tonic-gate kmutex_t asy_excl; /* asy adaptive mutex */ 269*7c478bd9Sstevel@tonic-gate kmutex_t asy_excl_hi; /* asy spinlock mutex */ 270*7c478bd9Sstevel@tonic-gate uchar_t asy_msr; /* saved modem status */ 271*7c478bd9Sstevel@tonic-gate uchar_t asy_mcr; /* soft carrier bits */ 272*7c478bd9Sstevel@tonic-gate uchar_t asy_lcr; /* console lcr bits */ 273*7c478bd9Sstevel@tonic-gate uchar_t asy_bidx; /* console baud rate index */ 274*7c478bd9Sstevel@tonic-gate tcflag_t asy_cflag; /* console mode bits */ 275*7c478bd9Sstevel@tonic-gate struct cons_polledio polledio; /* polled I/O functions */ 276*7c478bd9Sstevel@tonic-gate ddi_acc_handle_t asy_iohandle; /* Data access handle */ 277*7c478bd9Sstevel@tonic-gate tcflag_t asy_ocflag; /* old console mode bits */ 278*7c478bd9Sstevel@tonic-gate uchar_t asy_com_port; /* COM port number, or zero */ 279*7c478bd9Sstevel@tonic-gate uchar_t asy_fifor; /* FIFOR register setting */ 280*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 281*7c478bd9Sstevel@tonic-gate int asy_msint_cnt; /* number of times in async_msint */ 282*7c478bd9Sstevel@tonic-gate #endif 283*7c478bd9Sstevel@tonic-gate }; 284*7c478bd9Sstevel@tonic-gate 285*7c478bd9Sstevel@tonic-gate /* 286*7c478bd9Sstevel@tonic-gate * Asychronous protocol private data structure for ASY. 287*7c478bd9Sstevel@tonic-gate * Each of the fields in the structure is required to be protected by 288*7c478bd9Sstevel@tonic-gate * the lower priority lock except the fields that are set only at 289*7c478bd9Sstevel@tonic-gate * base level but cleared (with out lock) at interrupt level. 290*7c478bd9Sstevel@tonic-gate */ 291*7c478bd9Sstevel@tonic-gate 292*7c478bd9Sstevel@tonic-gate struct asyncline { 293*7c478bd9Sstevel@tonic-gate int async_flags; /* random flags */ 294*7c478bd9Sstevel@tonic-gate kcondvar_t async_flags_cv; /* condition variable for flags */ 295*7c478bd9Sstevel@tonic-gate dev_t async_dev; /* device major/minor numbers */ 296*7c478bd9Sstevel@tonic-gate mblk_t *async_xmitblk; /* transmit: active msg block */ 297*7c478bd9Sstevel@tonic-gate struct asycom *async_common; /* device common data */ 298*7c478bd9Sstevel@tonic-gate tty_common_t async_ttycommon; /* tty driver common data */ 299*7c478bd9Sstevel@tonic-gate bufcall_id_t async_wbufcid; /* id for pending write-side bufcall */ 300*7c478bd9Sstevel@tonic-gate timeout_id_t async_polltid; /* softint poll timeout id */ 301*7c478bd9Sstevel@tonic-gate timeout_id_t async_dtrtid; /* delaying DTR turn on */ 302*7c478bd9Sstevel@tonic-gate timeout_id_t async_utbrktid; /* hold minimum untimed break time id */ 303*7c478bd9Sstevel@tonic-gate 304*7c478bd9Sstevel@tonic-gate /* 305*7c478bd9Sstevel@tonic-gate * The following fields are protected by the asy_excl_hi lock. 306*7c478bd9Sstevel@tonic-gate * Some, such as async_flowc, are set only at the base level and 307*7c478bd9Sstevel@tonic-gate * cleared (without the lock) only by the interrupt level. 308*7c478bd9Sstevel@tonic-gate */ 309*7c478bd9Sstevel@tonic-gate uchar_t *async_optr; /* output pointer */ 310*7c478bd9Sstevel@tonic-gate int async_ocnt; /* output count */ 311*7c478bd9Sstevel@tonic-gate ushort_t async_rput; /* producing pointer for input */ 312*7c478bd9Sstevel@tonic-gate ushort_t async_rget; /* consuming pointer for input */ 313*7c478bd9Sstevel@tonic-gate 314*7c478bd9Sstevel@tonic-gate /* 315*7c478bd9Sstevel@tonic-gate * Each character stuffed into the ring has two bytes associated 316*7c478bd9Sstevel@tonic-gate * with it. The first byte is used to indicate special conditions 317*7c478bd9Sstevel@tonic-gate * and the second byte is the actual data. The ring buffer 318*7c478bd9Sstevel@tonic-gate * needs to be defined as ushort_t to accomodate this. 319*7c478bd9Sstevel@tonic-gate */ 320*7c478bd9Sstevel@tonic-gate ushort_t async_ring[RINGSIZE]; 321*7c478bd9Sstevel@tonic-gate 322*7c478bd9Sstevel@tonic-gate short async_break; /* break count */ 323*7c478bd9Sstevel@tonic-gate int async_inflow_source; /* input flow control type */ 324*7c478bd9Sstevel@tonic-gate 325*7c478bd9Sstevel@tonic-gate union { 326*7c478bd9Sstevel@tonic-gate struct { 327*7c478bd9Sstevel@tonic-gate uchar_t _hw; /* overrun (hw) */ 328*7c478bd9Sstevel@tonic-gate uchar_t _sw; /* overrun (sw) */ 329*7c478bd9Sstevel@tonic-gate } _a; 330*7c478bd9Sstevel@tonic-gate ushort_t uover_overrun; 331*7c478bd9Sstevel@tonic-gate } async_uover; 332*7c478bd9Sstevel@tonic-gate #define async_overrun async_uover._a.uover_overrun 333*7c478bd9Sstevel@tonic-gate #define async_hw_overrun async_uover._a._hw 334*7c478bd9Sstevel@tonic-gate #define async_sw_overrun async_uover._a._sw 335*7c478bd9Sstevel@tonic-gate short async_ext; /* modem status change count */ 336*7c478bd9Sstevel@tonic-gate short async_work; /* work to do flag */ 337*7c478bd9Sstevel@tonic-gate timeout_id_t async_timer; /* close drain progress timer */ 338*7c478bd9Sstevel@tonic-gate }; 339*7c478bd9Sstevel@tonic-gate 340*7c478bd9Sstevel@tonic-gate /* definitions for async_flags field */ 341*7c478bd9Sstevel@tonic-gate #define ASYNC_EXCL_OPEN 0x10000000 /* exclusive open */ 342*7c478bd9Sstevel@tonic-gate #define ASYNC_WOPEN 0x00000001 /* waiting for open to complete */ 343*7c478bd9Sstevel@tonic-gate #define ASYNC_ISOPEN 0x00000002 /* open is complete */ 344*7c478bd9Sstevel@tonic-gate #define ASYNC_OUT 0x00000004 /* line being used for dialout */ 345*7c478bd9Sstevel@tonic-gate #define ASYNC_CARR_ON 0x00000008 /* carrier on last time we looked */ 346*7c478bd9Sstevel@tonic-gate #define ASYNC_STOPPED 0x00000010 /* output is stopped */ 347*7c478bd9Sstevel@tonic-gate #define ASYNC_DELAY 0x00000020 /* waiting for delay to finish */ 348*7c478bd9Sstevel@tonic-gate #define ASYNC_BREAK 0x00000040 /* waiting for break to finish */ 349*7c478bd9Sstevel@tonic-gate #define ASYNC_BUSY 0x00000080 /* waiting for transmission to finish */ 350*7c478bd9Sstevel@tonic-gate #define ASYNC_DRAINING 0x00000100 /* waiting for output to drain */ 351*7c478bd9Sstevel@tonic-gate #define ASYNC_SERVICEIMM 0x00000200 /* queue soft interrupt as soon as */ 352*7c478bd9Sstevel@tonic-gate #define ASYNC_HW_IN_FLOW 0x00000400 /* input flow control in effect */ 353*7c478bd9Sstevel@tonic-gate #define ASYNC_HW_OUT_FLW 0x00000800 /* output flow control in effect */ 354*7c478bd9Sstevel@tonic-gate #define ASYNC_PROGRESS 0x00001000 /* made progress on output effort */ 355*7c478bd9Sstevel@tonic-gate #define ASYNC_CLOSING 0x00002000 /* processing close on stream */ 356*7c478bd9Sstevel@tonic-gate #define ASYNC_OUT_SUSPEND 0x00004000 /* waiting for TIOCSBRK to finish */ 357*7c478bd9Sstevel@tonic-gate #define ASYNC_HOLD_UTBRK 0x00008000 /* waiting for untimed break hold */ 358*7c478bd9Sstevel@tonic-gate /* the minimum time */ 359*7c478bd9Sstevel@tonic-gate #define ASYNC_DTR_DELAY 0x00010000 /* delaying DTR turn on */ 360*7c478bd9Sstevel@tonic-gate #define ASYNC_SW_IN_FLOW 0x00020000 /* sw input flow control in effect */ 361*7c478bd9Sstevel@tonic-gate #define ASYNC_SW_OUT_FLW 0x00040000 /* sw output flow control in effect */ 362*7c478bd9Sstevel@tonic-gate #define ASYNC_SW_IN_NEEDED 0x00080000 /* sw input flow control char is */ 363*7c478bd9Sstevel@tonic-gate /* needed to be sent */ 364*7c478bd9Sstevel@tonic-gate #define ASYNC_OUT_FLW_RESUME 0x00100000 /* output need to be resumed */ 365*7c478bd9Sstevel@tonic-gate /* because of transition of flow */ 366*7c478bd9Sstevel@tonic-gate /* control from stop to start */ 367*7c478bd9Sstevel@tonic-gate 368*7c478bd9Sstevel@tonic-gate /* asy_hwtype definitions */ 369*7c478bd9Sstevel@tonic-gate #define ASY8250A 0x2 /* 8250A or 16450 */ 370*7c478bd9Sstevel@tonic-gate #define ASY16550 0x3 /* broken FIFO which must not be used */ 371*7c478bd9Sstevel@tonic-gate #define ASY16550A 0x4 /* usable FIFO */ 372*7c478bd9Sstevel@tonic-gate #define ASY16650 0x5 373*7c478bd9Sstevel@tonic-gate #define ASY16750 0x6 374*7c478bd9Sstevel@tonic-gate 375*7c478bd9Sstevel@tonic-gate /* definitions for asy_flags field */ 376*7c478bd9Sstevel@tonic-gate #define ASY_NEEDSOFT 0x00000001 377*7c478bd9Sstevel@tonic-gate #define ASY_DOINGSOFT 0x00000002 378*7c478bd9Sstevel@tonic-gate #define ASY_PPS 0x00000004 379*7c478bd9Sstevel@tonic-gate #define ASY_PPS_EDGE 0x00000008 380*7c478bd9Sstevel@tonic-gate #define ASY_DOINGSOFT_RETRY 0x00000010 381*7c478bd9Sstevel@tonic-gate #define ASY_RTS_DTR_OFF 0x00000020 382*7c478bd9Sstevel@tonic-gate #define ASY_IGNORE_CD 0x00000040 383*7c478bd9Sstevel@tonic-gate #define ASY_CONSOLE 0x00000080 384*7c478bd9Sstevel@tonic-gate 385*7c478bd9Sstevel@tonic-gate /* definitions for asy_flags2 field */ 386*7c478bd9Sstevel@tonic-gate #define ASY2_NO_LOOPBACK 0x00000001 /* Device doesn't support loopback */ 387*7c478bd9Sstevel@tonic-gate 388*7c478bd9Sstevel@tonic-gate /* definitions for async_inflow_source field in struct asyncline */ 389*7c478bd9Sstevel@tonic-gate #define IN_FLOW_NULL 0x00000000 390*7c478bd9Sstevel@tonic-gate #define IN_FLOW_RINGBUFF 0x00000001 391*7c478bd9Sstevel@tonic-gate #define IN_FLOW_STREAMS 0x00000002 392*7c478bd9Sstevel@tonic-gate #define IN_FLOW_USER 0x00000004 393*7c478bd9Sstevel@tonic-gate 394*7c478bd9Sstevel@tonic-gate /* 395*7c478bd9Sstevel@tonic-gate * OUTLINE defines the high-order flag bit in the minor device number that 396*7c478bd9Sstevel@tonic-gate * controls use of a tty line for dialin and dialout simultaneously. 397*7c478bd9Sstevel@tonic-gate */ 398*7c478bd9Sstevel@tonic-gate #ifdef _LP64 399*7c478bd9Sstevel@tonic-gate #define OUTLINE (1 << (NBITSMINOR32 - 1)) 400*7c478bd9Sstevel@tonic-gate #else 401*7c478bd9Sstevel@tonic-gate #define OUTLINE (1 << (NBITSMINOR - 1)) 402*7c478bd9Sstevel@tonic-gate #endif 403*7c478bd9Sstevel@tonic-gate #define UNIT(x) (getminor(x) & ~OUTLINE) 404*7c478bd9Sstevel@tonic-gate 405*7c478bd9Sstevel@tonic-gate /* 406*7c478bd9Sstevel@tonic-gate * ASYSETSOFT macro to pend a soft interrupt if one isn't already pending. 407*7c478bd9Sstevel@tonic-gate */ 408*7c478bd9Sstevel@tonic-gate 409*7c478bd9Sstevel@tonic-gate extern kmutex_t asy_soft_lock; /* ptr to lock for asysoftpend */ 410*7c478bd9Sstevel@tonic-gate extern int asysoftpend; /* secondary interrupt pending */ 411*7c478bd9Sstevel@tonic-gate 412*7c478bd9Sstevel@tonic-gate #define ASYSETSOFT(asy) { \ 413*7c478bd9Sstevel@tonic-gate mutex_enter(&asy_soft_lock); \ 414*7c478bd9Sstevel@tonic-gate asy->asy_flags |= ASY_NEEDSOFT; \ 415*7c478bd9Sstevel@tonic-gate if (!asysoftpend) { \ 416*7c478bd9Sstevel@tonic-gate asysoftpend = 1; \ 417*7c478bd9Sstevel@tonic-gate mutex_exit(&asy_soft_lock); \ 418*7c478bd9Sstevel@tonic-gate ddi_trigger_softintr(asy_softintr_id); \ 419*7c478bd9Sstevel@tonic-gate } \ 420*7c478bd9Sstevel@tonic-gate else \ 421*7c478bd9Sstevel@tonic-gate mutex_exit(&asy_soft_lock); \ 422*7c478bd9Sstevel@tonic-gate } 423*7c478bd9Sstevel@tonic-gate 424*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 425*7c478bd9Sstevel@tonic-gate } 426*7c478bd9Sstevel@tonic-gate #endif 427*7c478bd9Sstevel@tonic-gate 428*7c478bd9Sstevel@tonic-gate #endif /* _SYS_ASY_H */ 429