xref: /netbsd/sys/arch/amiga/dev/mscreg.h (revision 6550d01e)
1 /*	$NetBSD: mscreg.h,v 1.9 2007/02/22 05:04:12 thorpej Exp $ */
2 
3 /*
4  * Copyright (c) 1982, 1986, 1990 Regents of the University of California.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  *    - created by zik 931207
32  *    - Fixed break value. 950108 RFH
33  *    - Added 6502 field to mscmemory so board can be halted while
34  *	it's memory is being reloaded. 950108 RFH
35  *    - Ripped out structure guts and replaced with Jukka Marin's stuff for his
36  *	freely redistributable version of the 2232 6502c code. Yea!!!!!!
37  *	950916 RFH
38  *    - Added Jukka's turbo board detection support and tmpbuf for copys. 950918
39  *    - Change to NetBSD style for integration in to the main tree. 950919
40  */
41 
42 /*
43  * Copyright (c) 1993 Zik.
44  * Copyright (c) 1995 Jukka Marin <jmarin@teeri.jmp.fi>.
45  * Copyright (c) 1995 Rob Healey <rhealey@kas.helios.mn.org>.
46  *
47  * Redistribution and use in source and binary forms, with or without
48  * modification, are permitted provided that the following conditions
49  * are met:
50  * 1. Redistributions of source code must retain the above copyright
51  *    notice, this list of conditions and the following disclaimer.
52  * 2. Redistributions in binary form must reproduce the above copyright
53  *    notice, this list of conditions and the following disclaimer in the
54  *    documentation and/or other materials provided with the distribution.
55  * 3. All advertising materials mentioning features or use of this software
56  *    must display the following acknowledgement:
57  *	This product includes software developed by the University of
58  *	California, Berkeley and its contributors.
59  * 4. Neither the name of the University nor the names of its contributors
60  *    may be used to endorse or promote products derived from this software
61  *    without specific prior written permission.
62  *
63  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
64  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
65  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
66  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
67  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
68  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
69  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
70  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
71  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
72  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
73  * SUCH DAMAGE.
74  *
75  *    - created by zik 931207
76  *    - Fixed break value. 950108 RFH
77  *    - Added 6502 field to mscmemory so board can be halted while
78  *	it's memory is being reloaded. 950108 RFH
79  *    - Ripped out structure guts and replaced with Jukka Marin's stuff for his
80  *	freely redistributable version of the 2232 6502c code. Yea!!!!!!
81  *	950916 RFH
82  *    - Added Jukka's turbo board detection support and tmpbuf for copys. 950918
83  *    - Change to NetBSD style for integration in to the main tree. 950919
84  */
85 
86 #define	NUMLINES	7	/* number of lines per card */
87 #define	IOBUFLEN	256	/* number of bytes per buffer */
88 #define	IOBUFLENMASK	0xff	/* mask for maximum number of bytes */
89 #define	IOBUFHIGHWATER	192	/* point at which to enable output */
90 #define	IOBUFLOWWATER	128	/* point at which to wake output */
91 
92 #define	MSC_VBL_PRIORITY	1	/* priority of vbl interrupt handler */
93 
94 #define	MSC_UNKNOWN	0	/* crystal not known */
95 #define	MSC_NORMAL	1	/* normal A2232 (1.8432 MHz oscillator) */
96 #define	MSC_TURBO	2	/* turbo A2232 (3.6864 MHz oscillator) */
97 
98 
99 struct msccommon {
100 	char   Crystal;	/* normal (1) or turbo (2) board? */
101 	u_char Pad_a;
102 	u_char TimerH;	/* timer value after speed check */
103 	u_char TimerL;
104 	u_char CDHead;	/* head pointer for CD message queue */
105 	u_char CDTail;	/* tail pointer for CD message queue */
106 	u_char CDStatus;
107 	u_char Pad_b;
108 };
109 
110 struct mscstatus {
111 	u_char InHead;		/* input queue head */
112 	u_char InTail;		/* input queue tail */
113 	u_char OutDisable;	/* disables output */
114 	u_char OutHead;		/* output queue head */
115 	u_char OutTail;		/* output queue tail */
116 	u_char OutCtrl;		/* soft flow control character to send */
117 	u_char OutFlush;	/* flushes output buffer */
118 	u_char Setup;		/* causes reconfiguration */
119 	u_char Param;		/* parameter byte - see MSCPARAM */
120 	u_char Command;		/* command byte - see MSCCMD */
121 	u_char SoftFlow;	/* enables xon/xoff flow control */
122 	/* private 65C02 fields: */
123 	u_char XonOff;		/* stores XON/XOFF enable/disable */
124 };
125 
126 #define	MSC_MEMPAD1	\
127     (0x0200 - NUMLINES * sizeof(struct mscstatus) - sizeof(struct msccommon))
128 #define	MSC_MEMPAD2	(0x2000 - NUMLINES * IOBUFLEN - IOBUFLEN)
129 
130 struct mscmemory {
131 	struct mscstatus Status[NUMLINES];	/* 0x0000-0x006f status areas */
132 	struct msccommon Common;		/* 0x0070-0x0077 common flags */
133 	u_char Dummy1[MSC_MEMPAD1];		/* 0x00XX-0x01ff */
134 	u_char OutBuf[NUMLINES][IOBUFLEN];	/* 0x0200-0x08ff output bufs */
135 	u_char InBuf[NUMLINES][IOBUFLEN];	/* 0x0900-0x0fff input bufs */
136 	u_char InCtl[NUMLINES][IOBUFLEN];	/* 0x1000-0x16ff control data */
137 	u_char CDBuf[IOBUFLEN];			/* 0x1700-0x17ff CD event buffer */
138 	u_char Dummy2[MSC_MEMPAD2];		/* 0x1800-0x2fff */
139 	u_char Code[0x1000];			/* 0x3000-0x3fff code area */
140 	u_short InterruptAck;			/* 0x4000        intr ack */
141 	u_char Dummy3[0x3ffe];			/* 0x4002-0x7fff */
142 	u_short Enable6502Reset;		/* 0x8000 Stop board, */
143 						/*  6502 RESET line held low */
144 	u_char Dummy4[0x3ffe];			/* 0x8002-0xbfff */
145 	u_short ResetBoard;			/* 0xc000 reset board & run, */
146 						/*  6502 RESET line held high */
147 };
148 
149 #undef MSC_MEMPAD1
150 #undef MSC_MEMPAD2
151 
152 struct mscdevice {
153 	volatile struct mscmemory *board;	/* where the board is located */
154 	int flags;			/* modem control flags */
155 	int openflags;			/* flags for device open */
156 	u_char unit;			/* which unit (ie. which board) */
157 	u_char port;			/* which port on the board (0-6) */
158 	u_char active;			/* does this port have hardware? */
159 	u_char closing;			/* are we flushing before close? */
160 	char tmpbuf[IOBUFLEN];		/* temp buffer for data transfers */
161 };
162 
163 #define	MSCINCTL_CHAR	0	/* corresponding byte in InBuf is a character */
164 #define	MSCINCTL_EVENT	1	/* corresponding byte in InBuf is an event */
165 
166 #define	MSCEVENT_Break		1	/* break set */
167 #define	MSCEVENT_CarrierOn	2	/* carrier raised */
168 #define	MSCEVENT_CarrierOff	3	/* carrier dropped */
169 
170 #define	MSCCMD_Enable		0x1	/* enable/DTR bit */
171 #define	MSCCMD_Close		0x2	/* close the device */
172 #define	MSCCMD_Open		0xb	/* open the device */
173 #define	MSCCMD_CMask		0xf	/* command mask */
174 #define	MSCCMD_RTSOff		0x0  	/* turn off RTS */
175 #define	MSCCMD_RTSOn		0x8	/* turn on RTS */
176 #define	MSCCMD_Break		0xd	/* transmit a break */
177 #define	MSCCMD_RTSMask		0xc	/* mask for RTS stuff */
178 #define	MSCCMD_NoParity		0x00	/* don't use parity */
179 #define	MSCCMD_OddParity	0x20	/* odd parity */
180 #define	MSCCMD_EvenParity	0x60	/* even parity */
181 #define	MSCCMD_ParityMask	0xe0	/* parity mask */
182 
183 #define	MSCPARAM_B115200	0x0	/* baud rates */
184 #define	MSCPARAM_B50		0x1
185 #define	MSCPARAM_B75		0x2
186 #define	MSCPARAM_B110		0x3
187 #define	MSCPARAM_B134		0x4
188 #define	MSCPARAM_B150		0x5
189 #define	MSCPARAM_B300		0x6
190 #define	MSCPARAM_B600		0x7
191 #define	MSCPARAM_B1200		0x8
192 #define	MSCPARAM_B1800		0x9
193 #define	MSCPARAM_B2400		0xa
194 #define	MSCPARAM_B3600		0xb
195 #define	MSCPARAM_B4800		0xc
196 #define	MSCPARAM_B7200		0xd
197 #define	MSCPARAM_B9600		0xe
198 #define	MSCPARAM_B19200		0xf
199 #define	MSCPARAM_BaudMask	0xf	/* baud rate mask */
200 #define	MSCPARAM_RcvBaud	0x10	/* enable receive baud rate */
201 #define	MSCPARAM_8Bit		0x00	/* numbers of bits */
202 #define	MSCPARAM_7Bit		0x20
203 #define	MSCPARAM_6Bit		0x40
204 #define	MSCPARAM_5Bit		0x60
205 #define	MSCPARAM_BitMask	0x60	/* numbers of bits mask */
206 
207 /* tty number from device */
208 #define	MSCTTY(dev)	(minor(dev) & 0x7e)
209 
210 /* slot number from device */
211 #define	MSCSLOT(dev)	((minor(dev) & 0x7e)>>1)
212 
213 /* dialin mode from device */
214 #define	MSCDIALIN(dev)	(minor(dev) & 0x01)
215 
216 /* board number from device */
217 #define	MSCBOARD(dev)	((minor(dev))>>4)
218 
219 /* line number from device */
220 #define	MSCLINE(dev)	(((minor(dev)) & 0xe)>>1)
221 
222 /* number of slots */
223 #define	MSCSLOTS	((NMSC-1)*8+7)
224 
225 /* number of ttys */
226 #define	MSCTTYS		(MSCSLOTS*2)
227 
228 /* board number given slot number */
229 #define	MSCUNIT(slot)	((slot)>>3)
230 
231 /* slot number given unit and line */
232 #define	MSCSLOTUL(unit,line)	(((unit)<<3)+(line))
233 
234 /* tty number given slot */
235 #define	MSCTTYSLOT(slot)	((slot)<<1)
236