aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/rio/riointr.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/rio/riointr.c')
-rw-r--r--drivers/char/rio/riointr.c311
1 files changed, 35 insertions, 276 deletions
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index 34d8787557a1..ec415ccbc4f0 100644
--- a/drivers/char/rio/riointr.c
+++ b/drivers/char/rio/riointr.c
@@ -101,8 +101,7 @@ static char *firstchars(char *p, int nch)
101 101
102#define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask)) 102#define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask))
103/* Enable and start the transmission of packets */ 103/* Enable and start the transmission of packets */
104void RIOTxEnable(en) 104void RIOTxEnable(char *en)
105char *en;
106{ 105{
107 struct Port *PortP; 106 struct Port *PortP;
108 struct rio_info *p; 107 struct rio_info *p;
@@ -186,10 +185,8 @@ char *en;
186static int RupIntr; 185static int RupIntr;
187static int RxIntr; 186static int RxIntr;
188static int TxIntr; 187static int TxIntr;
189void RIOServiceHost(p, HostP, From) 188
190struct rio_info *p; 189void RIOServiceHost(struct rio_info *p, struct Host *HostP, int From)
191struct Host *HostP;
192int From;
193{ 190{
194 rio_spin_lock(&HostP->HostLock); 191 rio_spin_lock(&HostP->HostLock);
195 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) { 192 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
@@ -201,22 +198,22 @@ int From;
201 } 198 }
202 rio_spin_unlock(&HostP->HostLock); 199 rio_spin_unlock(&HostP->HostLock);
203 200
204 if (RWORD(HostP->ParmMapP->rup_intr)) { 201 if (readw(&HostP->ParmMapP->rup_intr)) {
205 WWORD(HostP->ParmMapP->rup_intr, 0); 202 writew(0, &HostP->ParmMapP->rup_intr);
206 p->RIORupCount++; 203 p->RIORupCount++;
207 RupIntr++; 204 RupIntr++;
208 rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %d\n", HostP - p->RIOHosts); 205 rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %Zd\n", HostP - p->RIOHosts);
209 RIOPollHostCommands(p, HostP); 206 RIOPollHostCommands(p, HostP);
210 } 207 }
211 208
212 if (RWORD(HostP->ParmMapP->rx_intr)) { 209 if (readw(&HostP->ParmMapP->rx_intr)) {
213 int port; 210 int port;
214 211
215 WWORD(HostP->ParmMapP->rx_intr, 0); 212 writew(0, &HostP->ParmMapP->rx_intr);
216 p->RIORxCount++; 213 p->RIORxCount++;
217 RxIntr++; 214 RxIntr++;
218 215
219 rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %d\n", HostP - p->RIOHosts); 216 rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %Zd\n", HostP - p->RIOHosts);
220 /* 217 /*
221 ** Loop through every port. If the port is mapped into 218 ** Loop through every port. If the port is mapped into
222 ** the system ( i.e. has /dev/ttyXXXX associated ) then it is 219 ** the system ( i.e. has /dev/ttyXXXX associated ) then it is
@@ -277,26 +274,26 @@ int From;
277 ** it's handshake bit is set, then we must clear the handshake, 274 ** it's handshake bit is set, then we must clear the handshake,
278 ** so that that downstream RTA is re-enabled. 275 ** so that that downstream RTA is re-enabled.
279 */ 276 */
280 if (!can_remove_receive(&PacketP, PortP) && (RWORD(PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) { 277 if (!can_remove_receive(&PacketP, PortP) && (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) {
281 /* 278 /*
282 ** MAGIC! ( Basically, handshake the RX buffer, so that 279 ** MAGIC! ( Basically, handshake the RX buffer, so that
283 ** the RTAs upstream can be re-enabled. ) 280 ** the RTAs upstream can be re-enabled. )
284 */ 281 */
285 rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n"); 282 rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n");
286 WWORD(PortP->PhbP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET); 283 writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake);
287 } 284 }
288 rio_spin_unlock(&PortP->portSem); 285 rio_spin_unlock(&PortP->portSem);
289 } 286 }
290 } 287 }
291 288
292 if (RWORD(HostP->ParmMapP->tx_intr)) { 289 if (readw(&HostP->ParmMapP->tx_intr)) {
293 int port; 290 int port;
294 291
295 WWORD(HostP->ParmMapP->tx_intr, 0); 292 writew(0, &HostP->ParmMapP->tx_intr);
296 293
297 p->RIOTxCount++; 294 p->RIOTxCount++;
298 TxIntr++; 295 TxIntr++;
299 rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %d\n", HostP - p->RIOHosts); 296 rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %Zd\n", HostP - p->RIOHosts);
300 297
301 /* 298 /*
302 ** Loop through every port. 299 ** Loop through every port.
@@ -445,9 +442,9 @@ int From;
445 */ 442 */
446 PktCmdP = (struct PktCmd *) &PacketP->data[0]; 443 PktCmdP = (struct PktCmd *) &PacketP->data[0];
447 444
448 WBYTE(PktCmdP->Command, WFLUSH); 445 writeb(WFLUSH, &PktCmdP->Command);
449 446
450 p = PortP->HostPort % (ushort) PORTS_PER_RTA; 447 p = PortP->HostPort % (u16) PORTS_PER_RTA;
451 448
452 /* 449 /*
453 ** If second block of ports for 16 port RTA, add 8 450 ** If second block of ports for 16 port RTA, add 8
@@ -456,27 +453,27 @@ int From;
456 if (PortP->SecondBlock) 453 if (PortP->SecondBlock)
457 p += PORTS_PER_RTA; 454 p += PORTS_PER_RTA;
458 455
459 WBYTE(PktCmdP->PhbNum, p); 456 writeb(p, &PktCmdP->PhbNum);
460 457
461 /* 458 /*
462 ** to make debuggery easier 459 ** to make debuggery easier
463 */ 460 */
464 WBYTE(PacketP->data[2], 'W'); 461 writeb('W', &PacketP->data[2]);
465 WBYTE(PacketP->data[3], 'F'); 462 writeb('F', &PacketP->data[3]);
466 WBYTE(PacketP->data[4], 'L'); 463 writeb('L', &PacketP->data[4]);
467 WBYTE(PacketP->data[5], 'U'); 464 writeb('U', &PacketP->data[5]);
468 WBYTE(PacketP->data[6], 'S'); 465 writeb('S', &PacketP->data[6]);
469 WBYTE(PacketP->data[7], 'H'); 466 writeb('H', &PacketP->data[7]);
470 WBYTE(PacketP->data[8], ' '); 467 writeb(' ', &PacketP->data[8]);
471 WBYTE(PacketP->data[9], '0' + PortP->WflushFlag); 468 writeb('0' + PortP->WflushFlag, &PacketP->data[9]);
472 WBYTE(PacketP->data[10], ' '); 469 writeb(' ', &PacketP->data[10]);
473 WBYTE(PacketP->data[11], ' '); 470 writeb(' ', &PacketP->data[11]);
474 WBYTE(PacketP->data[12], '\0'); 471 writeb('\0', &PacketP->data[12]);
475 472
476 /* 473 /*
477 ** its two bytes long! 474 ** its two bytes long!
478 */ 475 */
479 WBYTE(PacketP->len, PKT_CMD_BIT | 2); 476 writeb(PKT_CMD_BIT | 2, &PacketP->len);
480 477
481 /* 478 /*
482 ** queue it! 479 ** queue it!
@@ -529,19 +526,15 @@ int From;
529} 526}
530 527
531/* 528/*
532** Routine for handling received data for clist drivers. 529** Routine for handling received data for tty drivers
533** NB: Called with the tty locked. The spl from the lockb( ) is passed.
534** we return the ttySpl level that we re-locked at.
535*/ 530*/
536static void RIOReceive(p, PortP) 531static void RIOReceive(struct rio_info *p, struct Port *PortP)
537struct rio_info *p;
538struct Port *PortP;
539{ 532{
540 struct tty_struct *TtyP; 533 struct tty_struct *TtyP;
541 register ushort transCount; 534 unsigned short transCount;
542 struct PKT *PacketP; 535 struct PKT *PacketP;
543 register uint DataCnt; 536 register unsigned int DataCnt;
544 uchar *ptr; 537 unsigned char *ptr;
545 unsigned char *buf; 538 unsigned char *buf;
546 int copied = 0; 539 int copied = 0;
547 540
@@ -594,9 +587,6 @@ struct Port *PortP;
594 transCount = 1; 587 transCount = 1;
595 while (can_remove_receive(&PacketP, PortP) 588 while (can_remove_receive(&PacketP, PortP)
596 && transCount) { 589 && transCount) {
597#ifdef STATS
598 PortP->Stat.RxIntCnt++;
599#endif /* STATS */
600 RxIntCnt++; 590 RxIntCnt++;
601 591
602 /* 592 /*
@@ -642,28 +632,15 @@ struct Port *PortP;
642 ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the 632 ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the
643 ** driver). 633 ** driver).
644 */ 634 */
645#undef ___DEBUG_IT___ 635 ptr = (unsigned char *) PacketP->data + PortP->RxDataStart;
646#ifdef ___DEBUG_IT___
647 kkprintf("I:%d R:%d P:%d Q:%d C:%d F:%x ", intCount, RxIntCnt, PortP->PortNum, TtyP->rxqueue.count, transCount, TtyP->flags);
648#endif
649 ptr = (uchar *) PacketP->data + PortP->RxDataStart;
650 636
651 tty_prepare_flip_string(TtyP, &buf, transCount); 637 tty_prepare_flip_string(TtyP, &buf, transCount);
652 rio_memcpy_fromio(buf, ptr, transCount); 638 rio_memcpy_fromio(buf, ptr, transCount);
653#ifdef STATS
654 /*
655 ** keep a count for statistical purposes
656 */
657 PortP->Stat.RxCharCnt += transCount;
658#endif
659 PortP->RxDataStart += transCount; 639 PortP->RxDataStart += transCount;
660 PacketP->len -= transCount; 640 PacketP->len -= transCount;
661 copied += transCount; 641 copied += transCount;
662 642
663 643
664#ifdef ___DEBUG_IT___
665 kkprintf("T:%d L:%d\n", DataCnt, PacketP->len);
666#endif
667 644
668 if (PacketP->len == 0) { 645 if (PacketP->len == 0) {
669 /* 646 /*
@@ -674,12 +651,6 @@ struct Port *PortP;
674 remove_receive(PortP); 651 remove_receive(PortP);
675 put_free_end(PortP->HostP, PacketP); 652 put_free_end(PortP->HostP, PacketP);
676 PortP->RxDataStart = 0; 653 PortP->RxDataStart = 0;
677#ifdef STATS
678 /*
679 ** more lies ( oops, I mean statistics )
680 */
681 PortP->Stat.RxPktCnt++;
682#endif /* STATS */
683 } 654 }
684 } 655 }
685 } 656 }
@@ -691,215 +662,3 @@ struct Port *PortP;
691 return; 662 return;
692} 663}
693 664
694#ifdef FUTURE_RELEASE
695/*
696** The proc routine called by the line discipline to do the work for it.
697** The proc routine works hand in hand with the interrupt routine.
698*/
699int riotproc(p, tp, cmd, port)
700struct rio_info *p;
701register struct ttystatics *tp;
702int cmd;
703int port;
704{
705 register struct Port *PortP;
706 int SysPort;
707 struct PKT *PacketP;
708
709 SysPort = port; /* Believe me, it works. */
710
711 if (SysPort < 0 || SysPort >= RIO_PORTS) {
712 rio_dprintk(RIO_DEBUG_INTR, "Illegal port %d derived from TTY in riotproc()\n", SysPort);
713 return 0;
714 }
715 PortP = p->RIOPortp[SysPort];
716
717 if ((uint) PortP->PhbP < (uint) PortP->Caddr || (uint) PortP->PhbP >= (uint) PortP->Caddr + SIXTY_FOUR_K) {
718 rio_dprintk(RIO_DEBUG_INTR, "RIO: NULL or BAD PhbP on sys port %d in proc routine\n", SysPort);
719 rio_dprintk(RIO_DEBUG_INTR, " PortP = 0x%x\n", PortP);
720 rio_dprintk(RIO_DEBUG_INTR, " PortP->PhbP = 0x%x\n", PortP->PhbP);
721 rio_dprintk(RIO_DEBUG_INTR, " PortP->Caddr = 0x%x\n", PortP->PhbP);
722 rio_dprintk(RIO_DEBUG_INTR, " PortP->HostPort = 0x%x\n", PortP->HostPort);
723 return 0;
724 }
725
726 switch (cmd) {
727 case T_WFLUSH:
728 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH\n");
729 /*
730 ** Because of the spooky way the RIO works, we don't need
731 ** to issue a flush command on any of the SET*F commands,
732 ** as that causes trouble with getty and login, which issue
733 ** these commands to incur a READ flush, and rely on the fact
734 ** that the line discipline does a wait for drain for them.
735 ** As the rio doesn't wait for drain, the write flush would
736 ** destroy the Password: prompt. This isn't very friendly, so
737 ** here we only issue a WFLUSH command if we are in the interrupt
738 ** routine, or we aren't executing a SET*F command.
739 */
740 if (PortP->HostP->InIntr || !PortP->FlushCmdBodge) {
741 /*
742 ** form a wflush packet - 1 byte long, no data
743 */
744 if (PortP->State & RIO_DELETED) {
745 rio_dprintk(RIO_DEBUG_INTR, "WFLUSH on deleted RTA\n");
746 } else {
747 if (RIOPreemptiveCmd(p, PortP, WFLUSH) == RIO_FAIL) {
748 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command failed\n");
749 } else
750 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command\n");
751 }
752 /*
753 ** WFLUSH operation - flush the data!
754 */
755 PortP->TxBufferIn = PortP->TxBufferOut = 0;
756 } else {
757 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command ignored\n");
758 }
759 /*
760 ** sort out the line discipline
761 */
762 if (PortP->CookMode == COOK_WELL)
763 goto start;
764 break;
765
766 case T_RESUME:
767 rio_dprintk(RIO_DEBUG_INTR, "T_RESUME\n");
768 /*
769 ** send pre-emptive resume packet
770 */
771 if (PortP->State & RIO_DELETED) {
772 rio_dprintk(RIO_DEBUG_INTR, "RESUME on deleted RTA\n");
773 } else {
774 if (RIOPreemptiveCmd(p, PortP, RESUME) == RIO_FAIL) {
775 rio_dprintk(RIO_DEBUG_INTR, "T_RESUME Command failed\n");
776 }
777 }
778 /*
779 ** and re-start the sender software!
780 */
781 if (PortP->CookMode == COOK_WELL)
782 goto start;
783 break;
784
785 case T_TIME:
786 rio_dprintk(RIO_DEBUG_INTR, "T_TIME\n");
787 /*
788 ** T_TIME is called when xDLY is set in oflags and
789 ** the line discipline timeout has expired. It's
790 ** function in life is to clear the TIMEOUT flag
791 ** and to re-start output to the port.
792 */
793 /*
794 ** Fall through and re-start output
795 */
796 case T_OUTPUT:
797 start:
798 if (PortP->MagicFlags & MAGIC_FLUSH) {
799 PortP->MagicFlags |= MORE_OUTPUT_EYGOR;
800 return 0;
801 }
802 RIOTxEnable((char *) PortP);
803 PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR;
804 /*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"T_OUTPUT finished\n"); */
805 break;
806
807 case T_SUSPEND:
808 rio_dprintk(RIO_DEBUG_INTR, "T_SUSPEND\n");
809 /*
810 ** send a suspend pre-emptive packet.
811 */
812 if (PortP->State & RIO_DELETED) {
813 rio_dprintk(RIO_DEBUG_INTR, "SUSPEND deleted RTA\n");
814 } else {
815 if (RIOPreemptiveCmd(p, PortP, SUSPEND) == RIO_FAIL) {
816 rio_dprintk(RIO_DEBUG_INTR, "T_SUSPEND Command failed\n");
817 }
818 }
819 /*
820 ** done!
821 */
822 break;
823
824 case T_BLOCK:
825 rio_dprintk(RIO_DEBUG_INTR, "T_BLOCK\n");
826 break;
827
828 case T_RFLUSH:
829 rio_dprintk(RIO_DEBUG_INTR, "T_RFLUSH\n");
830 if (PortP->State & RIO_DELETED) {
831 rio_dprintk(RIO_DEBUG_INTR, "RFLUSH on deleted RTA\n");
832 PortP->RxDataStart = 0;
833 } else {
834 if (RIOPreemptiveCmd(p, PortP, RFLUSH) == RIO_FAIL) {
835 rio_dprintk(RIO_DEBUG_INTR, "T_RFLUSH Command failed\n");
836 return 0;
837 }
838 PortP->RxDataStart = 0;
839 while (can_remove_receive(&PacketP, PortP)) {
840 remove_receive(PortP);
841 ShowPacket(DBG_PROC, PacketP);
842 put_free_end(PortP->HostP, PacketP);
843 }
844 if (PortP->PhbP->handshake == PHB_HANDSHAKE_SET) {
845 /*
846 ** MAGIC!
847 */
848 rio_dprintk(RIO_DEBUG_INTR, "Set receive handshake bit\n");
849 PortP->PhbP->handshake |= PHB_HANDSHAKE_RESET;
850 }
851 }
852 break;
853 /* FALLTHROUGH */
854 case T_UNBLOCK:
855 rio_dprintk(RIO_DEBUG_INTR, "T_UNBLOCK\n");
856 /*
857 ** If there is any data to receive set a timeout to service it.
858 */
859 RIOReceive(p, PortP);
860 break;
861
862 case T_BREAK:
863 rio_dprintk(RIO_DEBUG_INTR, "T_BREAK\n");
864 /*
865 ** Send a break command. For Sys V
866 ** this is a timed break, so we
867 ** send a SBREAK[time] packet
868 */
869 /*
870 ** Build a BREAK command
871 */
872 if (PortP->State & RIO_DELETED) {
873 rio_dprintk(RIO_DEBUG_INTR, "BREAK on deleted RTA\n");
874 } else {
875 if (RIOShortCommand(PortP, SBREAK, 2, p->RIOConf.BreakInterval) == RIO_FAIL) {
876 rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
877 }
878 }
879
880 /*
881 ** done!
882 */
883 break;
884
885 case T_INPUT:
886 rio_dprintk(RIO_DEBUG_INTR, "Proc T_INPUT called - I don't know what to do!\n");
887 break;
888 case T_PARM:
889 rio_dprintk(RIO_DEBUG_INTR, "Proc T_PARM called - I don't know what to do!\n");
890 break;
891
892 case T_SWTCH:
893 rio_dprintk(RIO_DEBUG_INTR, "Proc T_SWTCH called - I don't know what to do!\n");
894 break;
895
896 default:
897 rio_dprintk(RIO_DEBUG_INTR, "Proc UNKNOWN command %d\n", cmd);
898 }
899 /*
900 ** T_OUTPUT returns without passing through this point!
901 */
902 /*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"riotproc done\n"); */
903 return (0);
904}
905#endif