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