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