1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright (c) 1995,2001 by Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _PCSER_IO_H 28*0Sstevel@tonic-gate #define _PCSER_IO_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifdef __cplusplus 33*0Sstevel@tonic-gate extern "C" { 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate /* 37*0Sstevel@tonic-gate * Definitions for users of pcser devices. 38*0Sstevel@tonic-gate */ 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * Minor device number encoding: 42*0Sstevel@tonic-gate * 43*0Sstevel@tonic-gate * o c s s | s s s s 44*0Sstevel@tonic-gate * 45*0Sstevel@tonic-gate * o - set if this device is an outgoing serial line 46*0Sstevel@tonic-gate * c - set if this device is a control device 47*0Sstevel@tonic-gate * s - socket number of this device 48*0Sstevel@tonic-gate */ 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate /* 51*0Sstevel@tonic-gate * Ioctl definitions - why 'd'? why, for "defaults", of course 52*0Sstevel@tonic-gate * 53*0Sstevel@tonic-gate * PCSER_DCONTROL - sets/gets default parameters for any line 54*0Sstevel@tonic-gate * flushes write queues for any line 55*0Sstevel@tonic-gate * and a miscellany of other functions, read the man page 56*0Sstevel@tonic-gate * PCSER_SDEFAULTS - sets default parameters for line that take effect on 57*0Sstevel@tonic-gate * next open 58*0Sstevel@tonic-gate * PCSER_GDEFAULTS - get default parameters (may not be active yet) 59*0Sstevel@tonic-gate */ 60*0Sstevel@tonic-gate #define sIOC ('s'<<8) 61*0Sstevel@tonic-gate #define PCSER_DCONTROL (sIOC|250) 62*0Sstevel@tonic-gate #define PCSER_SDEFAULTS (sIOC|251) 63*0Sstevel@tonic-gate #define PCSER_GDEFAULTS (sIOC|252) 64*0Sstevel@tonic-gate #define PCSER_GSTATS (sIOC|255) 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate /* 67*0Sstevel@tonic-gate * we define this here so that it can be exported to users using the 68*0Sstevel@tonic-gate * serial ioctl()'s to manipulate line default parameters; if you 69*0Sstevel@tonic-gate * change this, the driver must be recompiled 70*0Sstevel@tonic-gate */ 71*0Sstevel@tonic-gate #define PCSER_SILOSIZE 1024 /* size of (soft) rx silo in line struct */ 72*0Sstevel@tonic-gate 73*0Sstevel@tonic-gate /* 74*0Sstevel@tonic-gate * macro that returns 1 if parameter is out of range, used for range checking 75*0Sstevel@tonic-gate * on valued parameters passed to driver via pcser_defaults_t and ppc_params_t 76*0Sstevel@tonic-gate */ 77*0Sstevel@tonic-gate #define FUNKY(v, min, max) ((v < min) || (v > max)) 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate /* 80*0Sstevel@tonic-gate * fields of pcser_default_t structure 81*0Sstevel@tonic-gate * 82*0Sstevel@tonic-gate * flags for the serial lines in the pcser_line_t->flags member 83*0Sstevel@tonic-gate */ 84*0Sstevel@tonic-gate #define DTR_ASSERT 0x0001 /* assert DTR on open */ 85*0Sstevel@tonic-gate #define SOFT_CARR 0x0002 /* ignore CD input on open */ 86*0Sstevel@tonic-gate #define PCSER_DTRCLOSE 0x0004 /* zs DTR close semantics if clear */ 87*0Sstevel@tonic-gate #define PCSER_CFLOWFLUSH 0x0008 /* flush data in close if blocked */ 88*0Sstevel@tonic-gate #define PCSER_CFLOWMSG 0x0010 /* display message in close */ 89*0Sstevel@tonic-gate #define PCSER_INSTANTFLOW 0x0020 /* if s/w flow disabled, enable xmtr */ 90*0Sstevel@tonic-gate #define PCSER_DTRFORCE 0x0040 /* force DTR always on */ 91*0Sstevel@tonic-gate #define PCSER_IGNORE_CD_ON_OPEN 0x0080 /* ignore CD timeout on every open */ 92*0Sstevel@tonic-gate #define PCSER_VALID_IO_INFO 0x0100 /* have valid IO infor from CIS */ 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate /* 95*0Sstevel@tonic-gate * parameters for the serial lines. min and max values are listed. 96*0Sstevel@tonic-gate * if you put a strange value in, the ioctl will return an EINVAL and 97*0Sstevel@tonic-gate * no defaults will be changed 98*0Sstevel@tonic-gate */ 99*0Sstevel@tonic-gate #define MIN_DRAIN_SIZE 4 /* min buf size in pcser_drainsilo() */ 100*0Sstevel@tonic-gate #define MAX_DRAIN_SIZE 1024 /* max buf size in pcser_drainsilo() */ 101*0Sstevel@tonic-gate #define MIN_HIWATER 2 /* min hiwater mark for Rx silo */ 102*0Sstevel@tonic-gate #define MAX_HIWATER (PCSER_SILOSIZE - 2) /* max hiwater for Rx silo */ 103*0Sstevel@tonic-gate #define MIN_LOWWATER 2 /* min lowwater for Rx silo */ 104*0Sstevel@tonic-gate #define MAX_LOWWATER ((pcser_defaults->pcser_hiwater)-2) /* max lowwater */ 105*0Sstevel@tonic-gate #define MIN_RTPR 1 /* min Rx timeout regtister value */ 106*0Sstevel@tonic-gate #define MAX_RTPR 255 /* max Rx timeout regtister value */ 107*0Sstevel@tonic-gate #define MIN_RX_FIFO 1 /* min value for Rx FIFO threshold */ 108*0Sstevel@tonic-gate #define MAX_RX_FIFO 8 /* max value for Rx FIFO threshold */ 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate #ifdef XXXNODEFSXXX 111*0Sstevel@tonic-gate /* 112*0Sstevel@tonic-gate * the structure that gets passed back and forth to deal with the defaults 113*0Sstevel@tonic-gate */ 114*0Sstevel@tonic-gate struct pcser_defaults_t { 115*0Sstevel@tonic-gate int flags; /* things like soft carrier, etc... */ 116*0Sstevel@tonic-gate /* serial port Rx handler parameters */ 117*0Sstevel@tonic-gate int drain_size; /* size of buf in pcser_drainsilo() */ 118*0Sstevel@tonic-gate int pcser_hiwater; /* high water mark in CHECK_RTS() */ 119*0Sstevel@tonic-gate int pcser_lowwater; /* low water mark in CHECK_RTS() */ 120*0Sstevel@tonic-gate int rtpr; /* inter-character receive timer */ 121*0Sstevel@tonic-gate int rx_fifo_thld; /* cd-180 RxFIFO threshold */ 122*0Sstevel@tonic-gate struct termios termios; /* baud rates, parity, etc... */ 123*0Sstevel@tonic-gate /* for the control device */ 124*0Sstevel@tonic-gate int line_no; /* line number to operate on */ 125*0Sstevel@tonic-gate int op; /* operation */ 126*0Sstevel@tonic-gate }; 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate /* 129*0Sstevel@tonic-gate * op field return values for PCSER_GDEFAULTS, PCSER_DCONTROL(PCSER_CDEFGET) 130*0Sstevel@tonic-gate * and PCSER_DCONTROL(PCSER_SPARAM_GET) 131*0Sstevel@tonic-gate */ 132*0Sstevel@tonic-gate #define PCSER_SERIAL 0x01 /* this is a serial line */ 133*0Sstevel@tonic-gate #define PCSER_CNTRL 0x04 /* this is the control line */ 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate /* 136*0Sstevel@tonic-gate * the op parameters, only written for the control device per board 137*0Sstevel@tonic-gate * used only with the PCSER_DCONTROL ioctl() and then only if the 138*0Sstevel@tonic-gate * device is the board control device (read the man page) 139*0Sstevel@tonic-gate * 140*0Sstevel@tonic-gate * PCSER_GDEFAULTS will return the type of line it's connected to 141*0Sstevel@tonic-gate * in the op field 142*0Sstevel@tonic-gate * 143*0Sstevel@tonic-gate * PCSER_DCONTROL(PCSER_CDEFGET) and PCSER_DCONTROL(PCSER_SPARAM_GET) will 144*0Sstevel@tonic-gate * return the type of line specified by the line_no field in 145*0Sstevel@tonic-gate * the op field 146*0Sstevel@tonic-gate * 147*0Sstevel@tonic-gate * PCSER_DCONTROL(PCSER_SPARAM_SET) and PCSER_DCONTROL(PCSER_SPARAM_GET) will 148*0Sstevel@tonic-gate * return an PCSER_NOTOPEN_ERR error if the referenced line is not open 149*0Sstevel@tonic-gate * 150*0Sstevel@tonic-gate * Note on PCSER_CFLUSH: set the line # that you want to flush in 151*0Sstevel@tonic-gate * the "line_no" field of the "pcser_defaults_t" struct that you 152*0Sstevel@tonic-gate * pass to PCSER_DCONTROL; if you want to flush the printer, set 153*0Sstevel@tonic-gate * the line number to 64 or use the PCSER_LP_SETLINE() macro 154*0Sstevel@tonic-gate * 155*0Sstevel@tonic-gate * PCSER_REGIOR, PCSER_REGIOW, PCSER_PPCREGR and PCSER_PPCREGW are designed 156*0Sstevel@tonic-gate * mostly for diagnostic use - don't try them unless you know what 157*0Sstevel@tonic-gate * you're doing; you can cause all sorts of problems like enabling 158*0Sstevel@tonic-gate * interrupts when they shouldn't be, resetting the cd180 and/or the 159*0Sstevel@tonic-gate * PPC and generally wreaking havoc with the whole system 160*0Sstevel@tonic-gate * to get register offsets for these, include <sbusdev/pcserreg.h> 161*0Sstevel@tonic-gate * for the diagnostic ops, specify the line number to operate on 162*0Sstevel@tonic-gate * as 0 (unless you want the passed line number to be loaded into 163*0Sstevel@tonic-gate * the cd180's CAR (channel address register) before each cd180 164*0Sstevel@tonic-gate * register access; if so, OR in PCSER_SETCAR to the op field) 165*0Sstevel@tonic-gate */ 166*0Sstevel@tonic-gate /* set another line's defaults */ 167*0Sstevel@tonic-gate #define PCSER_CDEFSET 0x00000001 168*0Sstevel@tonic-gate /* get another line's defaults */ 169*0Sstevel@tonic-gate #define PCSER_CDEFGET 0x00000002 170*0Sstevel@tonic-gate /* set serial port parameters immediately */ 171*0Sstevel@tonic-gate #define PCSER_SPARAM_SET 0x00000004 172*0Sstevel@tonic-gate /* get serial port parameters currently in use */ 173*0Sstevel@tonic-gate #define PCSER_SPARAM_GET 0x00000008 174*0Sstevel@tonic-gate /* flush a line's write queue */ 175*0Sstevel@tonic-gate #define PCSER_CFLUSH 0x00008000 176*0Sstevel@tonic-gate /* return if line is not open for PCSER_SPARAM_SET/PCSER_SPARAM_GET */ 177*0Sstevel@tonic-gate #define PCSER_NOTOPEN_ERR ESRCH 178*0Sstevel@tonic-gate 179*0Sstevel@tonic-gate #endif /* XXXNODEFSXXX */ 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gate /* 182*0Sstevel@tonic-gate * the pcser_stats_t struct is used for statistics gathering and monitoring 183*0Sstevel@tonic-gate * driver performance of the serial lines (statistics gathering is 184*0Sstevel@tonic-gate * not supported on the parallel line) 185*0Sstevel@tonic-gate */ 186*0Sstevel@tonic-gate struct pcser_stats_t { 187*0Sstevel@tonic-gate int cmd; /* command (see flags below) */ 188*0Sstevel@tonic-gate int qpunt; /* punting in pcser_drainsilo */ 189*0Sstevel@tonic-gate int drain_timer; /* posted a timer in pcser_drainsilo */ 190*0Sstevel@tonic-gate int no_canput; /* canput failed in pcser_drainsilo */ 191*0Sstevel@tonic-gate int no_rcv_drain; /* pcser_rcv no call pcser_drainsilo */ 192*0Sstevel@tonic-gate int pcser_drain; /* PCSER_DRAIN flag set */ 193*0Sstevel@tonic-gate int pcser_break; /* BREAK requested on XMIT */ 194*0Sstevel@tonic-gate int pcser_sbreak; /* start BREAK requested pcser_ioctl */ 195*0Sstevel@tonic-gate int pcser_ebreak; /* end BREAK requested pcser_ioctl */ 196*0Sstevel@tonic-gate int set_modem; /* set modem lines in pcser_ioctl */ 197*0Sstevel@tonic-gate int get_modem; /* get modem lines in pcser_ioctl */ 198*0Sstevel@tonic-gate int ioc_error; /* bad ioctl */ 199*0Sstevel@tonic-gate int set_params; /* call to pcser_param */ 200*0Sstevel@tonic-gate int no_start; /* already in pcser_start */ 201*0Sstevel@tonic-gate int xmit_int; /* transmit int errupts */ 202*0Sstevel@tonic-gate int rcv_int; /* receive int errupts */ 203*0Sstevel@tonic-gate int rcvex_int; /* receive exception interrupts */ 204*0Sstevel@tonic-gate int modem_int; /* modem change interrupts */ 205*0Sstevel@tonic-gate int xmit_cc; /* characters transmitted */ 206*0Sstevel@tonic-gate int rcv_cc; /* characters received */ 207*0Sstevel@tonic-gate int break_cnt; /* BREAKs received */ 208*0Sstevel@tonic-gate int bufcall; /* times couldn't get STREAMS buffer */ 209*0Sstevel@tonic-gate int canwait; /* pending timer in pcser_drainsilo */ 210*0Sstevel@tonic-gate int nqfretry; /* num q retries in pcser_drainsilo */ 211*0Sstevel@tonic-gate unsigned flags; /* misc flags */ 212*0Sstevel@tonic-gate }; 213*0Sstevel@tonic-gate /* 214*0Sstevel@tonic-gate * flags in pcser_stats_t.cmd field 215*0Sstevel@tonic-gate */ 216*0Sstevel@tonic-gate #define STAT_SET 0x0002 /* set line parameters */ 217*0Sstevel@tonic-gate #define STAT_CLEAR 0x0001 /* clear line statistics */ 218*0Sstevel@tonic-gate #define STAT_GET 0x0000 /* get line statistics */ 219*0Sstevel@tonic-gate 220*0Sstevel@tonic-gate /* 221*0Sstevel@tonic-gate * flags in pcser_stats_t.flags field 222*0Sstevel@tonic-gate */ 223*0Sstevel@tonic-gate #define CARD_IN_SOCKET 0x0001 /* card is in socket */ 224*0Sstevel@tonic-gate 225*0Sstevel@tonic-gate #ifdef __cplusplus 226*0Sstevel@tonic-gate } 227*0Sstevel@tonic-gate #endif 228*0Sstevel@tonic-gate 229*0Sstevel@tonic-gate #endif /* _PCSER_IO_H */ 230