2 ** -----------------------------------------------------------------------------
4 ** Perle Specialix driver for Linux
5 ** Ported from existing RIO Driver for SCO sources.
7 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
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.
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.
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.
25 ** Last Modified : 11/6/98 10:33:44
26 ** Retrieved : 11/6/98 10:33:49
28 ** ident @(#)riointr.c 1.2
30 ** -----------------------------------------------------------------------------
33 static char *_riointr_c_sccs_
= "@(#)riointr.c 1.2";
37 #include <linux/module.h>
38 #include <linux/slab.h>
39 #include <linux/errno.h>
40 #include <linux/tty.h>
41 #include <linux/tty_flip.h>
43 #include <asm/system.h>
44 #include <asm/string.h>
45 #include <asm/semaphore.h>
46 #include <asm/uaccess.h>
48 #include <linux/termios.h>
49 #include <linux/serial.h>
51 #include <linux/generic_serial.h>
53 #include <linux/delay.h>
55 #include "linux_compat.h"
56 #include "rio_linux.h"
88 static void RIOReceive(struct rio_info
*, struct Port
*);
91 static char *firstchars (char *p
, int nch
)
93 static char buf
[2][128];
96 memcpy (buf
[t
], p
, nch
);
102 #define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask))
103 /* Enable and start the transmission of packets */
110 struct tty_struct
* tty
;
112 struct PKT
* PacketP
;
115 PortP
= (struct Port
*)en
;
116 p
= (struct rio_info
*)PortP
->p
;
120 rio_dprintk (RIO_DEBUG_INTR
, "tx port %d: %d chars queued.\n",
121 PortP
->PortNum
, PortP
->gs
.xmit_cnt
);
123 if (!PortP
->gs
.xmit_cnt
) return;
126 /* This routine is an order of magnitude simpler than the specialix
127 version. One of the disadvantages is that this version will send
128 an incomplete packet (usually 64 bytes instead of 72) once for
129 every 4k worth of data. Let's just say that this won't influence
130 performance significantly..... */
132 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
134 while (can_add_transmit( &PacketP
, PortP
)) {
135 c
= PortP
->gs
.xmit_cnt
;
136 if (c
> PKT_MAX_DATA_LEN
) c
= PKT_MAX_DATA_LEN
;
138 /* Don't copy past the end of the source buffer */
139 if (c
> SERIAL_XMIT_SIZE
- PortP
->gs
.xmit_tail
)
140 c
= SERIAL_XMIT_SIZE
- PortP
->gs
.xmit_tail
;
145 rio_dprintk (RIO_DEBUG_INTR
, "rio: tx port %d: copying %d chars: %s - %s\n",
147 firstchars (PortP
->gs
.xmit_buf
+ PortP
->gs
.xmit_tail
, t
),
148 firstchars (PortP
->gs
.xmit_buf
+ PortP
->gs
.xmit_tail
+ c
-t
, t
));
150 /* If for one reason or another, we can't copy more data,
154 rio_memcpy_toio (PortP
->HostP
->Caddr
, (caddr_t
)PacketP
->data
,
155 PortP
->gs
.xmit_buf
+ PortP
->gs
.xmit_tail
, c
);
158 writeb (c
, &(PacketP
->len
));
159 if (!( PortP
->State
& RIO_DELETED
) ) {
160 add_transmit ( PortP
);
162 ** Count chars tx'd for port statistics reporting
164 if ( PortP
->statsGather
)
167 PortP
->gs
.xmit_tail
= (PortP
->gs
.xmit_tail
+ c
) & (SERIAL_XMIT_SIZE
-1);
168 PortP
->gs
.xmit_cnt
-= c
;
171 rio_spin_unlock_irqrestore(&PortP
->portSem
, flags
);
173 if (PortP
->gs
.xmit_cnt
<= (PortP
->gs
.wakeup_chars
+ 2*PKT_MAX_DATA_LEN
)) {
174 rio_dprintk (RIO_DEBUG_INTR
, "Waking up.... ldisc:%d (%d/%d)....",
175 (int)(PortP
->gs
.tty
->flags
& (1 << TTY_DO_WRITE_WAKEUP
)),
176 PortP
->gs
.wakeup_chars
, PortP
->gs
.xmit_cnt
);
177 if ((PortP
->gs
.tty
->flags
& (1 << TTY_DO_WRITE_WAKEUP
)) &&
178 PortP
->gs
.tty
->ldisc
.write_wakeup
)
179 (PortP
->gs
.tty
->ldisc
.write_wakeup
)(PortP
->gs
.tty
);
180 rio_dprintk (RIO_DEBUG_INTR
, "(%d/%d)\n",
181 PortP
->gs
.wakeup_chars
, PortP
->gs
.xmit_cnt
);
182 wake_up_interruptible(&PortP
->gs
.tty
->write_wait
);
189 ** RIO Host Service routine. Does all the work traditionally associated with an
196 RIOServiceHost(p
, HostP
, From
)
201 rio_spin_lock (&HostP
->HostLock
);
202 if ( (HostP
->Flags
& RUN_STATE
) != RC_RUNNING
) {
204 rio_spin_unlock (&HostP
->HostLock
);
205 if ((t
++ % 200) == 0)
206 rio_dprintk (RIO_DEBUG_INTR
, "Interrupt but host not running. flags=%x.\n", (int)HostP
->Flags
);
209 rio_spin_unlock (&HostP
->HostLock
);
211 if ( RWORD( HostP
->ParmMapP
->rup_intr
) ) {
212 WWORD( HostP
->ParmMapP
->rup_intr
, 0 );
215 rio_dprintk (RIO_DEBUG_INTR
, "rio: RUP interrupt on host %d\n", HostP
-p
->RIOHosts
);
216 RIOPollHostCommands(p
, HostP
);
219 if ( RWORD( HostP
->ParmMapP
->rx_intr
) ) {
222 WWORD( HostP
->ParmMapP
->rx_intr
, 0 );
226 rio_dprintk (RIO_DEBUG_INTR
, "rio: RX interrupt on host %d\n", HostP
-p
->RIOHosts
);
228 ** Loop through every port. If the port is mapped into
229 ** the system ( i.e. has /dev/ttyXXXX associated ) then it is
230 ** worth checking. If the port isn't open, grab any packets
231 ** hanging on its receive queue and stuff them on the free
232 ** list; check for commands on the way.
234 for ( port
=p
->RIOFirstPortsBooted
;
235 port
<p
->RIOLastPortsBooted
+PORTS_PER_RTA
; port
++ ) {
236 struct Port
*PortP
= p
->RIOPortp
[port
];
237 struct tty_struct
*ttyP
;
241 ** not mapped in - most of the RIOPortp[] information
242 ** has not been set up!
243 ** Optimise: ports come in bundles of eight.
245 if ( !PortP
->Mapped
) {
247 continue; /* with the next port */
251 ** If the host board isn't THIS host board, check the next one.
252 ** optimise: ports come in bundles of eight.
254 if ( PortP
->HostP
!= HostP
) {
260 ** Let us see - is the port open? If not, then don't service it.
262 if ( !( PortP
->PortState
& PORT_ISOPEN
) ) {
267 ** find corresponding tty structure. The process of mapping
268 ** the ports puts these here.
270 ttyP
= PortP
->gs
.tty
;
273 ** Lock the port before we begin working on it.
275 rio_spin_lock(&PortP
->portSem
);
278 ** Process received data if there is any.
280 if ( can_remove_receive( &PacketP
, PortP
) )
281 RIOReceive(p
, PortP
);
284 ** If there is no data left to be read from the port, and
285 ** it's handshake bit is set, then we must clear the handshake,
286 ** so that that downstream RTA is re-enabled.
288 if ( !can_remove_receive( &PacketP
, PortP
) &&
289 ( RWORD( PortP
->PhbP
->handshake
)==PHB_HANDSHAKE_SET
) ) {
291 ** MAGIC! ( Basically, handshake the RX buffer, so that
292 ** the RTAs upstream can be re-enabled. )
294 rio_dprintk (RIO_DEBUG_INTR
, "Set RX handshake bit\n");
295 WWORD( PortP
->PhbP
->handshake
,
296 PHB_HANDSHAKE_SET
|PHB_HANDSHAKE_RESET
);
298 rio_spin_unlock(&PortP
->portSem
);
302 if ( RWORD( HostP
->ParmMapP
->tx_intr
) ) {
305 WWORD( HostP
->ParmMapP
->tx_intr
, 0);
309 rio_dprintk (RIO_DEBUG_INTR
, "rio: TX interrupt on host %d\n", HostP
-p
->RIOHosts
);
312 ** Loop through every port.
313 ** If the port is mapped into the system ( i.e. has /dev/ttyXXXX
314 ** associated ) then it is worth checking.
316 for ( port
=p
->RIOFirstPortsBooted
;
317 port
<p
->RIOLastPortsBooted
+PORTS_PER_RTA
; port
++ ) {
318 struct Port
*PortP
= p
->RIOPortp
[port
];
319 struct tty_struct
*ttyP
;
323 ** not mapped in - most of the RIOPortp[] information
324 ** has not been set up!
326 if ( !PortP
->Mapped
) {
328 continue; /* with the next port */
332 ** If the host board isn't running, then its data structures
333 ** are no use to us - continue quietly.
335 if ( PortP
->HostP
!= HostP
) {
337 continue; /* with the next port */
341 ** Let us see - is the port open? If not, then don't service it.
343 if ( !( PortP
->PortState
& PORT_ISOPEN
) ) {
347 rio_dprintk (RIO_DEBUG_INTR
, "rio: Looking into port %d.\n", port
);
349 ** Lock the port before we begin working on it.
351 rio_spin_lock(&PortP
->portSem
);
354 ** If we can't add anything to the transmit queue, then
355 ** we need do none of this processing.
357 if ( !can_add_transmit( &PacketP
, PortP
) ) {
358 rio_dprintk (RIO_DEBUG_INTR
, "Can't add to port, so skipping.\n");
359 rio_spin_unlock(&PortP
->portSem
);
364 ** find corresponding tty structure. The process of mapping
365 ** the ports puts these here.
367 ttyP
= PortP
->gs
.tty
;
368 /* If ttyP is NULL, the port is getting closed. Forget about it. */
370 rio_dprintk (RIO_DEBUG_INTR
, "no tty, so skipping.\n");
371 rio_spin_unlock(&PortP
->portSem
);
375 ** If there is more room available we start up the transmit
376 ** data process again. This can be direct I/O, if the cookmode
377 ** is set to COOK_RAW or COOK_MEDIUM, or will be a call to the
378 ** riotproc( T_OUTPUT ) if we are in COOK_WELL mode, to fetch
379 ** characters via the line discipline. We must always call
380 ** the line discipline,
381 ** so that user input characters can be echoed correctly.
384 ** With the advent of double buffering, we now see if
385 ** TxBufferOut-In is non-zero. If so, then we copy a packet
386 ** to the output place, and set it going. If this empties
387 ** the buffer, then we must issue a wakeup( ) on OUT.
388 ** If it frees space in the buffer then we must issue
389 ** a wakeup( ) on IN.
391 ** ++++ Extra! Extra! If PortP->WflushFlag is set, then we
392 ** have to send a WFLUSH command down the PHB, to mark the
393 ** end point of a WFLUSH. We also need to clear out any
394 ** data from the double buffer! ( note that WflushFlag is a
395 ** *count* of the number of WFLUSH commands outstanding! )
397 ** ++++ And there's more!
398 ** If an RTA is powered off, then on again, and rebooted,
399 ** whilst it has ports open, then we need to re-open the ports.
400 ** ( reasonable enough ). We can't do this when we spot the
401 ** re-boot, in interrupt time, because the queue is probably
402 ** full. So, when we come in here, we need to test if any
403 ** ports are in this condition, and re-open the port before
404 ** we try to send any more data to it. Now, the re-booted
405 ** RTA will be discarding packets from the PHB until it
406 ** receives this open packet, but don't worry tooo much
407 ** about that. The one thing that is interesting is the
408 ** combination of this effect and the WFLUSH effect!
410 /* For now don't handle RTA reboots. -- REW.
411 Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */
412 if ( PortP
->MagicFlags
) {
414 if ( PortP
->MagicFlags
& MAGIC_REBOOT
) {
416 ** well, the RTA has been rebooted, and there is room
417 ** on its queue to add the open packet that is required.
419 ** The messy part of this line is trying to decide if
420 ** we need to call the Param function as a tty or as
422 ** DONT USE CLOCAL AS A TEST FOR THIS!
424 ** If we can't param the port, then move on to the
427 PortP
->InUse
= NOT_INUSE
;
429 rio_spin_unlock(&PortP
->portSem
);
430 if ( RIOParam(PortP
, OPEN
, ((PortP
->Cor2Copy
&
431 (COR2_RTSFLOW
|COR2_CTSFLOW
) )==
432 (COR2_RTSFLOW
|COR2_CTSFLOW
) ) ?
433 TRUE
: FALSE
, DONT_SLEEP
) == RIO_FAIL
) {
434 continue; /* with next port */
436 rio_spin_lock(&PortP
->portSem
);
437 PortP
->MagicFlags
&= ~MAGIC_REBOOT
;
442 ** As mentioned above, this is a tacky hack to cope
445 if ( PortP
->WflushFlag
) {
446 rio_dprintk (RIO_DEBUG_INTR
, "Want to WFLUSH mark this port\n");
449 rio_dprintk (RIO_DEBUG_INTR
, "FAILS - PORT IS IN USE\n");
452 while ( PortP
->WflushFlag
&&
453 can_add_transmit( &PacketP
, PortP
) &&
454 ( PortP
->InUse
== NOT_INUSE
) ) {
456 struct PktCmd
*PktCmdP
;
458 rio_dprintk (RIO_DEBUG_INTR
, "Add WFLUSH marker to data queue\n");
460 ** make it look just like a WFLUSH command
462 PktCmdP
= ( struct PktCmd
* )&PacketP
->data
[0];
464 WBYTE( PktCmdP
->Command
, WFLUSH
);
466 p
= PortP
->HostPort
% ( ushort
)PORTS_PER_RTA
;
469 ** If second block of ports for 16 port RTA, add 8
472 if ( PortP
->SecondBlock
)
475 WBYTE( PktCmdP
->PhbNum
, p
);
478 ** to make debuggery easier
480 WBYTE( PacketP
->data
[ 2], 'W' );
481 WBYTE( PacketP
->data
[ 3], 'F' );
482 WBYTE( PacketP
->data
[ 4], 'L' );
483 WBYTE( PacketP
->data
[ 5], 'U' );
484 WBYTE( PacketP
->data
[ 6], 'S' );
485 WBYTE( PacketP
->data
[ 7], 'H' );
486 WBYTE( PacketP
->data
[ 8], ' ' );
487 WBYTE( PacketP
->data
[ 9], '0'+PortP
->WflushFlag
);
488 WBYTE( PacketP
->data
[10], ' ' );
489 WBYTE( PacketP
->data
[11], ' ' );
490 WBYTE( PacketP
->data
[12], '\0' );
493 ** its two bytes long!
495 WBYTE( PacketP
->len
, PKT_CMD_BIT
| 2 );
500 if ( !( PortP
->State
& RIO_DELETED
) ) {
501 add_transmit( PortP
);
503 ** Count chars tx'd for port statistics reporting
505 if ( PortP
->statsGather
)
509 if ( --( PortP
->WflushFlag
) == 0 ) {
510 PortP
->MagicFlags
&= ~MAGIC_FLUSH
;
513 rio_dprintk (RIO_DEBUG_INTR
, "Wflush count now stands at %d\n",
516 if ( PortP
->MagicFlags
& MORE_OUTPUT_EYGOR
) {
517 if ( PortP
->MagicFlags
& MAGIC_FLUSH
) {
518 PortP
->MagicFlags
|= MORE_OUTPUT_EYGOR
;
521 if ( !can_add_transmit( &PacketP
, PortP
) ) {
522 rio_spin_unlock(&PortP
->portSem
);
525 rio_spin_unlock(&PortP
->portSem
);
526 RIOTxEnable((char *)PortP
);
527 rio_spin_lock(&PortP
->portSem
);
528 PortP
->MagicFlags
&= ~MORE_OUTPUT_EYGOR
;
535 ** If we can't add anything to the transmit queue, then
536 ** we need do none of the remaining processing.
538 if (!can_add_transmit( &PacketP
, PortP
) ) {
539 rio_spin_unlock(&PortP
->portSem
);
543 rio_spin_unlock(&PortP
->portSem
);
544 RIOTxEnable((char *)PortP
);
550 ** Routine for handling received data for clist drivers.
551 ** NB: Called with the tty locked. The spl from the lockb( ) is passed.
552 ** we return the ttySpl level that we re-locked at.
559 struct tty_struct
*TtyP
;
560 register ushort transCount
;
562 register uint DataCnt
;
567 static int intCount
, RxIntCnt
;
570 ** The receive data process is to remove packets from the
571 ** PHB until there aren't any more or the current cblock
572 ** is full. When this occurs, there will be some left over
573 ** data in the packet, that we must do something with.
574 ** As we haven't unhooked the packet from the read list
575 ** yet, we can just leave the packet there, having first
576 ** made a note of how far we got. This means that we need
577 ** a pointer per port saying where we start taking the
578 ** data from - this will normally be zero, but when we
579 ** run out of space it will be set to the offset of the
580 ** next byte to copy from the packet data area. The packet
581 ** length field is decremented by the number of bytes that
582 ** we succesfully removed from the packet. When this reaches
583 ** zero, we reset the offset pointer to be zero, and free
584 ** the packet from the front of the queue.
589 TtyP
= PortP
->gs
.tty
;
591 rio_dprintk (RIO_DEBUG_INTR
, "RIOReceive: tty is null. \n");
595 if (PortP
->State
& RIO_THROTTLE_RX
) {
596 rio_dprintk (RIO_DEBUG_INTR
, "RIOReceive: Throttled. Can't handle more input.\n");
600 if ( PortP
->State
& RIO_DELETED
)
602 while ( can_remove_receive( &PacketP
, PortP
) )
604 remove_receive( PortP
);
605 put_free_end( PortP
->HostP
, PacketP
);
611 ** loop, just so long as:
612 ** i ) there's some data ( i.e. can_remove_receive )
613 ** ii ) we haven't been blocked
614 ** iii ) there's somewhere to put the data
615 ** iv ) we haven't outstayed our welcome
618 while ( can_remove_receive(&PacketP
, PortP
)
622 PortP
->Stat
.RxIntCnt
++;
627 ** check that it is not a command!
629 if ( PacketP
->len
& PKT_CMD_BIT
) {
630 rio_dprintk (RIO_DEBUG_INTR
, "RIO: unexpected command packet received on PHB\n");
631 /* rio_dprint(RIO_DEBUG_INTR, (" sysport = %d\n", p->RIOPortp->PortNum)); */
632 rio_dprintk (RIO_DEBUG_INTR
, " dest_unit = %d\n", PacketP
->dest_unit
);
633 rio_dprintk (RIO_DEBUG_INTR
, " dest_port = %d\n", PacketP
->dest_port
);
634 rio_dprintk (RIO_DEBUG_INTR
, " src_unit = %d\n", PacketP
->src_unit
);
635 rio_dprintk (RIO_DEBUG_INTR
, " src_port = %d\n", PacketP
->src_port
);
636 rio_dprintk (RIO_DEBUG_INTR
, " len = %d\n", PacketP
->len
);
637 rio_dprintk (RIO_DEBUG_INTR
, " control = %d\n", PacketP
->control
);
638 rio_dprintk (RIO_DEBUG_INTR
, " csum = %d\n", PacketP
->csum
);
639 rio_dprintk (RIO_DEBUG_INTR
, " data bytes: ");
640 for ( DataCnt
=0; DataCnt
<PKT_MAX_DATA_LEN
; DataCnt
++ )
641 rio_dprintk (RIO_DEBUG_INTR
, "%d\n", PacketP
->data
[DataCnt
]);
642 remove_receive( PortP
);
643 put_free_end( PortP
->HostP
, PacketP
);
644 continue; /* with next packet */
648 ** How many characters can we move 'upstream' ?
650 ** Determine the minimum of the amount of data
651 ** available and the amount of space in which to
654 ** 1. Get the packet length by masking 'len'
655 ** for only the length bits.
656 ** 2. Available space is [buffer size] - [space used]
658 ** Transfer count is the minimum of packet length
659 ** and available space.
662 transCount
= tty_buffer_request_room(TtyP
, PacketP
->len
& PKT_LEN_MASK
);
663 rio_dprintk (RIO_DEBUG_REC
, "port %d: Copy %d bytes\n",
664 PortP
->PortNum
, transCount
);
666 ** To use the following 'kkprintfs' for debugging - change the '#undef'
667 ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the
670 #undef ___DEBUG_IT___
671 #ifdef ___DEBUG_IT___
672 kkprintf("I:%d R:%d P:%d Q:%d C:%d F:%x ",
680 ptr
= (uchar
*) PacketP
->data
+ PortP
->RxDataStart
;
682 tty_prepare_flip_string(TtyP
, &buf
, transCount
);
683 rio_memcpy_fromio (buf
, ptr
, transCount
);
686 ** keep a count for statistical purposes
688 PortP
->Stat
.RxCharCnt
+= transCount
;
690 PortP
->RxDataStart
+= transCount
;
691 PacketP
->len
-= transCount
;
692 copied
+= transCount
;
695 #ifdef ___DEBUG_IT___
696 kkprintf("T:%d L:%d\n", DataCnt
, PacketP
->len
);
699 if ( PacketP
->len
== 0 )
702 ** If we have emptied the packet, then we can
703 ** free it, and reset the start pointer for
706 remove_receive( PortP
);
707 put_free_end( PortP
->HostP
, PacketP
);
708 PortP
->RxDataStart
= 0;
711 ** more lies ( oops, I mean statistics )
713 PortP
->Stat
.RxPktCnt
++;
719 rio_dprintk (RIO_DEBUG_REC
, "port %d: pushing tty flip buffer: %d total bytes copied.\n", PortP
->PortNum
, copied
);
720 tty_flip_buffer_push (TtyP
);
726 #ifdef FUTURE_RELEASE
728 ** The proc routine called by the line discipline to do the work for it.
729 ** The proc routine works hand in hand with the interrupt routine.
732 riotproc(p
, tp
, cmd
, port
)
734 register struct ttystatics
*tp
;
738 register struct Port
*PortP
;
742 SysPort
= port
; /* Believe me, it works. */
744 if ( SysPort
< 0 || SysPort
>= RIO_PORTS
) {
745 rio_dprintk (RIO_DEBUG_INTR
, "Illegal port %d derived from TTY in riotproc()\n",SysPort
);
748 PortP
= p
->RIOPortp
[SysPort
];
750 if ((uint
)PortP
->PhbP
< (uint
)PortP
->Caddr
||
751 (uint
)PortP
->PhbP
>= (uint
)PortP
->Caddr
+SIXTY_FOUR_K
) {
752 rio_dprintk (RIO_DEBUG_INTR
, "RIO: NULL or BAD PhbP on sys port %d in proc routine\n",
754 rio_dprintk (RIO_DEBUG_INTR
, " PortP = 0x%x\n",PortP
);
755 rio_dprintk (RIO_DEBUG_INTR
, " PortP->PhbP = 0x%x\n",PortP
->PhbP
);
756 rio_dprintk (RIO_DEBUG_INTR
, " PortP->Caddr = 0x%x\n",PortP
->PhbP
);
757 rio_dprintk (RIO_DEBUG_INTR
, " PortP->HostPort = 0x%x\n",PortP
->HostPort
);
763 rio_dprintk (RIO_DEBUG_INTR
, "T_WFLUSH\n");
765 ** Because of the spooky way the RIO works, we don't need
766 ** to issue a flush command on any of the SET*F commands,
767 ** as that causes trouble with getty and login, which issue
768 ** these commands to incur a READ flush, and rely on the fact
769 ** that the line discipline does a wait for drain for them.
770 ** As the rio doesn't wait for drain, the write flush would
771 ** destroy the Password: prompt. This isn't very friendly, so
772 ** here we only issue a WFLUSH command if we are in the interrupt
773 ** routine, or we aren't executing a SET*F command.
775 if ( PortP
->HostP
->InIntr
|| !PortP
->FlushCmdBodge
) {
777 ** form a wflush packet - 1 byte long, no data
779 if ( PortP
->State
& RIO_DELETED
) {
780 rio_dprintk (RIO_DEBUG_INTR
, "WFLUSH on deleted RTA\n");
783 if ( RIOPreemptiveCmd(p
, PortP
, WFLUSH
) == RIO_FAIL
) {
784 rio_dprintk (RIO_DEBUG_INTR
, "T_WFLUSH Command failed\n");
787 rio_dprintk (RIO_DEBUG_INTR
, "T_WFLUSH Command\n");
790 ** WFLUSH operation - flush the data!
792 PortP
->TxBufferIn
= PortP
->TxBufferOut
= 0;
795 rio_dprintk (RIO_DEBUG_INTR
, "T_WFLUSH Command ignored\n");
798 ** sort out the line discipline
800 if (PortP
->CookMode
== COOK_WELL
)
805 rio_dprintk (RIO_DEBUG_INTR
, "T_RESUME\n");
807 ** send pre-emptive resume packet
809 if ( PortP
->State
& RIO_DELETED
) {
810 rio_dprintk (RIO_DEBUG_INTR
, "RESUME on deleted RTA\n");
813 if ( RIOPreemptiveCmd(p
, PortP
, RESUME
) == RIO_FAIL
) {
814 rio_dprintk (RIO_DEBUG_INTR
, "T_RESUME Command failed\n");
818 ** and re-start the sender software!
820 if (PortP
->CookMode
== COOK_WELL
)
825 rio_dprintk (RIO_DEBUG_INTR
, "T_TIME\n");
827 ** T_TIME is called when xDLY is set in oflags and
828 ** the line discipline timeout has expired. It's
829 ** function in life is to clear the TIMEOUT flag
830 ** and to re-start output to the port.
833 ** Fall through and re-start output
837 if ( PortP
->MagicFlags
& MAGIC_FLUSH
) {
838 PortP
->MagicFlags
|= MORE_OUTPUT_EYGOR
;
841 RIOTxEnable((char *)PortP
);
842 PortP
->MagicFlags
&= ~MORE_OUTPUT_EYGOR
;
843 /*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"T_OUTPUT finished\n");*/
847 rio_dprintk (RIO_DEBUG_INTR
, "T_SUSPEND\n");
849 ** send a suspend pre-emptive packet.
851 if ( PortP
->State
& RIO_DELETED
) {
852 rio_dprintk (RIO_DEBUG_INTR
, "SUSPEND deleted RTA\n");
855 if ( RIOPreemptiveCmd(p
, PortP
, SUSPEND
) == RIO_FAIL
) {
856 rio_dprintk (RIO_DEBUG_INTR
, "T_SUSPEND Command failed\n");
865 rio_dprintk (RIO_DEBUG_INTR
, "T_BLOCK\n");
869 rio_dprintk (RIO_DEBUG_INTR
, "T_RFLUSH\n");
870 if ( PortP
->State
& RIO_DELETED
) {
871 rio_dprintk (RIO_DEBUG_INTR
, "RFLUSH on deleted RTA\n");
872 PortP
->RxDataStart
= 0;
875 if ( RIOPreemptiveCmd( p
, PortP
, RFLUSH
) == RIO_FAIL
) {
876 rio_dprintk (RIO_DEBUG_INTR
, "T_RFLUSH Command failed\n");
879 PortP
->RxDataStart
= 0;
880 while ( can_remove_receive(&PacketP
, PortP
) ) {
881 remove_receive(PortP
);
882 ShowPacket(DBG_PROC
, PacketP
);
883 put_free_end(PortP
->HostP
, PacketP
);
885 if ( PortP
->PhbP
->handshake
== PHB_HANDSHAKE_SET
) {
889 rio_dprintk (RIO_DEBUG_INTR
, "Set receive handshake bit\n");
890 PortP
->PhbP
->handshake
|= PHB_HANDSHAKE_RESET
;
896 rio_dprintk (RIO_DEBUG_INTR
, "T_UNBLOCK\n");
898 ** If there is any data to receive set a timeout to service it.
900 RIOReceive(p
, PortP
);
904 rio_dprintk (RIO_DEBUG_INTR
, "T_BREAK\n");
906 ** Send a break command. For Sys V
907 ** this is a timed break, so we
908 ** send a SBREAK[time] packet
911 ** Build a BREAK command
913 if ( PortP
->State
& RIO_DELETED
) {
914 rio_dprintk (RIO_DEBUG_INTR
, "BREAK on deleted RTA\n");
917 if (RIOShortCommand(PortP
,SBREAK
,2,
918 p
->RIOConf
.BreakInterval
)==RIO_FAIL
) {
919 rio_dprintk (RIO_DEBUG_INTR
, "SBREAK RIOShortCommand failed\n");
929 rio_dprintk (RIO_DEBUG_INTR
, "Proc T_INPUT called - I don't know what to do!\n");
932 rio_dprintk (RIO_DEBUG_INTR
, "Proc T_PARM called - I don't know what to do!\n");
936 rio_dprintk (RIO_DEBUG_INTR
, "Proc T_SWTCH called - I don't know what to do!\n");
940 rio_dprintk (RIO_DEBUG_INTR
, "Proc UNKNOWN command %d\n",cmd
);
943 ** T_OUTPUT returns without passing through this point!
945 /*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"riotproc done\n");*/