1 |
1275 |
phoenix |
/*
|
2 |
|
|
** -----------------------------------------------------------------------------
|
3 |
|
|
**
|
4 |
|
|
** Perle Specialix driver for Linux
|
5 |
|
|
** Ported from existing RIO Driver for SCO sources.
|
6 |
|
|
*
|
7 |
|
|
* (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
|
8 |
|
|
*
|
9 |
|
|
* This program is free software; you can redistribute it and/or modify
|
10 |
|
|
* it under the terms of the GNU General Public License as published by
|
11 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
12 |
|
|
* (at your option) any later version.
|
13 |
|
|
*
|
14 |
|
|
* This program is distributed in the hope that it will be useful,
|
15 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
|
|
* GNU General Public License for more details.
|
18 |
|
|
*
|
19 |
|
|
* You should have received a copy of the GNU General Public License
|
20 |
|
|
* along with this program; if not, write to the Free Software
|
21 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
22 |
|
|
**
|
23 |
|
|
** Module : riointr.c
|
24 |
|
|
** SID : 1.2
|
25 |
|
|
** Last Modified : 11/6/98 10:33:44
|
26 |
|
|
** Retrieved : 11/6/98 10:33:49
|
27 |
|
|
**
|
28 |
|
|
** ident @(#)riointr.c 1.2
|
29 |
|
|
**
|
30 |
|
|
** -----------------------------------------------------------------------------
|
31 |
|
|
*/
|
32 |
|
|
#ifdef SCCS_LABELS
|
33 |
|
|
static char *_riointr_c_sccs_ = "@(#)riointr.c 1.2";
|
34 |
|
|
#endif
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
#define __NO_VERSION__
|
38 |
|
|
#include <linux/module.h>
|
39 |
|
|
#include <linux/slab.h>
|
40 |
|
|
#include <linux/errno.h>
|
41 |
|
|
#include <linux/tty.h>
|
42 |
|
|
#include <asm/io.h>
|
43 |
|
|
#include <asm/system.h>
|
44 |
|
|
#include <asm/string.h>
|
45 |
|
|
#include <asm/semaphore.h>
|
46 |
|
|
#include <asm/uaccess.h>
|
47 |
|
|
|
48 |
|
|
#include <linux/termios.h>
|
49 |
|
|
#include <linux/serial.h>
|
50 |
|
|
|
51 |
|
|
#include <linux/compatmac.h>
|
52 |
|
|
#include <linux/generic_serial.h>
|
53 |
|
|
|
54 |
|
|
#include <linux/delay.h>
|
55 |
|
|
|
56 |
|
|
#include "linux_compat.h"
|
57 |
|
|
#include "rio_linux.h"
|
58 |
|
|
#include "typdef.h"
|
59 |
|
|
#include "pkt.h"
|
60 |
|
|
#include "daemon.h"
|
61 |
|
|
#include "rio.h"
|
62 |
|
|
#include "riospace.h"
|
63 |
|
|
#include "top.h"
|
64 |
|
|
#include "cmdpkt.h"
|
65 |
|
|
#include "map.h"
|
66 |
|
|
#include "riotypes.h"
|
67 |
|
|
#include "rup.h"
|
68 |
|
|
#include "port.h"
|
69 |
|
|
#include "riodrvr.h"
|
70 |
|
|
#include "rioinfo.h"
|
71 |
|
|
#include "func.h"
|
72 |
|
|
#include "errors.h"
|
73 |
|
|
#include "pci.h"
|
74 |
|
|
|
75 |
|
|
#include "parmmap.h"
|
76 |
|
|
#include "unixrup.h"
|
77 |
|
|
#include "board.h"
|
78 |
|
|
#include "host.h"
|
79 |
|
|
#include "error.h"
|
80 |
|
|
#include "phb.h"
|
81 |
|
|
#include "link.h"
|
82 |
|
|
#include "cmdblk.h"
|
83 |
|
|
#include "route.h"
|
84 |
|
|
#include "control.h"
|
85 |
|
|
#include "cirrus.h"
|
86 |
|
|
#include "rioioctl.h"
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
/*
|
92 |
|
|
** riopoll is called every clock tick. Once the /dev/rio device has been
|
93 |
|
|
** opened, and polldistributed( ) has been called, this routine is called
|
94 |
|
|
** every clock tick *by every cpu*. The 'interesting' piece of code that
|
95 |
|
|
** manipulates 'RIONumCpus' and 'RIOCpuCountdown' is used to fair-share
|
96 |
|
|
** the work between the CPUs. If there are 'N' cpus, then each poll time
|
97 |
|
|
** we increment a counter, modulo 'N-1'. When this counter is 0, we call
|
98 |
|
|
** the interrupt handler. This has the effect that polls are serviced
|
99 |
|
|
** by processor 'N', 'N-1', 'N-2', ... '0', round and round. Neat.
|
100 |
|
|
*/
|
101 |
|
|
void
|
102 |
|
|
riopoll(p)
|
103 |
|
|
struct rio_info * p;
|
104 |
|
|
{
|
105 |
|
|
int host;
|
106 |
|
|
|
107 |
|
|
/*
|
108 |
|
|
** Here's the deal. We try to fair share as much as possible amongst
|
109 |
|
|
** all the processors that are available. Since each processor
|
110 |
|
|
** should generate HZ ticks per second and since we only need HZ ticks
|
111 |
|
|
** in total for proper operation we simply attempt to cycle round each
|
112 |
|
|
** processor in turn, using RIOCpuCountdown to decide whether to call
|
113 |
|
|
** the interrupt routine. ( In fact the count zeroes when it reaches
|
114 |
|
|
** one less than the total number of processors - so e.g. on a two
|
115 |
|
|
** processor system RIOService will get called 2*HZ times per second. )
|
116 |
|
|
** this_cpu (cur_cpu()) tells us the number of the current processor
|
117 |
|
|
** as follows:
|
118 |
|
|
**
|
119 |
|
|
** 0 - default CPU
|
120 |
|
|
** 1 - first extra CPU
|
121 |
|
|
** 2 - second extra CPU
|
122 |
|
|
** etc.
|
123 |
|
|
*/
|
124 |
|
|
|
125 |
|
|
/*
|
126 |
|
|
** okay, we've got a cpu that hasn't had a go recently
|
127 |
|
|
** - lets check to see what needs doing.
|
128 |
|
|
*/
|
129 |
|
|
for ( host=0; host<p->RIONumHosts; host++ ) {
|
130 |
|
|
struct Host *HostP = &p->RIOHosts[host];
|
131 |
|
|
|
132 |
|
|
rio_spin_lock( &HostP->HostLock );
|
133 |
|
|
|
134 |
|
|
if ( ( (HostP->Flags & RUN_STATE) != RC_RUNNING ) ||
|
135 |
|
|
HostP->InIntr ) {
|
136 |
|
|
rio_spin_unlock (&HostP->HostLock);
|
137 |
|
|
continue;
|
138 |
|
|
}
|
139 |
|
|
|
140 |
|
|
if ( RWORD( HostP->ParmMapP->rup_intr ) ||
|
141 |
|
|
RWORD( HostP->ParmMapP->rx_intr ) ||
|
142 |
|
|
RWORD( HostP->ParmMapP->tx_intr ) ) {
|
143 |
|
|
HostP->InIntr = 1;
|
144 |
|
|
|
145 |
|
|
#ifdef FUTURE_RELEASE
|
146 |
|
|
if( HostP->Type == RIO_EISA )
|
147 |
|
|
INBZ( HostP->Slot, EISA_INTERRUPT_RESET );
|
148 |
|
|
else
|
149 |
|
|
#endif
|
150 |
|
|
WBYTE( HostP->ResetInt , 0xff );
|
151 |
|
|
|
152 |
|
|
rio_spin_lock(&HostP->HostLock);
|
153 |
|
|
|
154 |
|
|
p->_RIO_Polled++;
|
155 |
|
|
RIOServiceHost(p, HostP, 'p' );
|
156 |
|
|
rio_spin_lock( &HostP->HostLock);
|
157 |
|
|
HostP->InIntr = 0;
|
158 |
|
|
rio_spin_unlock (&HostP->HostLock);
|
159 |
|
|
}
|
160 |
|
|
}
|
161 |
|
|
rio_spin_unlock (&p->RIOIntrSem);
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
char *firstchars (char *p, int nch)
|
166 |
|
|
{
|
167 |
|
|
static char buf[2][128];
|
168 |
|
|
static int t=0;
|
169 |
|
|
t = ! t;
|
170 |
|
|
memcpy (buf[t], p, nch);
|
171 |
|
|
buf[t][nch] = 0;
|
172 |
|
|
return buf[t];
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
#define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask))
|
177 |
|
|
/* Enable and start the transmission of packets */
|
178 |
|
|
void
|
179 |
|
|
RIOTxEnable(en)
|
180 |
|
|
char * en;
|
181 |
|
|
{
|
182 |
|
|
struct Port * PortP;
|
183 |
|
|
struct rio_info *p;
|
184 |
|
|
struct tty_struct* tty;
|
185 |
|
|
int c;
|
186 |
|
|
struct PKT * PacketP;
|
187 |
|
|
unsigned long flags;
|
188 |
|
|
|
189 |
|
|
PortP = (struct Port *)en;
|
190 |
|
|
p = (struct rio_info *)PortP->p;
|
191 |
|
|
tty = PortP->gs.tty;
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "tx port %d: %d chars queued.\n",
|
195 |
|
|
PortP->PortNum, PortP->gs.xmit_cnt);
|
196 |
|
|
|
197 |
|
|
if (!PortP->gs.xmit_cnt) return;
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
/* This routine is an order of magnitude simpler than the specialix
|
201 |
|
|
version. One of the disadvantages is that this version will send
|
202 |
|
|
an incomplete packet (usually 64 bytes instead of 72) once for
|
203 |
|
|
every 4k worth of data. Let's just say that this won't influence
|
204 |
|
|
performance significantly..... */
|
205 |
|
|
|
206 |
|
|
rio_spin_lock_irqsave(&PortP->portSem, flags);
|
207 |
|
|
|
208 |
|
|
while (can_add_transmit( &PacketP, PortP )) {
|
209 |
|
|
c = PortP->gs.xmit_cnt;
|
210 |
|
|
if (c > PKT_MAX_DATA_LEN) c = PKT_MAX_DATA_LEN;
|
211 |
|
|
|
212 |
|
|
/* Don't copy past the end of the source buffer */
|
213 |
|
|
if (c > SERIAL_XMIT_SIZE - PortP->gs.xmit_tail)
|
214 |
|
|
c = SERIAL_XMIT_SIZE - PortP->gs.xmit_tail;
|
215 |
|
|
|
216 |
|
|
{ int t;
|
217 |
|
|
t = (c > 10)?10:c;
|
218 |
|
|
|
219 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "rio: tx port %d: copying %d chars: %s - %s\n",
|
220 |
|
|
PortP->PortNum, c,
|
221 |
|
|
firstchars (PortP->gs.xmit_buf + PortP->gs.xmit_tail , t),
|
222 |
|
|
firstchars (PortP->gs.xmit_buf + PortP->gs.xmit_tail + c-t, t));
|
223 |
|
|
}
|
224 |
|
|
/* If for one reason or another, we can't copy more data,
|
225 |
|
|
we're done! */
|
226 |
|
|
if (c == 0) break;
|
227 |
|
|
|
228 |
|
|
rio_memcpy_toio (PortP->HostP->Caddr, (caddr_t)PacketP->data,
|
229 |
|
|
PortP->gs.xmit_buf + PortP->gs.xmit_tail, c);
|
230 |
|
|
/* udelay (1); */
|
231 |
|
|
|
232 |
|
|
writeb (c, &(PacketP->len));
|
233 |
|
|
if (!( PortP->State & RIO_DELETED ) ) {
|
234 |
|
|
add_transmit ( PortP );
|
235 |
|
|
/*
|
236 |
|
|
** Count chars tx'd for port statistics reporting
|
237 |
|
|
*/
|
238 |
|
|
if ( PortP->statsGather )
|
239 |
|
|
PortP->txchars += c;
|
240 |
|
|
}
|
241 |
|
|
PortP->gs.xmit_tail = (PortP->gs.xmit_tail + c) & (SERIAL_XMIT_SIZE-1);
|
242 |
|
|
PortP->gs.xmit_cnt -= c;
|
243 |
|
|
}
|
244 |
|
|
|
245 |
|
|
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
|
246 |
|
|
|
247 |
|
|
if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2*PKT_MAX_DATA_LEN)) {
|
248 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "Waking up.... ldisc:%d (%d/%d)....",
|
249 |
|
|
(int)(PortP->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)),
|
250 |
|
|
PortP->gs.wakeup_chars, PortP->gs.xmit_cnt);
|
251 |
|
|
if ((PortP->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
|
252 |
|
|
PortP->gs.tty->ldisc.write_wakeup)
|
253 |
|
|
(PortP->gs.tty->ldisc.write_wakeup)(PortP->gs.tty);
|
254 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "(%d/%d)\n",
|
255 |
|
|
PortP->gs.wakeup_chars, PortP->gs.xmit_cnt);
|
256 |
|
|
wake_up_interruptible(&PortP->gs.tty->write_wait);
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
}
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
/*
|
263 |
|
|
** When a real-life interrupt comes in here, we try to find out
|
264 |
|
|
** which host card it belongs to, and then service only that host
|
265 |
|
|
** Notice the cunning way that, once we've found a candidate, we
|
266 |
|
|
** continue just in case we are sharing interrupts.
|
267 |
|
|
*/
|
268 |
|
|
void
|
269 |
|
|
riointr(p)
|
270 |
|
|
struct rio_info * p;
|
271 |
|
|
{
|
272 |
|
|
int host;
|
273 |
|
|
|
274 |
|
|
for ( host=0; host<p->RIONumHosts; host++ ) {
|
275 |
|
|
struct Host *HostP = &p->RIOHosts[host];
|
276 |
|
|
|
277 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "riointr() doing host %d type %d\n", host, HostP->Type);
|
278 |
|
|
|
279 |
|
|
switch( HostP->Type ) {
|
280 |
|
|
case RIO_AT:
|
281 |
|
|
case RIO_MCA:
|
282 |
|
|
case RIO_PCI:
|
283 |
|
|
rio_spin_lock(&HostP->HostLock);
|
284 |
|
|
WBYTE(HostP->ResetInt , 0xff);
|
285 |
|
|
if ( !HostP->InIntr ) {
|
286 |
|
|
HostP->InIntr = 1;
|
287 |
|
|
rio_spin_unlock (&HostP->HostLock);
|
288 |
|
|
p->_RIO_Interrupted++;
|
289 |
|
|
RIOServiceHost(p, HostP, 'i');
|
290 |
|
|
rio_spin_lock(&HostP->HostLock);
|
291 |
|
|
HostP->InIntr = 0;
|
292 |
|
|
}
|
293 |
|
|
rio_spin_unlock(&HostP->HostLock);
|
294 |
|
|
break;
|
295 |
|
|
#ifdef FUTURE_RELEASE
|
296 |
|
|
case RIO_EISA:
|
297 |
|
|
if ( ivec == HostP->Ivec )
|
298 |
|
|
{
|
299 |
|
|
OldSpl = LOCKB( &HostP->HostLock );
|
300 |
|
|
INBZ( HostP->Slot, EISA_INTERRUPT_RESET );
|
301 |
|
|
if ( !HostP->InIntr )
|
302 |
|
|
{
|
303 |
|
|
HostP->InIntr = 1;
|
304 |
|
|
UNLOCKB( &HostP->HostLock, OldSpl );
|
305 |
|
|
if ( this_cpu < RIO_CPU_LIMIT )
|
306 |
|
|
{
|
307 |
|
|
int intrSpl = LOCKB( &RIOIntrLock );
|
308 |
|
|
UNLOCKB( &RIOIntrLock, intrSpl );
|
309 |
|
|
}
|
310 |
|
|
p->_RIO_Interrupted++;
|
311 |
|
|
RIOServiceHost( HostP, 'i' );
|
312 |
|
|
OldSpl = LOCKB( &HostP->HostLock );
|
313 |
|
|
HostP->InIntr = 0;
|
314 |
|
|
}
|
315 |
|
|
UNLOCKB( &HostP->HostLock, OldSpl );
|
316 |
|
|
done++;
|
317 |
|
|
}
|
318 |
|
|
break;
|
319 |
|
|
#endif
|
320 |
|
|
}
|
321 |
|
|
|
322 |
|
|
HostP->IntSrvDone++;
|
323 |
|
|
}
|
324 |
|
|
|
325 |
|
|
#ifdef FUTURE_RELEASE
|
326 |
|
|
if ( !done )
|
327 |
|
|
{
|
328 |
|
|
cmn_err( CE_WARN, "RIO: Interrupt received with vector 0x%x\n", ivec );
|
329 |
|
|
cmn_err( CE_CONT, " Valid vectors are:\n");
|
330 |
|
|
for ( host=0; host<RIONumHosts; host++ )
|
331 |
|
|
{
|
332 |
|
|
switch( RIOHosts[host].Type )
|
333 |
|
|
{
|
334 |
|
|
case RIO_AT:
|
335 |
|
|
case RIO_MCA:
|
336 |
|
|
case RIO_EISA:
|
337 |
|
|
cmn_err( CE_CONT, "0x%x ", RIOHosts[host].Ivec );
|
338 |
|
|
break;
|
339 |
|
|
case RIO_PCI:
|
340 |
|
|
cmn_err( CE_CONT, "0x%x ", get_intr_arg( RIOHosts[host].PciDevInfo.busnum, IDIST_PCI_IRQ( RIOHosts[host].PciDevInfo.slotnum, RIOHosts[host].PciDevInfo.funcnum ) ));
|
341 |
|
|
break;
|
342 |
|
|
}
|
343 |
|
|
}
|
344 |
|
|
cmn_err( CE_CONT, "\n" );
|
345 |
|
|
}
|
346 |
|
|
#endif
|
347 |
|
|
}
|
348 |
|
|
|
349 |
|
|
/*
|
350 |
|
|
** RIO Host Service routine. Does all the work traditionally associated with an
|
351 |
|
|
** interrupt.
|
352 |
|
|
*/
|
353 |
|
|
static int RupIntr;
|
354 |
|
|
static int RxIntr;
|
355 |
|
|
static int TxIntr;
|
356 |
|
|
void
|
357 |
|
|
RIOServiceHost(p, HostP, From)
|
358 |
|
|
struct rio_info * p;
|
359 |
|
|
struct Host *HostP;
|
360 |
|
|
int From;
|
361 |
|
|
{
|
362 |
|
|
rio_spin_lock (&HostP->HostLock);
|
363 |
|
|
if ( (HostP->Flags & RUN_STATE) != RC_RUNNING ) {
|
364 |
|
|
static int t =0;
|
365 |
|
|
rio_spin_unlock (&HostP->HostLock);
|
366 |
|
|
if ((t++ % 200) == 0)
|
367 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "Interrupt but host not running. flags=%x.\n", (int)HostP->Flags);
|
368 |
|
|
return;
|
369 |
|
|
}
|
370 |
|
|
rio_spin_unlock (&HostP->HostLock);
|
371 |
|
|
|
372 |
|
|
if ( RWORD( HostP->ParmMapP->rup_intr ) ) {
|
373 |
|
|
WWORD( HostP->ParmMapP->rup_intr , 0 );
|
374 |
|
|
p->RIORupCount++;
|
375 |
|
|
RupIntr++;
|
376 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "rio: RUP interrupt on host %d\n", HostP-p->RIOHosts);
|
377 |
|
|
RIOPollHostCommands(p, HostP );
|
378 |
|
|
}
|
379 |
|
|
|
380 |
|
|
if ( RWORD( HostP->ParmMapP->rx_intr ) ) {
|
381 |
|
|
int port;
|
382 |
|
|
|
383 |
|
|
WWORD( HostP->ParmMapP->rx_intr , 0 );
|
384 |
|
|
p->RIORxCount++;
|
385 |
|
|
RxIntr++;
|
386 |
|
|
|
387 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "rio: RX interrupt on host %d\n", HostP-p->RIOHosts);
|
388 |
|
|
/*
|
389 |
|
|
** Loop through every port. If the port is mapped into
|
390 |
|
|
** the system ( i.e. has /dev/ttyXXXX associated ) then it is
|
391 |
|
|
** worth checking. If the port isn't open, grab any packets
|
392 |
|
|
** hanging on its receive queue and stuff them on the free
|
393 |
|
|
** list; check for commands on the way.
|
394 |
|
|
*/
|
395 |
|
|
for ( port=p->RIOFirstPortsBooted;
|
396 |
|
|
port<p->RIOLastPortsBooted+PORTS_PER_RTA; port++ ) {
|
397 |
|
|
struct Port *PortP = p->RIOPortp[port];
|
398 |
|
|
struct tty_struct *ttyP;
|
399 |
|
|
struct PKT *PacketP;
|
400 |
|
|
|
401 |
|
|
/*
|
402 |
|
|
** not mapped in - most of the RIOPortp[] information
|
403 |
|
|
** has not been set up!
|
404 |
|
|
** Optimise: ports come in bundles of eight.
|
405 |
|
|
*/
|
406 |
|
|
if ( !PortP->Mapped ) {
|
407 |
|
|
port += 7;
|
408 |
|
|
continue; /* with the next port */
|
409 |
|
|
}
|
410 |
|
|
|
411 |
|
|
/*
|
412 |
|
|
** If the host board isn't THIS host board, check the next one.
|
413 |
|
|
** optimise: ports come in bundles of eight.
|
414 |
|
|
*/
|
415 |
|
|
if ( PortP->HostP != HostP ) {
|
416 |
|
|
port += 7;
|
417 |
|
|
continue;
|
418 |
|
|
}
|
419 |
|
|
|
420 |
|
|
/*
|
421 |
|
|
** Let us see - is the port open? If not, then don't service it.
|
422 |
|
|
*/
|
423 |
|
|
if ( !( PortP->PortState & PORT_ISOPEN ) ) {
|
424 |
|
|
continue;
|
425 |
|
|
}
|
426 |
|
|
|
427 |
|
|
/*
|
428 |
|
|
** find corresponding tty structure. The process of mapping
|
429 |
|
|
** the ports puts these here.
|
430 |
|
|
*/
|
431 |
|
|
ttyP = PortP->gs.tty;
|
432 |
|
|
|
433 |
|
|
/*
|
434 |
|
|
** Lock the port before we begin working on it.
|
435 |
|
|
*/
|
436 |
|
|
rio_spin_lock(&PortP->portSem);
|
437 |
|
|
|
438 |
|
|
/*
|
439 |
|
|
** Process received data if there is any.
|
440 |
|
|
*/
|
441 |
|
|
if ( can_remove_receive( &PacketP, PortP ) )
|
442 |
|
|
RIOReceive(p, PortP);
|
443 |
|
|
|
444 |
|
|
/*
|
445 |
|
|
** If there is no data left to be read from the port, and
|
446 |
|
|
** it's handshake bit is set, then we must clear the handshake,
|
447 |
|
|
** so that that downstream RTA is re-enabled.
|
448 |
|
|
*/
|
449 |
|
|
if ( !can_remove_receive( &PacketP, PortP ) &&
|
450 |
|
|
( RWORD( PortP->PhbP->handshake )==PHB_HANDSHAKE_SET ) ) {
|
451 |
|
|
/*
|
452 |
|
|
** MAGIC! ( Basically, handshake the RX buffer, so that
|
453 |
|
|
** the RTAs upstream can be re-enabled. )
|
454 |
|
|
*/
|
455 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "Set RX handshake bit\n");
|
456 |
|
|
WWORD( PortP->PhbP->handshake,
|
457 |
|
|
PHB_HANDSHAKE_SET|PHB_HANDSHAKE_RESET );
|
458 |
|
|
}
|
459 |
|
|
rio_spin_unlock(&PortP->portSem);
|
460 |
|
|
}
|
461 |
|
|
}
|
462 |
|
|
|
463 |
|
|
if ( RWORD( HostP->ParmMapP->tx_intr ) ) {
|
464 |
|
|
int port;
|
465 |
|
|
|
466 |
|
|
WWORD( HostP->ParmMapP->tx_intr , 0);
|
467 |
|
|
|
468 |
|
|
p->RIOTxCount++;
|
469 |
|
|
TxIntr++;
|
470 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "rio: TX interrupt on host %d\n", HostP-p->RIOHosts);
|
471 |
|
|
|
472 |
|
|
/*
|
473 |
|
|
** Loop through every port.
|
474 |
|
|
** If the port is mapped into the system ( i.e. has /dev/ttyXXXX
|
475 |
|
|
** associated ) then it is worth checking.
|
476 |
|
|
*/
|
477 |
|
|
for ( port=p->RIOFirstPortsBooted;
|
478 |
|
|
port<p->RIOLastPortsBooted+PORTS_PER_RTA; port++ ) {
|
479 |
|
|
struct Port *PortP = p->RIOPortp[port];
|
480 |
|
|
struct tty_struct *ttyP;
|
481 |
|
|
struct PKT *PacketP;
|
482 |
|
|
|
483 |
|
|
/*
|
484 |
|
|
** not mapped in - most of the RIOPortp[] information
|
485 |
|
|
** has not been set up!
|
486 |
|
|
*/
|
487 |
|
|
if ( !PortP->Mapped ) {
|
488 |
|
|
port += 7;
|
489 |
|
|
continue; /* with the next port */
|
490 |
|
|
}
|
491 |
|
|
|
492 |
|
|
/*
|
493 |
|
|
** If the host board isn't running, then its data structures
|
494 |
|
|
** are no use to us - continue quietly.
|
495 |
|
|
*/
|
496 |
|
|
if ( PortP->HostP != HostP ) {
|
497 |
|
|
port += 7;
|
498 |
|
|
continue; /* with the next port */
|
499 |
|
|
}
|
500 |
|
|
|
501 |
|
|
/*
|
502 |
|
|
** Let us see - is the port open? If not, then don't service it.
|
503 |
|
|
*/
|
504 |
|
|
if ( !( PortP->PortState & PORT_ISOPEN ) ) {
|
505 |
|
|
continue;
|
506 |
|
|
}
|
507 |
|
|
|
508 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "rio: Looking into port %d.\n", port);
|
509 |
|
|
/*
|
510 |
|
|
** Lock the port before we begin working on it.
|
511 |
|
|
*/
|
512 |
|
|
rio_spin_lock(&PortP->portSem);
|
513 |
|
|
|
514 |
|
|
/*
|
515 |
|
|
** If we can't add anything to the transmit queue, then
|
516 |
|
|
** we need do none of this processing.
|
517 |
|
|
*/
|
518 |
|
|
if ( !can_add_transmit( &PacketP, PortP ) ) {
|
519 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "Can't add to port, so skipping.\n");
|
520 |
|
|
rio_spin_unlock(&PortP->portSem);
|
521 |
|
|
continue;
|
522 |
|
|
}
|
523 |
|
|
|
524 |
|
|
/*
|
525 |
|
|
** find corresponding tty structure. The process of mapping
|
526 |
|
|
** the ports puts these here.
|
527 |
|
|
*/
|
528 |
|
|
ttyP = PortP->gs.tty;
|
529 |
|
|
/* If ttyP is NULL, the port is getting closed. Forget about it. */
|
530 |
|
|
if (!ttyP) {
|
531 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "no tty, so skipping.\n");
|
532 |
|
|
rio_spin_unlock(&PortP->portSem);
|
533 |
|
|
continue;
|
534 |
|
|
}
|
535 |
|
|
/*
|
536 |
|
|
** If there is more room available we start up the transmit
|
537 |
|
|
** data process again. This can be direct I/O, if the cookmode
|
538 |
|
|
** is set to COOK_RAW or COOK_MEDIUM, or will be a call to the
|
539 |
|
|
** riotproc( T_OUTPUT ) if we are in COOK_WELL mode, to fetch
|
540 |
|
|
** characters via the line discipline. We must always call
|
541 |
|
|
** the line discipline,
|
542 |
|
|
** so that user input characters can be echoed correctly.
|
543 |
|
|
**
|
544 |
|
|
** ++++ Update +++++
|
545 |
|
|
** With the advent of double buffering, we now see if
|
546 |
|
|
** TxBufferOut-In is non-zero. If so, then we copy a packet
|
547 |
|
|
** to the output place, and set it going. If this empties
|
548 |
|
|
** the buffer, then we must issue a wakeup( ) on OUT.
|
549 |
|
|
** If it frees space in the buffer then we must issue
|
550 |
|
|
** a wakeup( ) on IN.
|
551 |
|
|
**
|
552 |
|
|
** ++++ Extra! Extra! If PortP->WflushFlag is set, then we
|
553 |
|
|
** have to send a WFLUSH command down the PHB, to mark the
|
554 |
|
|
** end point of a WFLUSH. We also need to clear out any
|
555 |
|
|
** data from the double buffer! ( note that WflushFlag is a
|
556 |
|
|
** *count* of the number of WFLUSH commands outstanding! )
|
557 |
|
|
**
|
558 |
|
|
** ++++ And there's more!
|
559 |
|
|
** If an RTA is powered off, then on again, and rebooted,
|
560 |
|
|
** whilst it has ports open, then we need to re-open the ports.
|
561 |
|
|
** ( reasonable enough ). We can't do this when we spot the
|
562 |
|
|
** re-boot, in interrupt time, because the queue is probably
|
563 |
|
|
** full. So, when we come in here, we need to test if any
|
564 |
|
|
** ports are in this condition, and re-open the port before
|
565 |
|
|
** we try to send any more data to it. Now, the re-booted
|
566 |
|
|
** RTA will be discarding packets from the PHB until it
|
567 |
|
|
** receives this open packet, but don't worry tooo much
|
568 |
|
|
** about that. The one thing that is interesting is the
|
569 |
|
|
** combination of this effect and the WFLUSH effect!
|
570 |
|
|
*/
|
571 |
|
|
/* For now don't handle RTA reboots. -- REW.
|
572 |
|
|
Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */
|
573 |
|
|
if ( PortP->MagicFlags ) {
|
574 |
|
|
#if 1
|
575 |
|
|
if ( PortP->MagicFlags & MAGIC_REBOOT ) {
|
576 |
|
|
/*
|
577 |
|
|
** well, the RTA has been rebooted, and there is room
|
578 |
|
|
** on its queue to add the open packet that is required.
|
579 |
|
|
**
|
580 |
|
|
** The messy part of this line is trying to decide if
|
581 |
|
|
** we need to call the Param function as a tty or as
|
582 |
|
|
** a modem.
|
583 |
|
|
** DONT USE CLOCAL AS A TEST FOR THIS!
|
584 |
|
|
**
|
585 |
|
|
** If we can't param the port, then move on to the
|
586 |
|
|
** next port.
|
587 |
|
|
*/
|
588 |
|
|
PortP->InUse = NOT_INUSE;
|
589 |
|
|
|
590 |
|
|
rio_spin_unlock(&PortP->portSem);
|
591 |
|
|
if ( RIOParam(PortP, OPEN, ((PortP->Cor2Copy &
|
592 |
|
|
(COR2_RTSFLOW|COR2_CTSFLOW ) )==
|
593 |
|
|
(COR2_RTSFLOW|COR2_CTSFLOW ) ) ?
|
594 |
|
|
TRUE : FALSE, DONT_SLEEP ) == RIO_FAIL ) {
|
595 |
|
|
continue; /* with next port */
|
596 |
|
|
}
|
597 |
|
|
rio_spin_lock(&PortP->portSem);
|
598 |
|
|
PortP->MagicFlags &= ~MAGIC_REBOOT;
|
599 |
|
|
}
|
600 |
|
|
#endif
|
601 |
|
|
|
602 |
|
|
/*
|
603 |
|
|
** As mentioned above, this is a tacky hack to cope
|
604 |
|
|
** with WFLUSH
|
605 |
|
|
*/
|
606 |
|
|
if ( PortP->WflushFlag ) {
|
607 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "Want to WFLUSH mark this port\n");
|
608 |
|
|
|
609 |
|
|
if ( PortP->InUse )
|
610 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "FAILS - PORT IS IN USE\n");
|
611 |
|
|
}
|
612 |
|
|
|
613 |
|
|
while ( PortP->WflushFlag &&
|
614 |
|
|
can_add_transmit( &PacketP, PortP ) &&
|
615 |
|
|
( PortP->InUse == NOT_INUSE ) ) {
|
616 |
|
|
int p;
|
617 |
|
|
struct PktCmd *PktCmdP;
|
618 |
|
|
|
619 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "Add WFLUSH marker to data queue\n");
|
620 |
|
|
/*
|
621 |
|
|
** make it look just like a WFLUSH command
|
622 |
|
|
*/
|
623 |
|
|
PktCmdP = ( struct PktCmd * )&PacketP->data[0];
|
624 |
|
|
|
625 |
|
|
WBYTE( PktCmdP->Command , WFLUSH );
|
626 |
|
|
|
627 |
|
|
p = PortP->HostPort % ( ushort )PORTS_PER_RTA;
|
628 |
|
|
|
629 |
|
|
/*
|
630 |
|
|
** If second block of ports for 16 port RTA, add 8
|
631 |
|
|
** to index 8-15.
|
632 |
|
|
*/
|
633 |
|
|
if ( PortP->SecondBlock )
|
634 |
|
|
p += PORTS_PER_RTA;
|
635 |
|
|
|
636 |
|
|
WBYTE( PktCmdP->PhbNum, p );
|
637 |
|
|
|
638 |
|
|
/*
|
639 |
|
|
** to make debuggery easier
|
640 |
|
|
*/
|
641 |
|
|
WBYTE( PacketP->data[ 2], 'W' );
|
642 |
|
|
WBYTE( PacketP->data[ 3], 'F' );
|
643 |
|
|
WBYTE( PacketP->data[ 4], 'L' );
|
644 |
|
|
WBYTE( PacketP->data[ 5], 'U' );
|
645 |
|
|
WBYTE( PacketP->data[ 6], 'S' );
|
646 |
|
|
WBYTE( PacketP->data[ 7], 'H' );
|
647 |
|
|
WBYTE( PacketP->data[ 8], ' ' );
|
648 |
|
|
WBYTE( PacketP->data[ 9], '0'+PortP->WflushFlag );
|
649 |
|
|
WBYTE( PacketP->data[10], ' ' );
|
650 |
|
|
WBYTE( PacketP->data[11], ' ' );
|
651 |
|
|
WBYTE( PacketP->data[12], '\0' );
|
652 |
|
|
|
653 |
|
|
/*
|
654 |
|
|
** its two bytes long!
|
655 |
|
|
*/
|
656 |
|
|
WBYTE( PacketP->len , PKT_CMD_BIT | 2 );
|
657 |
|
|
|
658 |
|
|
/*
|
659 |
|
|
** queue it!
|
660 |
|
|
*/
|
661 |
|
|
if ( !( PortP->State & RIO_DELETED ) ) {
|
662 |
|
|
add_transmit( PortP );
|
663 |
|
|
/*
|
664 |
|
|
** Count chars tx'd for port statistics reporting
|
665 |
|
|
*/
|
666 |
|
|
if ( PortP->statsGather )
|
667 |
|
|
PortP->txchars += 2;
|
668 |
|
|
}
|
669 |
|
|
|
670 |
|
|
if ( --( PortP->WflushFlag ) == 0 ) {
|
671 |
|
|
PortP->MagicFlags &= ~MAGIC_FLUSH;
|
672 |
|
|
}
|
673 |
|
|
|
674 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "Wflush count now stands at %d\n",
|
675 |
|
|
PortP->WflushFlag);
|
676 |
|
|
}
|
677 |
|
|
if ( PortP->MagicFlags & MORE_OUTPUT_EYGOR ) {
|
678 |
|
|
if ( PortP->MagicFlags & MAGIC_FLUSH ) {
|
679 |
|
|
PortP->MagicFlags |= MORE_OUTPUT_EYGOR;
|
680 |
|
|
}
|
681 |
|
|
else {
|
682 |
|
|
if ( !can_add_transmit( &PacketP, PortP ) ) {
|
683 |
|
|
rio_spin_unlock(&PortP->portSem);
|
684 |
|
|
continue;
|
685 |
|
|
}
|
686 |
|
|
rio_spin_unlock(&PortP->portSem);
|
687 |
|
|
RIOTxEnable((char *)PortP);
|
688 |
|
|
rio_spin_lock(&PortP->portSem);
|
689 |
|
|
PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR;
|
690 |
|
|
}
|
691 |
|
|
}
|
692 |
|
|
}
|
693 |
|
|
|
694 |
|
|
|
695 |
|
|
/*
|
696 |
|
|
** If we can't add anything to the transmit queue, then
|
697 |
|
|
** we need do none of the remaining processing.
|
698 |
|
|
*/
|
699 |
|
|
if (!can_add_transmit( &PacketP, PortP ) ) {
|
700 |
|
|
rio_spin_unlock(&PortP->portSem);
|
701 |
|
|
continue;
|
702 |
|
|
}
|
703 |
|
|
|
704 |
|
|
rio_spin_unlock(&PortP->portSem);
|
705 |
|
|
RIOTxEnable((char *)PortP);
|
706 |
|
|
}
|
707 |
|
|
}
|
708 |
|
|
}
|
709 |
|
|
|
710 |
|
|
/*
|
711 |
|
|
** Routine for handling received data for clist drivers.
|
712 |
|
|
** NB: Called with the tty locked. The spl from the lockb( ) is passed.
|
713 |
|
|
** we return the ttySpl level that we re-locked at.
|
714 |
|
|
*/
|
715 |
|
|
void
|
716 |
|
|
RIOReceive(p, PortP)
|
717 |
|
|
struct rio_info * p;
|
718 |
|
|
struct Port * PortP;
|
719 |
|
|
{
|
720 |
|
|
struct tty_struct *TtyP;
|
721 |
|
|
register ushort transCount;
|
722 |
|
|
struct PKT *PacketP;
|
723 |
|
|
register uint DataCnt;
|
724 |
|
|
uchar * ptr;
|
725 |
|
|
int copied =0;
|
726 |
|
|
|
727 |
|
|
static int intCount, RxIntCnt;
|
728 |
|
|
|
729 |
|
|
/*
|
730 |
|
|
** The receive data process is to remove packets from the
|
731 |
|
|
** PHB until there aren't any more or the current cblock
|
732 |
|
|
** is full. When this occurs, there will be some left over
|
733 |
|
|
** data in the packet, that we must do something with.
|
734 |
|
|
** As we haven't unhooked the packet from the read list
|
735 |
|
|
** yet, we can just leave the packet there, having first
|
736 |
|
|
** made a note of how far we got. This means that we need
|
737 |
|
|
** a pointer per port saying where we start taking the
|
738 |
|
|
** data from - this will normally be zero, but when we
|
739 |
|
|
** run out of space it will be set to the offset of the
|
740 |
|
|
** next byte to copy from the packet data area. The packet
|
741 |
|
|
** length field is decremented by the number of bytes that
|
742 |
|
|
** we succesfully removed from the packet. When this reaches
|
743 |
|
|
** zero, we reset the offset pointer to be zero, and free
|
744 |
|
|
** the packet from the front of the queue.
|
745 |
|
|
*/
|
746 |
|
|
|
747 |
|
|
intCount++;
|
748 |
|
|
|
749 |
|
|
TtyP = PortP->gs.tty;
|
750 |
|
|
if (!TtyP) {
|
751 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "RIOReceive: tty is null. \n");
|
752 |
|
|
return;
|
753 |
|
|
}
|
754 |
|
|
|
755 |
|
|
if (PortP->State & RIO_THROTTLE_RX) {
|
756 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "RIOReceive: Throttled. Can't handle more input.\n");
|
757 |
|
|
return;
|
758 |
|
|
}
|
759 |
|
|
|
760 |
|
|
if ( PortP->State & RIO_DELETED )
|
761 |
|
|
{
|
762 |
|
|
while ( can_remove_receive( &PacketP, PortP ) )
|
763 |
|
|
{
|
764 |
|
|
remove_receive( PortP );
|
765 |
|
|
put_free_end( PortP->HostP, PacketP );
|
766 |
|
|
}
|
767 |
|
|
}
|
768 |
|
|
else
|
769 |
|
|
{
|
770 |
|
|
/*
|
771 |
|
|
** loop, just so long as:
|
772 |
|
|
** i ) there's some data ( i.e. can_remove_receive )
|
773 |
|
|
** ii ) we haven't been blocked
|
774 |
|
|
** iii ) there's somewhere to put the data
|
775 |
|
|
** iv ) we haven't outstayed our welcome
|
776 |
|
|
*/
|
777 |
|
|
transCount = 1;
|
778 |
|
|
while ( can_remove_receive(&PacketP, PortP)
|
779 |
|
|
&& transCount)
|
780 |
|
|
{
|
781 |
|
|
#ifdef STATS
|
782 |
|
|
PortP->Stat.RxIntCnt++;
|
783 |
|
|
#endif /* STATS */
|
784 |
|
|
RxIntCnt++;
|
785 |
|
|
|
786 |
|
|
/*
|
787 |
|
|
** check that it is not a command!
|
788 |
|
|
*/
|
789 |
|
|
if ( PacketP->len & PKT_CMD_BIT ) {
|
790 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "RIO: unexpected command packet received on PHB\n");
|
791 |
|
|
/* rio_dprint(RIO_DEBUG_INTR, (" sysport = %d\n", p->RIOPortp->PortNum)); */
|
792 |
|
|
rio_dprintk (RIO_DEBUG_INTR, " dest_unit = %d\n", PacketP->dest_unit);
|
793 |
|
|
rio_dprintk (RIO_DEBUG_INTR, " dest_port = %d\n", PacketP->dest_port);
|
794 |
|
|
rio_dprintk (RIO_DEBUG_INTR, " src_unit = %d\n", PacketP->src_unit);
|
795 |
|
|
rio_dprintk (RIO_DEBUG_INTR, " src_port = %d\n", PacketP->src_port);
|
796 |
|
|
rio_dprintk (RIO_DEBUG_INTR, " len = %d\n", PacketP->len);
|
797 |
|
|
rio_dprintk (RIO_DEBUG_INTR, " control = %d\n", PacketP->control);
|
798 |
|
|
rio_dprintk (RIO_DEBUG_INTR, " csum = %d\n", PacketP->csum);
|
799 |
|
|
rio_dprintk (RIO_DEBUG_INTR, " data bytes: ");
|
800 |
|
|
for ( DataCnt=0; DataCnt<PKT_MAX_DATA_LEN; DataCnt++ )
|
801 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "%d\n", PacketP->data[DataCnt]);
|
802 |
|
|
remove_receive( PortP );
|
803 |
|
|
put_free_end( PortP->HostP, PacketP );
|
804 |
|
|
continue; /* with next packet */
|
805 |
|
|
}
|
806 |
|
|
|
807 |
|
|
/*
|
808 |
|
|
** How many characters can we move 'upstream' ?
|
809 |
|
|
**
|
810 |
|
|
** Determine the minimum of the amount of data
|
811 |
|
|
** available and the amount of space in which to
|
812 |
|
|
** put it.
|
813 |
|
|
**
|
814 |
|
|
** 1. Get the packet length by masking 'len'
|
815 |
|
|
** for only the length bits.
|
816 |
|
|
** 2. Available space is [buffer size] - [space used]
|
817 |
|
|
**
|
818 |
|
|
** Transfer count is the minimum of packet length
|
819 |
|
|
** and available space.
|
820 |
|
|
*/
|
821 |
|
|
|
822 |
|
|
transCount = min_t(unsigned int, PacketP->len & PKT_LEN_MASK,
|
823 |
|
|
TTY_FLIPBUF_SIZE - TtyP->flip.count);
|
824 |
|
|
rio_dprintk (RIO_DEBUG_REC, "port %d: Copy %d bytes\n",
|
825 |
|
|
PortP->PortNum, transCount);
|
826 |
|
|
/*
|
827 |
|
|
** To use the following 'kkprintfs' for debugging - change the '#undef'
|
828 |
|
|
** to '#define', (this is the only place ___DEBUG_IT___ occurs in the
|
829 |
|
|
** driver).
|
830 |
|
|
*/
|
831 |
|
|
#undef ___DEBUG_IT___
|
832 |
|
|
#ifdef ___DEBUG_IT___
|
833 |
|
|
kkprintf("I:%d R:%d P:%d Q:%d C:%d F:%x ",
|
834 |
|
|
intCount,
|
835 |
|
|
RxIntCnt,
|
836 |
|
|
PortP->PortNum,
|
837 |
|
|
TtyP->rxqueue.count,
|
838 |
|
|
transCount,
|
839 |
|
|
TtyP->flags );
|
840 |
|
|
#endif
|
841 |
|
|
ptr = (uchar *) PacketP->data + PortP->RxDataStart;
|
842 |
|
|
|
843 |
|
|
rio_memcpy_fromio (TtyP->flip.char_buf_ptr, ptr, transCount);
|
844 |
|
|
memset(TtyP->flip.flag_buf_ptr, TTY_NORMAL, transCount);
|
845 |
|
|
|
846 |
|
|
#ifdef STATS
|
847 |
|
|
/*
|
848 |
|
|
** keep a count for statistical purposes
|
849 |
|
|
*/
|
850 |
|
|
PortP->Stat.RxCharCnt += transCount;
|
851 |
|
|
#endif
|
852 |
|
|
PortP->RxDataStart += transCount;
|
853 |
|
|
PacketP->len -= transCount;
|
854 |
|
|
copied += transCount;
|
855 |
|
|
TtyP->flip.count += transCount;
|
856 |
|
|
TtyP->flip.char_buf_ptr += transCount;
|
857 |
|
|
TtyP->flip.flag_buf_ptr += transCount;
|
858 |
|
|
|
859 |
|
|
|
860 |
|
|
#ifdef ___DEBUG_IT___
|
861 |
|
|
kkprintf("T:%d L:%d\n", DataCnt, PacketP->len );
|
862 |
|
|
#endif
|
863 |
|
|
|
864 |
|
|
if ( PacketP->len == 0 )
|
865 |
|
|
{
|
866 |
|
|
/*
|
867 |
|
|
** If we have emptied the packet, then we can
|
868 |
|
|
** free it, and reset the start pointer for
|
869 |
|
|
** the next packet.
|
870 |
|
|
*/
|
871 |
|
|
remove_receive( PortP );
|
872 |
|
|
put_free_end( PortP->HostP, PacketP );
|
873 |
|
|
PortP->RxDataStart = 0;
|
874 |
|
|
#ifdef STATS
|
875 |
|
|
/*
|
876 |
|
|
** more lies ( oops, I mean statistics )
|
877 |
|
|
*/
|
878 |
|
|
PortP->Stat.RxPktCnt++;
|
879 |
|
|
#endif /* STATS */
|
880 |
|
|
}
|
881 |
|
|
}
|
882 |
|
|
}
|
883 |
|
|
if (copied) {
|
884 |
|
|
rio_dprintk (RIO_DEBUG_REC, "port %d: pushing tty flip buffer: %d total bytes copied.\n", PortP->PortNum, copied);
|
885 |
|
|
tty_flip_buffer_push (TtyP);
|
886 |
|
|
}
|
887 |
|
|
|
888 |
|
|
return;
|
889 |
|
|
}
|
890 |
|
|
|
891 |
|
|
#ifdef FUTURE_RELEASE
|
892 |
|
|
/*
|
893 |
|
|
** The proc routine called by the line discipline to do the work for it.
|
894 |
|
|
** The proc routine works hand in hand with the interrupt routine.
|
895 |
|
|
*/
|
896 |
|
|
int
|
897 |
|
|
riotproc(p, tp, cmd, port)
|
898 |
|
|
struct rio_info * p;
|
899 |
|
|
register struct ttystatics *tp;
|
900 |
|
|
int cmd;
|
901 |
|
|
int port;
|
902 |
|
|
{
|
903 |
|
|
register struct Port *PortP;
|
904 |
|
|
int SysPort;
|
905 |
|
|
struct PKT *PacketP;
|
906 |
|
|
|
907 |
|
|
SysPort = port; /* Believe me, it works. */
|
908 |
|
|
|
909 |
|
|
if ( SysPort < 0 || SysPort >= RIO_PORTS ) {
|
910 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "Illegal port %d derived from TTY in riotproc()\n",SysPort);
|
911 |
|
|
return 0;
|
912 |
|
|
}
|
913 |
|
|
PortP = p->RIOPortp[SysPort];
|
914 |
|
|
|
915 |
|
|
if ((uint)PortP->PhbP < (uint)PortP->Caddr ||
|
916 |
|
|
(uint)PortP->PhbP >= (uint)PortP->Caddr+SIXTY_FOUR_K ) {
|
917 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "RIO: NULL or BAD PhbP on sys port %d in proc routine\n",
|
918 |
|
|
SysPort);
|
919 |
|
|
rio_dprintk (RIO_DEBUG_INTR, " PortP = 0x%x\n",PortP);
|
920 |
|
|
rio_dprintk (RIO_DEBUG_INTR, " PortP->PhbP = 0x%x\n",PortP->PhbP);
|
921 |
|
|
rio_dprintk (RIO_DEBUG_INTR, " PortP->Caddr = 0x%x\n",PortP->PhbP);
|
922 |
|
|
rio_dprintk (RIO_DEBUG_INTR, " PortP->HostPort = 0x%x\n",PortP->HostPort);
|
923 |
|
|
return 0;
|
924 |
|
|
}
|
925 |
|
|
|
926 |
|
|
switch(cmd) {
|
927 |
|
|
case T_WFLUSH:
|
928 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_WFLUSH\n");
|
929 |
|
|
/*
|
930 |
|
|
** Because of the spooky way the RIO works, we don't need
|
931 |
|
|
** to issue a flush command on any of the SET*F commands,
|
932 |
|
|
** as that causes trouble with getty and login, which issue
|
933 |
|
|
** these commands to incur a READ flush, and rely on the fact
|
934 |
|
|
** that the line discipline does a wait for drain for them.
|
935 |
|
|
** As the rio doesn't wait for drain, the write flush would
|
936 |
|
|
** destroy the Password: prompt. This isn't very friendly, so
|
937 |
|
|
** here we only issue a WFLUSH command if we are in the interrupt
|
938 |
|
|
** routine, or we aren't executing a SET*F command.
|
939 |
|
|
*/
|
940 |
|
|
if ( PortP->HostP->InIntr || !PortP->FlushCmdBodge ) {
|
941 |
|
|
/*
|
942 |
|
|
** form a wflush packet - 1 byte long, no data
|
943 |
|
|
*/
|
944 |
|
|
if ( PortP->State & RIO_DELETED ) {
|
945 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "WFLUSH on deleted RTA\n");
|
946 |
|
|
}
|
947 |
|
|
else {
|
948 |
|
|
if ( RIOPreemptiveCmd(p, PortP, WFLUSH ) == RIO_FAIL ) {
|
949 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_WFLUSH Command failed\n");
|
950 |
|
|
}
|
951 |
|
|
else
|
952 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_WFLUSH Command\n");
|
953 |
|
|
}
|
954 |
|
|
/*
|
955 |
|
|
** WFLUSH operation - flush the data!
|
956 |
|
|
*/
|
957 |
|
|
PortP->TxBufferIn = PortP->TxBufferOut = 0;
|
958 |
|
|
}
|
959 |
|
|
else {
|
960 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_WFLUSH Command ignored\n");
|
961 |
|
|
}
|
962 |
|
|
/*
|
963 |
|
|
** sort out the line discipline
|
964 |
|
|
*/
|
965 |
|
|
if (PortP->CookMode == COOK_WELL)
|
966 |
|
|
goto start;
|
967 |
|
|
break;
|
968 |
|
|
|
969 |
|
|
case T_RESUME:
|
970 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_RESUME\n");
|
971 |
|
|
/*
|
972 |
|
|
** send pre-emptive resume packet
|
973 |
|
|
*/
|
974 |
|
|
if ( PortP->State & RIO_DELETED ) {
|
975 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "RESUME on deleted RTA\n");
|
976 |
|
|
}
|
977 |
|
|
else {
|
978 |
|
|
if ( RIOPreemptiveCmd(p, PortP, RESUME ) == RIO_FAIL ) {
|
979 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_RESUME Command failed\n");
|
980 |
|
|
}
|
981 |
|
|
}
|
982 |
|
|
/*
|
983 |
|
|
** and re-start the sender software!
|
984 |
|
|
*/
|
985 |
|
|
if (PortP->CookMode == COOK_WELL)
|
986 |
|
|
goto start;
|
987 |
|
|
break;
|
988 |
|
|
|
989 |
|
|
case T_TIME:
|
990 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_TIME\n");
|
991 |
|
|
/*
|
992 |
|
|
** T_TIME is called when xDLY is set in oflags and
|
993 |
|
|
** the line discipline timeout has expired. It's
|
994 |
|
|
** function in life is to clear the TIMEOUT flag
|
995 |
|
|
** and to re-start output to the port.
|
996 |
|
|
*/
|
997 |
|
|
/*
|
998 |
|
|
** Fall through and re-start output
|
999 |
|
|
*/
|
1000 |
|
|
case T_OUTPUT:
|
1001 |
|
|
start:
|
1002 |
|
|
if ( PortP->MagicFlags & MAGIC_FLUSH ) {
|
1003 |
|
|
PortP->MagicFlags |= MORE_OUTPUT_EYGOR;
|
1004 |
|
|
return 0;
|
1005 |
|
|
}
|
1006 |
|
|
RIOTxEnable((char *)PortP);
|
1007 |
|
|
PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR;
|
1008 |
|
|
/*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"T_OUTPUT finished\n");*/
|
1009 |
|
|
break;
|
1010 |
|
|
|
1011 |
|
|
case T_SUSPEND:
|
1012 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_SUSPEND\n");
|
1013 |
|
|
/*
|
1014 |
|
|
** send a suspend pre-emptive packet.
|
1015 |
|
|
*/
|
1016 |
|
|
if ( PortP->State & RIO_DELETED ) {
|
1017 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "SUSPEND deleted RTA\n");
|
1018 |
|
|
}
|
1019 |
|
|
else {
|
1020 |
|
|
if ( RIOPreemptiveCmd(p, PortP, SUSPEND ) == RIO_FAIL ) {
|
1021 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_SUSPEND Command failed\n");
|
1022 |
|
|
}
|
1023 |
|
|
}
|
1024 |
|
|
/*
|
1025 |
|
|
** done!
|
1026 |
|
|
*/
|
1027 |
|
|
break;
|
1028 |
|
|
|
1029 |
|
|
case T_BLOCK:
|
1030 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_BLOCK\n");
|
1031 |
|
|
break;
|
1032 |
|
|
|
1033 |
|
|
case T_RFLUSH:
|
1034 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_RFLUSH\n");
|
1035 |
|
|
if ( PortP->State & RIO_DELETED ) {
|
1036 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "RFLUSH on deleted RTA\n");
|
1037 |
|
|
PortP->RxDataStart = 0;
|
1038 |
|
|
}
|
1039 |
|
|
else {
|
1040 |
|
|
if ( RIOPreemptiveCmd( p, PortP, RFLUSH ) == RIO_FAIL ) {
|
1041 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_RFLUSH Command failed\n");
|
1042 |
|
|
return 0;
|
1043 |
|
|
}
|
1044 |
|
|
PortP->RxDataStart = 0;
|
1045 |
|
|
while ( can_remove_receive(&PacketP, PortP) ) {
|
1046 |
|
|
remove_receive(PortP);
|
1047 |
|
|
ShowPacket(DBG_PROC, PacketP );
|
1048 |
|
|
put_free_end(PortP->HostP, PacketP );
|
1049 |
|
|
}
|
1050 |
|
|
if ( PortP->PhbP->handshake == PHB_HANDSHAKE_SET ) {
|
1051 |
|
|
/*
|
1052 |
|
|
** MAGIC!
|
1053 |
|
|
*/
|
1054 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "Set receive handshake bit\n");
|
1055 |
|
|
PortP->PhbP->handshake |= PHB_HANDSHAKE_RESET;
|
1056 |
|
|
}
|
1057 |
|
|
}
|
1058 |
|
|
break;
|
1059 |
|
|
/* FALLTHROUGH */
|
1060 |
|
|
case T_UNBLOCK:
|
1061 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_UNBLOCK\n");
|
1062 |
|
|
/*
|
1063 |
|
|
** If there is any data to receive set a timeout to service it.
|
1064 |
|
|
*/
|
1065 |
|
|
RIOReceive(p, PortP);
|
1066 |
|
|
break;
|
1067 |
|
|
|
1068 |
|
|
case T_BREAK:
|
1069 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "T_BREAK\n");
|
1070 |
|
|
/*
|
1071 |
|
|
** Send a break command. For Sys V
|
1072 |
|
|
** this is a timed break, so we
|
1073 |
|
|
** send a SBREAK[time] packet
|
1074 |
|
|
*/
|
1075 |
|
|
/*
|
1076 |
|
|
** Build a BREAK command
|
1077 |
|
|
*/
|
1078 |
|
|
if ( PortP->State & RIO_DELETED ) {
|
1079 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "BREAK on deleted RTA\n");
|
1080 |
|
|
}
|
1081 |
|
|
else {
|
1082 |
|
|
if (RIOShortCommand(PortP,SBREAK,2,
|
1083 |
|
|
p->RIOConf.BreakInterval)==RIO_FAIL) {
|
1084 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
|
1085 |
|
|
}
|
1086 |
|
|
}
|
1087 |
|
|
|
1088 |
|
|
/*
|
1089 |
|
|
** done!
|
1090 |
|
|
*/
|
1091 |
|
|
break;
|
1092 |
|
|
|
1093 |
|
|
case T_INPUT:
|
1094 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "Proc T_INPUT called - I don't know what to do!\n");
|
1095 |
|
|
break;
|
1096 |
|
|
case T_PARM:
|
1097 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "Proc T_PARM called - I don't know what to do!\n");
|
1098 |
|
|
break;
|
1099 |
|
|
|
1100 |
|
|
case T_SWTCH:
|
1101 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "Proc T_SWTCH called - I don't know what to do!\n");
|
1102 |
|
|
break;
|
1103 |
|
|
|
1104 |
|
|
default:
|
1105 |
|
|
rio_dprintk (RIO_DEBUG_INTR, "Proc UNKNOWN command %d\n",cmd);
|
1106 |
|
|
}
|
1107 |
|
|
/*
|
1108 |
|
|
** T_OUTPUT returns without passing through this point!
|
1109 |
|
|
*/
|
1110 |
|
|
/*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"riotproc done\n");*/
|
1111 |
|
|
return(0);
|
1112 |
|
|
}
|
1113 |
|
|
#endif
|