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