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