10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 53359Smyers * Common Development and Distribution License (the "License"). 63359Smyers * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ 220Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ 230Sstevel@tonic-gate /* All Rights Reserved */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate /* 26*12401SZachary.Kissel@Sun.COM * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. 270Sstevel@tonic-gate */ 280Sstevel@tonic-gate 290Sstevel@tonic-gate #ifndef _SYS_ASY_H 300Sstevel@tonic-gate #define _SYS_ASY_H 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate #include <sys/tty.h> 370Sstevel@tonic-gate #include <sys/ksynch.h> 380Sstevel@tonic-gate #include <sys/dditypes.h> 390Sstevel@tonic-gate 403359Smyers /* 413359Smyers * internal bus type naming 423359Smyers */ 433359Smyers #define ASY_BUS_PCI (0) 443359Smyers #define ASY_BUS_ISA (1) 453359Smyers #define ASY_BUS_UNKNOWN (-1) 463359Smyers 473359Smyers #define ASY_MINOR_LEN (40) 483359Smyers 490Sstevel@tonic-gate #define COM1_IOADDR 0x3f8 500Sstevel@tonic-gate #define COM2_IOADDR 0x2f8 510Sstevel@tonic-gate #define COM3_IOADDR 0x3e8 520Sstevel@tonic-gate #define COM4_IOADDR 0x2e8 530Sstevel@tonic-gate 540Sstevel@tonic-gate /* 550Sstevel@tonic-gate * Definitions for INS8250 / 16550 chips 560Sstevel@tonic-gate */ 570Sstevel@tonic-gate 580Sstevel@tonic-gate /* defined as offsets from the data register */ 590Sstevel@tonic-gate #define DAT 0 /* receive/transmit data */ 600Sstevel@tonic-gate #define ICR 1 /* interrupt control register */ 610Sstevel@tonic-gate #define ISR 2 /* interrupt status register */ 620Sstevel@tonic-gate #define LCR 3 /* line control register */ 630Sstevel@tonic-gate #define MCR 4 /* modem control register */ 640Sstevel@tonic-gate #define LSR 5 /* line status register */ 650Sstevel@tonic-gate #define MSR 6 /* modem status register */ 660Sstevel@tonic-gate #define SCR 7 /* scratch register */ 670Sstevel@tonic-gate #define DLL 0 /* divisor latch (lsb) */ 680Sstevel@tonic-gate #define DLH 1 /* divisor latch (msb) */ 690Sstevel@tonic-gate #define FIFOR ISR /* FIFO register for 16550 */ 700Sstevel@tonic-gate #define EFR ISR /* Enhanced feature register for 16650 */ 710Sstevel@tonic-gate 720Sstevel@tonic-gate /* 730Sstevel@tonic-gate * INTEL 8210-A/B & 16450/16550 Registers Structure. 740Sstevel@tonic-gate */ 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* Line Control Register */ 770Sstevel@tonic-gate #define WLS0 0x01 /* word length select bit 0 */ 780Sstevel@tonic-gate #define WLS1 0x02 /* word length select bit 2 */ 790Sstevel@tonic-gate #define STB 0x04 /* number of stop bits */ 800Sstevel@tonic-gate #define PEN 0x08 /* parity enable */ 810Sstevel@tonic-gate #define EPS 0x10 /* even parity select */ 820Sstevel@tonic-gate #define SETBREAK 0x40 /* break key */ 830Sstevel@tonic-gate #define DLAB 0x80 /* divisor latch access bit */ 840Sstevel@tonic-gate #define RXLEN 0x03 /* # of data bits per received/xmitted char */ 850Sstevel@tonic-gate #define STOP1 0x00 860Sstevel@tonic-gate #define STOP2 0x04 870Sstevel@tonic-gate #define PAREN 0x08 880Sstevel@tonic-gate #define PAREVN 0x10 890Sstevel@tonic-gate #define PARMARK 0x20 900Sstevel@tonic-gate #define SNDBRK 0x40 910Sstevel@tonic-gate #define EFRACCESS 0xBF /* magic value for 16650 EFR access */ 920Sstevel@tonic-gate 930Sstevel@tonic-gate #define BITS5 0x00 /* 5 bits per char */ 940Sstevel@tonic-gate #define BITS6 0x01 /* 6 bits per char */ 950Sstevel@tonic-gate #define BITS7 0x02 /* 7 bits per char */ 960Sstevel@tonic-gate #define BITS8 0x03 /* 8 bits per char */ 970Sstevel@tonic-gate 980Sstevel@tonic-gate /* Line Status Register */ 990Sstevel@tonic-gate #define RCA 0x01 /* data ready */ 1000Sstevel@tonic-gate #define OVRRUN 0x02 /* overrun error */ 1010Sstevel@tonic-gate #define PARERR 0x04 /* parity error */ 1020Sstevel@tonic-gate #define FRMERR 0x08 /* framing error */ 1030Sstevel@tonic-gate #define BRKDET 0x10 /* a break has arrived */ 1040Sstevel@tonic-gate #define XHRE 0x20 /* tx hold reg is now empty */ 1050Sstevel@tonic-gate #define XSRE 0x40 /* tx shift reg is now empty */ 1060Sstevel@tonic-gate #define RFBE 0x80 /* rx FIFO Buffer error */ 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate /* Interrupt Id Regisger */ 1090Sstevel@tonic-gate #define MSTATUS 0x00 /* modem status changed */ 1100Sstevel@tonic-gate #define NOINTERRUPT 0x01 /* no interrupt pending */ 1110Sstevel@tonic-gate #define TxRDY 0x02 /* Transmitter Holding Register Empty */ 1120Sstevel@tonic-gate #define RxRDY 0x04 /* Receiver Data Available */ 1130Sstevel@tonic-gate #define FFTMOUT 0x0c /* FIFO timeout - 16550AF */ 1140Sstevel@tonic-gate #define RSTATUS 0x06 /* Receiver Line Status */ 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate /* Interrupt Enable Register */ 1170Sstevel@tonic-gate #define RIEN 0x01 /* Received Data Ready */ 1180Sstevel@tonic-gate #define TIEN 0x02 /* Tx Hold Register Empty */ 1190Sstevel@tonic-gate #define SIEN 0x04 /* Receiver Line Status */ 1200Sstevel@tonic-gate #define MIEN 0x08 /* Modem Status */ 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate /* Modem Control Register */ 1230Sstevel@tonic-gate #define DTR 0x01 /* Data Terminal Ready */ 1240Sstevel@tonic-gate #define RTS 0x02 /* Request To Send */ 1250Sstevel@tonic-gate #define OUT1 0x04 /* Aux output - not used */ 1260Sstevel@tonic-gate #define OUT2 0x08 /* turns intr to 386 on/off */ 1270Sstevel@tonic-gate #define ASY_LOOP 0x10 /* loopback for diagnostics */ 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate /* Modem Status Register */ 1300Sstevel@tonic-gate #define DCTS 0x01 /* Delta Clear To Send */ 1310Sstevel@tonic-gate #define DDSR 0x02 /* Delta Data Set Ready */ 1320Sstevel@tonic-gate #define DRI 0x04 /* Trail Edge Ring Indicator */ 1330Sstevel@tonic-gate #define DDCD 0x08 /* Delta Data Carrier Detect */ 1340Sstevel@tonic-gate #define CTS 0x10 /* Clear To Send */ 1350Sstevel@tonic-gate #define DSR 0x20 /* Data Set Ready */ 1360Sstevel@tonic-gate #define RI 0x40 /* Ring Indicator */ 1370Sstevel@tonic-gate #define DCD 0x80 /* Data Carrier Detect */ 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate #define DELTAS(x) ((x)&(DCTS|DDSR|DRI|DDCD)) 1400Sstevel@tonic-gate #define STATES(x) ((x)&(CTS|DSR|RI|DCD)) 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate /* flags for FCR (FIFO Control register) */ 1430Sstevel@tonic-gate #define FIFO_OFF 0x00 /* fifo disabled */ 1440Sstevel@tonic-gate #define FIFO_ON 0x01 /* fifo enabled */ 1450Sstevel@tonic-gate #define FIFORXFLSH 0x02 /* flush receiver FIFO */ 1460Sstevel@tonic-gate #define FIFOTXFLSH 0x04 /* flush transmitter FIFO */ 1470Sstevel@tonic-gate #define FIFODMA 0x08 /* DMA mode 1 */ 1480Sstevel@tonic-gate #define FIFOEXTRA1 0x10 /* Longer fifos on some 16650's */ 1490Sstevel@tonic-gate #define FIFOEXTRA2 0x20 /* Longer fifos on some 16650's and 16750 */ 1500Sstevel@tonic-gate #define FIFO_TRIG_1 0x00 /* 1 byte trigger level */ 1510Sstevel@tonic-gate #define FIFO_TRIG_4 0x40 /* 4 byte trigger level */ 1520Sstevel@tonic-gate #define FIFO_TRIG_8 0x80 /* 8 byte trigger level */ 1530Sstevel@tonic-gate #define FIFO_TRIG_14 0xC0 /* 14 byte trigger level */ 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate /* Serial in/out requests */ 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate #define OVERRUN 040000 1580Sstevel@tonic-gate #define FRERROR 020000 1590Sstevel@tonic-gate #define PERROR 010000 1600Sstevel@tonic-gate #define S_ERRORS (PERROR|OVERRUN|FRERROR) 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate /* EFR - Enhanced feature register for 16650 */ 1630Sstevel@tonic-gate #define ENHENABLE 0x10 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate /* SCR - scratch register */ 1660Sstevel@tonic-gate #define SCRTEST 0x5a /* arbritrary value for testing SCR register */ 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate /* 1690Sstevel@tonic-gate * Ring buffer and async line management definitions. 1700Sstevel@tonic-gate */ 171*12401SZachary.Kissel@Sun.COM #define RINGBITS 16 /* # of bits in ring ptrs */ 1720Sstevel@tonic-gate #define RINGSIZE (1<<RINGBITS) /* size of ring */ 1730Sstevel@tonic-gate #define RINGMASK (RINGSIZE-1) 174*12401SZachary.Kissel@Sun.COM #define RINGFRAC 12 /* fraction of ring to force flush */ 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate #define RING_INIT(ap) ((ap)->async_rput = (ap)->async_rget = 0) 1770Sstevel@tonic-gate #define RING_CNT(ap) (((ap)->async_rput >= (ap)->async_rget) ? \ 1780Sstevel@tonic-gate ((ap)->async_rput - (ap)->async_rget):\ 1790Sstevel@tonic-gate ((0x10000 - (ap)->async_rget) + (ap)->async_rput)) 1800Sstevel@tonic-gate #define RING_FRAC(ap) ((int)RING_CNT(ap) >= (int)(RINGSIZE/RINGFRAC)) 1810Sstevel@tonic-gate #define RING_POK(ap, n) ((int)RING_CNT(ap) < (int)(RINGSIZE-(n))) 1820Sstevel@tonic-gate #define RING_PUT(ap, c) \ 1830Sstevel@tonic-gate ((ap)->async_ring[(ap)->async_rput++ & RINGMASK] = (uchar_t)(c)) 1840Sstevel@tonic-gate #define RING_UNPUT(ap) ((ap)->async_rput--) 1850Sstevel@tonic-gate #define RING_GOK(ap, n) ((int)RING_CNT(ap) >= (int)(n)) 1860Sstevel@tonic-gate #define RING_GET(ap) ((ap)->async_ring[(ap)->async_rget++ & RINGMASK]) 1870Sstevel@tonic-gate #define RING_EAT(ap, n) ((ap)->async_rget += (n)) 1880Sstevel@tonic-gate #define RING_MARK(ap, c, s) \ 1890Sstevel@tonic-gate ((ap)->async_ring[(ap)->async_rput++ & RINGMASK] = ((uchar_t)(c)|(s))) 1900Sstevel@tonic-gate #define RING_UNMARK(ap) \ 1910Sstevel@tonic-gate ((ap)->async_ring[((ap)->async_rget) & RINGMASK] &= ~S_ERRORS) 1920Sstevel@tonic-gate #define RING_ERR(ap, c) \ 1930Sstevel@tonic-gate ((ap)->async_ring[((ap)->async_rget) & RINGMASK] & (c)) 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate /* 1960Sstevel@tonic-gate * Asy tracing macros. These are a bit similar to some macros in sys/vtrace.h . 1970Sstevel@tonic-gate * 1980Sstevel@tonic-gate * XXX - Needs review: would it be better to use the macros in sys/vtrace.h ? 1990Sstevel@tonic-gate */ 2000Sstevel@tonic-gate #ifdef DEBUG 2010Sstevel@tonic-gate #define DEBUGWARN0(fac, format) \ 2020Sstevel@tonic-gate if (debug & (fac)) \ 2030Sstevel@tonic-gate cmn_err(CE_WARN, format) 2040Sstevel@tonic-gate #define DEBUGNOTE0(fac, format) \ 2050Sstevel@tonic-gate if (debug & (fac)) \ 2060Sstevel@tonic-gate cmn_err(CE_NOTE, format) 2070Sstevel@tonic-gate #define DEBUGNOTE1(fac, format, arg1) \ 2080Sstevel@tonic-gate if (debug & (fac)) \ 2090Sstevel@tonic-gate cmn_err(CE_NOTE, format, arg1) 2100Sstevel@tonic-gate #define DEBUGNOTE2(fac, format, arg1, arg2) \ 2110Sstevel@tonic-gate if (debug & (fac)) \ 2120Sstevel@tonic-gate cmn_err(CE_NOTE, format, arg1, arg2) 2130Sstevel@tonic-gate #define DEBUGNOTE3(fac, format, arg1, arg2, arg3) \ 2140Sstevel@tonic-gate if (debug & (fac)) \ 2150Sstevel@tonic-gate cmn_err(CE_NOTE, format, arg1, arg2, arg3) 2160Sstevel@tonic-gate #define DEBUGCONT0(fac, format) \ 2170Sstevel@tonic-gate if (debug & (fac)) \ 2180Sstevel@tonic-gate cmn_err(CE_CONT, format) 2190Sstevel@tonic-gate #define DEBUGCONT1(fac, format, arg1) \ 2200Sstevel@tonic-gate if (debug & (fac)) \ 2210Sstevel@tonic-gate cmn_err(CE_CONT, format, arg1) 2220Sstevel@tonic-gate #define DEBUGCONT2(fac, format, arg1, arg2) \ 2230Sstevel@tonic-gate if (debug & (fac)) \ 2240Sstevel@tonic-gate cmn_err(CE_CONT, format, arg1, arg2) 2250Sstevel@tonic-gate #define DEBUGCONT3(fac, format, arg1, arg2, arg3) \ 2260Sstevel@tonic-gate if (debug & (fac)) \ 2270Sstevel@tonic-gate cmn_err(CE_CONT, format, arg1, arg2, arg3) 2280Sstevel@tonic-gate #define DEBUGCONT4(fac, format, arg1, arg2, arg3, arg4) \ 2290Sstevel@tonic-gate if (debug & (fac)) \ 2300Sstevel@tonic-gate cmn_err(CE_CONT, format, arg1, arg2, arg3, arg4) 2310Sstevel@tonic-gate #define DEBUGCONT10(fac, format, \ 2320Sstevel@tonic-gate arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) \ 2330Sstevel@tonic-gate if (debug & (fac)) \ 2340Sstevel@tonic-gate cmn_err(CE_CONT, format, \ 2350Sstevel@tonic-gate arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) 2360Sstevel@tonic-gate #else 2370Sstevel@tonic-gate #define DEBUGWARN0(fac, format) 2380Sstevel@tonic-gate #define DEBUGNOTE0(fac, format) 2390Sstevel@tonic-gate #define DEBUGNOTE1(fac, format, arg1) 2400Sstevel@tonic-gate #define DEBUGNOTE2(fac, format, arg1, arg2) 2410Sstevel@tonic-gate #define DEBUGNOTE3(fac, format, arg1, arg2, arg3) 2420Sstevel@tonic-gate #define DEBUGCONT0(fac, format) 2430Sstevel@tonic-gate #define DEBUGCONT1(fac, format, arg1) 2440Sstevel@tonic-gate #define DEBUGCONT2(fac, format, arg1, arg2) 2450Sstevel@tonic-gate #define DEBUGCONT3(fac, format, arg1, arg2, arg3) 2460Sstevel@tonic-gate #define DEBUGCONT4(fac, format, arg1, arg2, arg3, arg4) 2470Sstevel@tonic-gate #define DEBUGCONT10(fac, format, \ 2480Sstevel@tonic-gate arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) 2490Sstevel@tonic-gate #endif 2500Sstevel@tonic-gate 2510Sstevel@tonic-gate /* 2520Sstevel@tonic-gate * Hardware channel common data. One structure per port. 2530Sstevel@tonic-gate * Each of the fields in this structure is required to be protected by a 2540Sstevel@tonic-gate * mutex lock at the highest priority at which it can be altered. 2550Sstevel@tonic-gate * The asy_flags, and asy_next fields can be altered by interrupt 2560Sstevel@tonic-gate * handling code that must be protected by the mutex whose handle is 2570Sstevel@tonic-gate * stored in asy_excl_hi. All others can be protected by the asy_excl 2580Sstevel@tonic-gate * mutex, which is lower priority and adaptive. 2590Sstevel@tonic-gate */ 2600Sstevel@tonic-gate 2610Sstevel@tonic-gate struct asycom { 2620Sstevel@tonic-gate int asy_flags; /* random flags */ 2630Sstevel@tonic-gate /* protected by asy_excl_hi lock */ 2640Sstevel@tonic-gate uint_t asy_hwtype; /* HW type: ASY16550A, etc. */ 2650Sstevel@tonic-gate uint_t asy_use_fifo; /* HW FIFO use it or not ?? */ 2660Sstevel@tonic-gate uint_t asy_fifo_buf; /* With FIFO = 16, otherwise = 1 */ 2670Sstevel@tonic-gate uint_t asy_flags2; /* flags which don't change, no lock */ 2680Sstevel@tonic-gate uint8_t *asy_ioaddr; /* i/o address of ASY port */ 2690Sstevel@tonic-gate struct asyncline *asy_priv; /* protocol private data -- asyncline */ 2700Sstevel@tonic-gate dev_info_t *asy_dip; /* dev_info */ 2710Sstevel@tonic-gate int asy_unit; /* which port */ 2720Sstevel@tonic-gate ddi_iblock_cookie_t asy_iblock; 2730Sstevel@tonic-gate kmutex_t asy_excl; /* asy adaptive mutex */ 2740Sstevel@tonic-gate kmutex_t asy_excl_hi; /* asy spinlock mutex */ 275*12401SZachary.Kissel@Sun.COM kmutex_t asy_soft_lock; /* soft lock for guarding softpend. */ 276*12401SZachary.Kissel@Sun.COM int asysoftpend; /* Flag indicating soft int pending. */ 277*12401SZachary.Kissel@Sun.COM ddi_softintr_t asy_softintr_id; 278*12401SZachary.Kissel@Sun.COM ddi_iblock_cookie_t asy_soft_iblock; 2795295Srandyf 2805295Srandyf /* 2815295Srandyf * The asy_soft_sr mutex should only be taken by the soft interrupt 2825295Srandyf * handler and the driver DDI_SUSPEND/DDI_RESUME code. It 2835295Srandyf * shouldn't be taken by any code that may get called indirectly 2845295Srandyf * by the soft interrupt handler (e.g. as a result of a put or 2855295Srandyf * putnext call). 2865295Srandyf */ 2875295Srandyf kmutex_t asy_soft_sr; /* soft int suspend/resume mutex */ 2880Sstevel@tonic-gate uchar_t asy_msr; /* saved modem status */ 2890Sstevel@tonic-gate uchar_t asy_mcr; /* soft carrier bits */ 2900Sstevel@tonic-gate uchar_t asy_lcr; /* console lcr bits */ 2910Sstevel@tonic-gate uchar_t asy_bidx; /* console baud rate index */ 2920Sstevel@tonic-gate tcflag_t asy_cflag; /* console mode bits */ 2930Sstevel@tonic-gate struct cons_polledio polledio; /* polled I/O functions */ 2940Sstevel@tonic-gate ddi_acc_handle_t asy_iohandle; /* Data access handle */ 2950Sstevel@tonic-gate tcflag_t asy_ocflag; /* old console mode bits */ 2960Sstevel@tonic-gate uchar_t asy_com_port; /* COM port number, or zero */ 2970Sstevel@tonic-gate uchar_t asy_fifor; /* FIFOR register setting */ 2980Sstevel@tonic-gate #ifdef DEBUG 2990Sstevel@tonic-gate int asy_msint_cnt; /* number of times in async_msint */ 3000Sstevel@tonic-gate #endif 3010Sstevel@tonic-gate }; 3020Sstevel@tonic-gate 3030Sstevel@tonic-gate /* 3040Sstevel@tonic-gate * Asychronous protocol private data structure for ASY. 3050Sstevel@tonic-gate * Each of the fields in the structure is required to be protected by 3060Sstevel@tonic-gate * the lower priority lock except the fields that are set only at 3070Sstevel@tonic-gate * base level but cleared (with out lock) at interrupt level. 3080Sstevel@tonic-gate */ 3090Sstevel@tonic-gate 3100Sstevel@tonic-gate struct asyncline { 3110Sstevel@tonic-gate int async_flags; /* random flags */ 3120Sstevel@tonic-gate kcondvar_t async_flags_cv; /* condition variable for flags */ 3135295Srandyf kcondvar_t async_ops_cv; /* condition variable for async_ops */ 3140Sstevel@tonic-gate dev_t async_dev; /* device major/minor numbers */ 3150Sstevel@tonic-gate mblk_t *async_xmitblk; /* transmit: active msg block */ 3160Sstevel@tonic-gate struct asycom *async_common; /* device common data */ 3170Sstevel@tonic-gate tty_common_t async_ttycommon; /* tty driver common data */ 3180Sstevel@tonic-gate bufcall_id_t async_wbufcid; /* id for pending write-side bufcall */ 3195295Srandyf size_t async_wbufcds; /* Buffer size requested in bufcall */ 3200Sstevel@tonic-gate timeout_id_t async_polltid; /* softint poll timeout id */ 3210Sstevel@tonic-gate timeout_id_t async_dtrtid; /* delaying DTR turn on */ 3220Sstevel@tonic-gate timeout_id_t async_utbrktid; /* hold minimum untimed break time id */ 3230Sstevel@tonic-gate 3240Sstevel@tonic-gate /* 3250Sstevel@tonic-gate * The following fields are protected by the asy_excl_hi lock. 3260Sstevel@tonic-gate * Some, such as async_flowc, are set only at the base level and 3270Sstevel@tonic-gate * cleared (without the lock) only by the interrupt level. 3280Sstevel@tonic-gate */ 3290Sstevel@tonic-gate uchar_t *async_optr; /* output pointer */ 3300Sstevel@tonic-gate int async_ocnt; /* output count */ 331*12401SZachary.Kissel@Sun.COM uint_t async_rput; /* producing pointer for input */ 332*12401SZachary.Kissel@Sun.COM uint_t async_rget; /* consuming pointer for input */ 3330Sstevel@tonic-gate 3340Sstevel@tonic-gate /* 3350Sstevel@tonic-gate * Each character stuffed into the ring has two bytes associated 3360Sstevel@tonic-gate * with it. The first byte is used to indicate special conditions 3370Sstevel@tonic-gate * and the second byte is the actual data. The ring buffer 3380Sstevel@tonic-gate * needs to be defined as ushort_t to accomodate this. 3390Sstevel@tonic-gate */ 3400Sstevel@tonic-gate ushort_t async_ring[RINGSIZE]; 3410Sstevel@tonic-gate 3420Sstevel@tonic-gate short async_break; /* break count */ 3430Sstevel@tonic-gate int async_inflow_source; /* input flow control type */ 3440Sstevel@tonic-gate 3450Sstevel@tonic-gate union { 3460Sstevel@tonic-gate struct { 3470Sstevel@tonic-gate uchar_t _hw; /* overrun (hw) */ 3480Sstevel@tonic-gate uchar_t _sw; /* overrun (sw) */ 3490Sstevel@tonic-gate } _a; 3500Sstevel@tonic-gate ushort_t uover_overrun; 3510Sstevel@tonic-gate } async_uover; 3520Sstevel@tonic-gate #define async_overrun async_uover._a.uover_overrun 3530Sstevel@tonic-gate #define async_hw_overrun async_uover._a._hw 3540Sstevel@tonic-gate #define async_sw_overrun async_uover._a._sw 3550Sstevel@tonic-gate short async_ext; /* modem status change count */ 3560Sstevel@tonic-gate short async_work; /* work to do flag */ 3570Sstevel@tonic-gate timeout_id_t async_timer; /* close drain progress timer */ 3585295Srandyf 3595295Srandyf mblk_t *async_suspqf; /* front of suspend queue */ 3605295Srandyf mblk_t *async_suspqb; /* back of suspend queue */ 3615295Srandyf int async_ops; /* active operations counter */ 3620Sstevel@tonic-gate }; 3630Sstevel@tonic-gate 3640Sstevel@tonic-gate /* definitions for async_flags field */ 3650Sstevel@tonic-gate #define ASYNC_EXCL_OPEN 0x10000000 /* exclusive open */ 3660Sstevel@tonic-gate #define ASYNC_WOPEN 0x00000001 /* waiting for open to complete */ 3670Sstevel@tonic-gate #define ASYNC_ISOPEN 0x00000002 /* open is complete */ 3680Sstevel@tonic-gate #define ASYNC_OUT 0x00000004 /* line being used for dialout */ 3690Sstevel@tonic-gate #define ASYNC_CARR_ON 0x00000008 /* carrier on last time we looked */ 3700Sstevel@tonic-gate #define ASYNC_STOPPED 0x00000010 /* output is stopped */ 3710Sstevel@tonic-gate #define ASYNC_DELAY 0x00000020 /* waiting for delay to finish */ 3720Sstevel@tonic-gate #define ASYNC_BREAK 0x00000040 /* waiting for break to finish */ 3730Sstevel@tonic-gate #define ASYNC_BUSY 0x00000080 /* waiting for transmission to finish */ 3740Sstevel@tonic-gate #define ASYNC_DRAINING 0x00000100 /* waiting for output to drain */ 3750Sstevel@tonic-gate #define ASYNC_SERVICEIMM 0x00000200 /* queue soft interrupt as soon as */ 3760Sstevel@tonic-gate #define ASYNC_HW_IN_FLOW 0x00000400 /* input flow control in effect */ 3770Sstevel@tonic-gate #define ASYNC_HW_OUT_FLW 0x00000800 /* output flow control in effect */ 3780Sstevel@tonic-gate #define ASYNC_PROGRESS 0x00001000 /* made progress on output effort */ 3790Sstevel@tonic-gate #define ASYNC_CLOSING 0x00002000 /* processing close on stream */ 3800Sstevel@tonic-gate #define ASYNC_OUT_SUSPEND 0x00004000 /* waiting for TIOCSBRK to finish */ 3810Sstevel@tonic-gate #define ASYNC_HOLD_UTBRK 0x00008000 /* waiting for untimed break hold */ 3820Sstevel@tonic-gate /* the minimum time */ 3830Sstevel@tonic-gate #define ASYNC_DTR_DELAY 0x00010000 /* delaying DTR turn on */ 3840Sstevel@tonic-gate #define ASYNC_SW_IN_FLOW 0x00020000 /* sw input flow control in effect */ 3850Sstevel@tonic-gate #define ASYNC_SW_OUT_FLW 0x00040000 /* sw output flow control in effect */ 3860Sstevel@tonic-gate #define ASYNC_SW_IN_NEEDED 0x00080000 /* sw input flow control char is */ 3870Sstevel@tonic-gate /* needed to be sent */ 3880Sstevel@tonic-gate #define ASYNC_OUT_FLW_RESUME 0x00100000 /* output need to be resumed */ 3890Sstevel@tonic-gate /* because of transition of flow */ 3900Sstevel@tonic-gate /* control from stop to start */ 3915295Srandyf #define ASYNC_DDI_SUSPENDED 0x00200000 /* suspended by DDI */ 3925295Srandyf #define ASYNC_RESUME_BUFCALL 0x00400000 /* call bufcall when resumed by DDI */ 3930Sstevel@tonic-gate 3940Sstevel@tonic-gate /* asy_hwtype definitions */ 3950Sstevel@tonic-gate #define ASY8250A 0x2 /* 8250A or 16450 */ 3960Sstevel@tonic-gate #define ASY16550 0x3 /* broken FIFO which must not be used */ 3970Sstevel@tonic-gate #define ASY16550A 0x4 /* usable FIFO */ 3980Sstevel@tonic-gate #define ASY16650 0x5 3990Sstevel@tonic-gate #define ASY16750 0x6 4000Sstevel@tonic-gate 4010Sstevel@tonic-gate /* definitions for asy_flags field */ 4020Sstevel@tonic-gate #define ASY_NEEDSOFT 0x00000001 4030Sstevel@tonic-gate #define ASY_DOINGSOFT 0x00000002 4040Sstevel@tonic-gate #define ASY_PPS 0x00000004 4050Sstevel@tonic-gate #define ASY_PPS_EDGE 0x00000008 4060Sstevel@tonic-gate #define ASY_DOINGSOFT_RETRY 0x00000010 4070Sstevel@tonic-gate #define ASY_RTS_DTR_OFF 0x00000020 4080Sstevel@tonic-gate #define ASY_IGNORE_CD 0x00000040 4090Sstevel@tonic-gate #define ASY_CONSOLE 0x00000080 4105295Srandyf #define ASY_DDI_SUSPENDED 0x00000100 /* suspended by DDI */ 4110Sstevel@tonic-gate 4120Sstevel@tonic-gate /* definitions for asy_flags2 field */ 4130Sstevel@tonic-gate #define ASY2_NO_LOOPBACK 0x00000001 /* Device doesn't support loopback */ 4140Sstevel@tonic-gate 4150Sstevel@tonic-gate /* definitions for async_inflow_source field in struct asyncline */ 4160Sstevel@tonic-gate #define IN_FLOW_NULL 0x00000000 4170Sstevel@tonic-gate #define IN_FLOW_RINGBUFF 0x00000001 4180Sstevel@tonic-gate #define IN_FLOW_STREAMS 0x00000002 4190Sstevel@tonic-gate #define IN_FLOW_USER 0x00000004 4200Sstevel@tonic-gate 4210Sstevel@tonic-gate /* 4220Sstevel@tonic-gate * OUTLINE defines the high-order flag bit in the minor device number that 4230Sstevel@tonic-gate * controls use of a tty line for dialin and dialout simultaneously. 4240Sstevel@tonic-gate */ 4250Sstevel@tonic-gate #ifdef _LP64 4260Sstevel@tonic-gate #define OUTLINE (1 << (NBITSMINOR32 - 1)) 4270Sstevel@tonic-gate #else 4280Sstevel@tonic-gate #define OUTLINE (1 << (NBITSMINOR - 1)) 4290Sstevel@tonic-gate #endif 4300Sstevel@tonic-gate #define UNIT(x) (getminor(x) & ~OUTLINE) 4310Sstevel@tonic-gate 4320Sstevel@tonic-gate /* 4330Sstevel@tonic-gate * ASYSETSOFT macro to pend a soft interrupt if one isn't already pending. 4340Sstevel@tonic-gate */ 4350Sstevel@tonic-gate 4360Sstevel@tonic-gate #define ASYSETSOFT(asy) { \ 437*12401SZachary.Kissel@Sun.COM if (mutex_tryenter(&asy->asy_soft_lock)) { \ 438*12401SZachary.Kissel@Sun.COM asy->asy_flags |= ASY_NEEDSOFT; \ 439*12401SZachary.Kissel@Sun.COM if (!asy->asysoftpend) { \ 440*12401SZachary.Kissel@Sun.COM asy->asysoftpend = 1; \ 441*12401SZachary.Kissel@Sun.COM mutex_exit(&asy->asy_soft_lock); \ 442*12401SZachary.Kissel@Sun.COM ddi_trigger_softintr(asy->asy_softintr_id); \ 443*12401SZachary.Kissel@Sun.COM } \ 444*12401SZachary.Kissel@Sun.COM else \ 445*12401SZachary.Kissel@Sun.COM mutex_exit(&asy->asy_soft_lock); \ 446*12401SZachary.Kissel@Sun.COM } \ 4470Sstevel@tonic-gate } 4480Sstevel@tonic-gate 4490Sstevel@tonic-gate #ifdef __cplusplus 4500Sstevel@tonic-gate } 4510Sstevel@tonic-gate #endif 4520Sstevel@tonic-gate 4530Sstevel@tonic-gate #endif /* _SYS_ASY_H */ 454