summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/pcmcia/pcser_io.h
blob: cc317842c69af802eb19ddd488a10a5bb2278660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1995,2001 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef _PCSER_IO_H
#define	_PCSER_IO_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Definitions for users of pcser devices.
 */

/*
 * Minor device number encoding:
 *
 *	o c s s | s s s s
 *
 *	o - set if this device is an outgoing serial line
 *	c - set if this device is a control device
 *	s - socket number of this device
 */

/*
 * Ioctl definitions - why 'd'?  why, for "defaults", of course
 *
 *	PCSER_DCONTROL -	sets/gets default parameters for any line
 *			flushes write queues for any line
 *			and a miscellany of other functions, read the man page
 *	PCSER_SDEFAULTS - sets default parameters for line that take effect on
 *			next open
 *	PCSER_GDEFAULTS - get default parameters (may not be active yet)
 */
#define	sIOC			('s'<<8)
#define	PCSER_DCONTROL		(sIOC|250)
#define	PCSER_SDEFAULTS	(sIOC|251)
#define	PCSER_GDEFAULTS	(sIOC|252)
#define	PCSER_GSTATS		(sIOC|255)

/*
 * we define this here so that it can be exported to users using the
 * serial ioctl()'s to manipulate line default parameters; if you
 * change this, the driver must be recompiled
 */
#define	PCSER_SILOSIZE	1024	/* size of (soft) rx silo in line struct */

/*
 * macro that returns 1 if parameter is out of range, used for range checking
 * on valued parameters passed to driver via pcser_defaults_t and ppc_params_t
 */
#define	FUNKY(v, min, max)	((v < min) || (v > max))

/*
 * fields of pcser_default_t structure
 *
 * flags for the serial lines in the pcser_line_t->flags member
 */
#define	DTR_ASSERT		0x0001	/* assert DTR on open */
#define	SOFT_CARR		0x0002	/* ignore CD input on open */
#define	PCSER_DTRCLOSE		0x0004	/* zs DTR close semantics if clear */
#define	PCSER_CFLOWFLUSH	0x0008	/* flush data in close if blocked */
#define	PCSER_CFLOWMSG		0x0010	/* display message in close */
#define	PCSER_INSTANTFLOW	0x0020	/* if s/w flow disabled, enable xmtr */
#define	PCSER_DTRFORCE		0x0040	/* force DTR always on */
#define	PCSER_IGNORE_CD_ON_OPEN	0x0080	/* ignore CD timeout on every open */
#define	PCSER_VALID_IO_INFO	0x0100	/* have valid IO infor from CIS */

/*
 * parameters for the serial lines. min and max values are listed.
 * if you put a strange value in, the ioctl will return an EINVAL and
 * no defaults will be changed
 */
#define	MIN_DRAIN_SIZE	4		/* min buf size in pcser_drainsilo() */
#define	MAX_DRAIN_SIZE	1024		/* max buf size in pcser_drainsilo() */
#define	MIN_HIWATER	2		/* min hiwater mark for Rx silo */
#define	MAX_HIWATER	(PCSER_SILOSIZE - 2)	/* max hiwater for Rx silo */
#define	MIN_LOWWATER	2			/* min lowwater for Rx silo */
#define	MAX_LOWWATER	((pcser_defaults->pcser_hiwater)-2) /* max lowwater */
#define	MIN_RTPR	1		/* min Rx timeout regtister value */
#define	MAX_RTPR	255		/* max Rx timeout regtister value */
#define	MIN_RX_FIFO	1		/* min value for Rx FIFO threshold */
#define	MAX_RX_FIFO	8		/* max value for Rx FIFO threshold */

#ifdef	XXXNODEFSXXX
/*
 * the structure that gets passed back and forth to deal with the defaults
 */
struct pcser_defaults_t {
	int		flags;		/* things like soft carrier, etc... */
	/* serial port Rx handler parameters */
	int		drain_size;	/* size of buf in pcser_drainsilo() */
	int		pcser_hiwater;	/* high water mark in CHECK_RTS() */
	int		pcser_lowwater;	/* low water mark in CHECK_RTS() */
	int		rtpr;		/* inter-character receive timer */
	int		rx_fifo_thld;	/* cd-180 RxFIFO threshold */
	struct termios	termios;	/* baud rates, parity, etc... */
	/* for the control device */
	int		line_no;	/* line number to operate on */
	int		op;		/* operation */
};

/*
 * op field return values for PCSER_GDEFAULTS, PCSER_DCONTROL(PCSER_CDEFGET)
 * and PCSER_DCONTROL(PCSER_SPARAM_GET)
 */
#define	PCSER_SERIAL	0x01		/* this is a serial line */
#define	PCSER_CNTRL	0x04		/* this is the control line */

/*
 * the op parameters, only written for the control device per board
 * used only with the PCSER_DCONTROL ioctl() and then only if the
 * device is the board control device (read the man page)
 *
 * PCSER_GDEFAULTS will return the type of line it's connected to
 * in the op field
 *
 * PCSER_DCONTROL(PCSER_CDEFGET) and PCSER_DCONTROL(PCSER_SPARAM_GET) will
 * return the type of line specified by the line_no field in
 * the op field
 *
 * PCSER_DCONTROL(PCSER_SPARAM_SET) and PCSER_DCONTROL(PCSER_SPARAM_GET) will
 * return an PCSER_NOTOPEN_ERR error if the referenced line is not open
 *
 * Note on PCSER_CFLUSH: set the line # that you want to flush in
 * the "line_no" field of the "pcser_defaults_t" struct that you
 * pass to PCSER_DCONTROL; if you want to flush the printer, set
 * the line number to 64 or use the PCSER_LP_SETLINE() macro
 *
 * PCSER_REGIOR, PCSER_REGIOW, PCSER_PPCREGR and PCSER_PPCREGW are designed
 * mostly for diagnostic use - don't try them unless you know what
 * you're doing; you can cause all sorts of problems like enabling
 * interrupts when they shouldn't be, resetting the cd180 and/or the
 * PPC and generally wreaking havoc with the whole system
 * to get register offsets for these, include <sbusdev/pcserreg.h>
 * for the diagnostic ops, specify the line number to operate on
 * as 0 (unless you want the passed line number to be loaded into
 * the cd180's CAR (channel address register) before each cd180
 * register access; if so, OR in PCSER_SETCAR to the op field)
 */
/* set another line's defaults */
#define	PCSER_CDEFSET		0x00000001
/* get another line's defaults */
#define	PCSER_CDEFGET		0x00000002
/* set serial port parameters immediately */
#define	PCSER_SPARAM_SET	0x00000004
/* get serial port parameters currently in use */
#define	PCSER_SPARAM_GET	0x00000008
/* flush a line's write queue */
#define	PCSER_CFLUSH		0x00008000
/* return if line is not open for PCSER_SPARAM_SET/PCSER_SPARAM_GET */
#define	PCSER_NOTOPEN_ERR	ESRCH

#endif	/* XXXNODEFSXXX */

/*
 * the pcser_stats_t struct is used for statistics gathering and monitoring
 *	driver performance of the serial lines (statistics gathering is
 *	not supported on the parallel line)
 */
struct pcser_stats_t {
	int		cmd;		/* command (see flags below) */
	int		qpunt;		/* punting in pcser_drainsilo */
	int		drain_timer;	/* posted a timer in pcser_drainsilo */
	int		no_canput;	/* canput failed in pcser_drainsilo */
	int		no_rcv_drain;	/* pcser_rcv no call pcser_drainsilo */
	int		pcser_drain;	/* PCSER_DRAIN flag set */
	int		pcser_break;	/* BREAK requested on XMIT */
	int		pcser_sbreak;	/* start BREAK requested pcser_ioctl */
	int		pcser_ebreak;	/* end BREAK requested pcser_ioctl */
	int		set_modem;	/* set modem lines in pcser_ioctl */
	int		get_modem;	/* get modem lines in pcser_ioctl */
	int		ioc_error;	/* bad ioctl */
	int		set_params;	/* call to pcser_param */
	int		no_start;	/* already in pcser_start */
	int		xmit_int;	/* transmit int	errupts */
	int		rcv_int;	/* receive int	errupts */
	int		rcvex_int;	/* receive exception interrupts */
	int		modem_int;	/* modem change interrupts */
	int		xmit_cc;	/* characters transmitted */
	int		rcv_cc;		/* characters received */
	int		break_cnt;	/* BREAKs received */
	int		bufcall;	/* times couldn't get STREAMS buffer */
	int		canwait;	/* pending timer in pcser_drainsilo */
	int		nqfretry;	/* num q retries in pcser_drainsilo */
	unsigned	flags;		/* misc flags */
};
/*
 * flags in pcser_stats_t.cmd field
 */
#define	STAT_SET		0x0002		/* set line parameters */
#define	STAT_CLEAR		0x0001		/* clear line statistics */
#define	STAT_GET		0x0000		/* get line statistics */

/*
 * flags in pcser_stats_t.flags field
 */
#define	CARD_IN_SOCKET		0x0001		/* card is in socket */

#ifdef	__cplusplus
}
#endif

#endif	/* _PCSER_IO_H */