From owner-FreeBSD-users-jp@jp.freebsd.org  Fri Mar 29 22:47:04 1996
Received: by mail.jp.freebsd.org (8.7.3+2.6Wbeta5/8.7.3) id WAA29484
	Fri, 29 Mar 1996 22:47:04 +0900 (JST)
Received: by mail.jp.freebsd.org (8.7.3+2.6Wbeta5/8.7.3) with SMTP id WAA29479
	for <FreeBSD-users-jp@jp.freebsd.org>; Fri, 29 Mar 1996 22:46:58 +0900 (JST)
Received: by feynman.rsch.tuis.ac.jp (8.6.9+2.4Wb/3.2W6 ) id WAA21195; Fri, 29 Mar 1996 22:46:12 +0900
Date: Fri, 29 Mar 1996 22:46:12 +0900
Message-Id: <199603291346.WAA21195@feynman.rsch.tuis.ac.jp>
To: FreeBSD-users-jp@jp.freebsd.org
From: ojima@rsch.tuis.ac.jp (Atsushi Ojima)
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-2022-JP
X-Mailer: mnews [version 1.19] 1995-07/21(Fri)
Reply-To: FreeBSD-users-jp@jp.freebsd.org
X-Distribute: distribute [version 2.1 (Alpha) patchlevel=19]
X-Sequence: FreeBSD-users-jp 899
Subject: [FreeBSD-users-jp 899] RSB-2000 Serial Driver Patch
Errors-To: owner-FreeBSD-users-jp@jp.freebsd.org
Sender: owner-FreeBSD-users-jp@jp.freebsd.org


  $B>.Eg!w>pJsBgB46H$7$A$c$C$?!"$I$&$7$h$&(B(^^; $B$G$9!#(B

  $B0JA0!"(BFreeBSD(98)-2.0.5R $B$G$N(B RSB-2000 Serial Driver $B$N7o$G$3$N(BML $B$K(B
  $B<ALd$7$?$H$3$m!"(B $BD[0f!w#N#T#T%G!<%?(B $B$5$s$+$i!"(Bsio.c $B$H(B ns16550.h $B$K$D(B
  $B$$$F$N%Q%C%A$rD:$-$^$7$?!#(B

  $BD:$$$?%Q%C%A$O(B2.0R $BMQ(B $B$@$H$N$3$H$G$9$,!"<c43$N=$@5!J$H$$$C$F$b(B.rej$B%U%!(B
  $B%$%k$r<jF0$G=$@5$7$?$@$1!K$G0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bL@$7$?J8=q$C$F$J$$$G$9(B
   $B$+$M$'!&!&(B
  $B!J=PMh$l$PF|K\8l$G!&!&!&!&(B^^; $B!K(B

 --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
*** ./ic/ns16550.h.orig	Fri Mar 17 21:15:53 1995
--- ./ic/ns16550.h	Sat Mar 16 02:25:04 1996
***************
*** 40,46 ****
  /*
   * modified for MC16550II
   */
! 
  #define	com_data	0x000	/* data register (R/W) */
  #define	com_dlbl	0x000	/* divisor latch low (W) */
  #define	com_dlbh	0x100	/* divisor latch high (W) */
--- 40,46 ----
  /*
   * modified for MC16550II
   */
! #if !defined(RSB384)
  #define	com_data	0x000	/* data register (R/W) */
  #define	com_dlbl	0x000	/* divisor latch low (W) */
  #define	com_dlbh	0x100	/* divisor latch high (W) */
***************
*** 52,54 ****
--- 52,70 ----
  #define	com_mcr		0x400	/* modem control register (R/W) */
  #define	com_lsr		0x500	/* line status register (R/W) */
  #define	com_msr		0x600	/* modem status register (R/W) */
+ 
+ #else
+ 
+ #define       com_data        0       /* data register (R/W) */
+ #define       com_dlbl        0       /* divisor latch low (W) */
+ #define       com_dlbh        2       /* divisor latch high (W) */
+ #define       com_ier         2       /* interrupt enable (W) */
+ #define       com_iir         4       /* interrupt identification (R) */
+ #define       com_fifo        4       /* FIFO control (W) */
+ #define       com_lctl        6       /* line control register (R/W) */
+ #define       com_cfcr        6       /* line control register (R/W) */
+ #define       com_mcr         8       /* modem control register (R/W) */
+ #define       com_lsr         10      /* line status register (R/W) */
+ #define       com_msr         12      /* modem status register (R/W) */
+ 
+ #endif
*** sio.c.orig	Sat Mar 16 02:14:40 1996
--- sio.c	Sat Mar 16 02:23:24 1996
***************
*** 131,136 ****
--- 131,142 ----
  #include <i386/isa/ic/ns16550.h>
  #endif
  
+ #ifdef RSB384
+ #undef	COMBRD
+ #define	COMBRD(x)	(1152000 / x)
+ #undef	IO_COMSIZE
+ #define	IO_COMSIZE	1
+ #endif
  /*
   * XXX temporary kludges for 2.0 (XXX TK2.0).
   */
***************
*** 474,482 ****
  static	int	pc98_set_ioport		__P((struct com_s *com, int io_base));
  
  #define com_int_Tx_disable(com) \
! 		pc98_disable_i8251_interrupt(com,IEN_Tx|IEN_TxEMP)
  #define com_int_Tx_enable(com) \
! 		pc98_enable_i8251_interrupt(com,IEN_TxFLAG)
  #define com_int_Rx_disable(com) \
  		pc98_disable_i8251_interrupt(com,IEN_Rx)
  #define com_int_Rx_enable(com) \
--- 480,488 ----
  static	int	pc98_set_ioport		__P((struct com_s *com, int io_base));
  
  #define com_int_Tx_disable(com) \
! 		pc98_disable_i8251_interrupt(com,IEN_TxEMP)
  #define com_int_Tx_enable(com) \
! 		pc98_enable_i8251_interrupt(com,IEN_TxEMP)
  #define com_int_Rx_disable(com) \
  		pc98_disable_i8251_interrupt(com,IEN_Rx)
  #define com_int_Rx_enable(com) \
***************
*** 571,578 ****
--- 577,588 ----
  #if defined(PC98)
  static Port_t likely_com_ports[] = { 0x30,
  #if defined(MC16550)
+ #if defined(RSB384)
+ 				     0xb0, 0xb1,
+ #else
  				     0xd2, 0x8d2,
  #endif
+ #endif
  				   };
  #else
  static Port_t likely_com_ports[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, };
***************
*** 854,863 ****
  	failures[4] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_TXRDY;
  #if defined(PC98)
  	if (idev->id_irq != 0)
! 		failures[5] = pc98_irq_pending(idev) ? 1 : 0;
  #else
  	if (idev->id_irq != 0)
! 		failures[5] = isa_irq_pending(idev) ? 1	: 0;
  #endif
  	failures[6] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_NOPEND;
  
--- 864,873 ----
  	failures[4] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_TXRDY;
  #if defined(PC98)
  	if (idev->id_irq != 0)
! 		failures[5] = pc98_irq_pending(idev) ? 0 : 1;
  #else
  	if (idev->id_irq != 0)
! 		failures[5] = isa_irq_pending(idev) ? 0	: 1;
  #endif
  	failures[6] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_NOPEND;
  
***************
*** 875,884 ****
  	failures[7] = inb(iobase + com_ier);
  #if defined(PC98)
  	if (idev->id_irq != 0)
! 		failures[8] = pc98_irq_pending(idev) ? 1 : 0;
  #else
  	if (idev->id_irq != 0)
! 		failures[8] = isa_irq_pending(idev) ? 1	: 0;
  #endif
  	failures[9] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_NOPEND;
  
--- 885,894 ----
  	failures[7] = inb(iobase + com_ier);
  #if defined(PC98)
  	if (idev->id_irq != 0)
! 		failures[8] = pc98_irq_pending(idev) ? 0 : 1;
  #else
  	if (idev->id_irq != 0)
! 		failures[8] = isa_irq_pending(idev) ? 0	: 1;
  #endif
  	failures[9] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_NOPEND;
  
***************
*** 945,951 ****
--- 955,965 ----
  	com->ihighwater = com->ibuf1 + RS_IHIGHWATER;
  	com->iobase = iobase;
  #if defined(PC98)
+ #if defined(RSB384)
+ 	if((iobase & 0x0f0) != 0xb0) {
+ #else
  	if((iobase & 0x0f0) != 0xd0) {
+ #endif
  		if(pc98_set_ioport(com, iobase) == -1)
  			return 0;
  	} else {
***************
*** 1083,1088 ****
--- 1097,1105 ----
  			kdc_sio[unit].kdc_description =
  			  "Serial port: National 16550A, FIFO disabled";
  		} else {
+ #if defined(RSB384)
+ 		        printf(" fifo enabled");
+ #endif
  			com->hasfifo = TRUE;
  			com->ftl_init = FIFO_TRIGGER_14;
  			com->tx_fifo_size = 16;
***************
*** 1386,1391 ****
--- 1403,1409 ----
  	tp = com->tp;
  	s = spltty();
  	(*linesw[tp->t_line].l_close)(tp, flag);
+ 	com->modem_checking = 0;
  	disc_optim(tp, &(tp->t_termios), com);
  	siostop(tp, FREAD | FWRITE);
  	comhardclose(com);
***************
*** 1782,1788 ****
  			}
  #if defined(PC98)
  			if(IS_8251(com->pc98_if_type))
! 				if ( !(pc98_check_i8251_interrupt(com) & IEN_TxFLAG) )
  					com_int_Tx_enable(com);
  #endif
  			com->optr = ioptr;
--- 1800,1806 ----
  			}
  #if defined(PC98)
  			if(IS_8251(com->pc98_if_type))
! 				if ( !(pc98_check_i8251_interrupt(com) & IEN_TxEMP ) )
  					com_int_Tx_enable(com);
  #endif
  			com->optr = ioptr;
***************
*** 1790,1796 ****
  				/* output just completed */
  #if defined(PC98)
  				if(IS_8251(com->pc98_if_type))
! 					if ( pc98_check_i8251_interrupt(com) & IEN_TxFLAG )
  						com_int_Tx_disable(com);
  #endif
  				com_events += LOTS_OF_EVENTS;
--- 1808,1814 ----
  				/* output just completed */
  #if defined(PC98)
  				if(IS_8251(com->pc98_if_type))
! 					if ( pc98_check_i8251_interrupt(com) & IEN_TxEMP )
  						com_int_Tx_disable(com);
  #endif
  				com_events += LOTS_OF_EVENTS;
***************
*** 1801,1807 ****
  #if defined(PC98)
  		else if (line_status & LSR_TXRDY) {
  			if(IS_8251(com->pc98_if_type))
! 				if ( pc98_check_i8251_interrupt(com) & IEN_TxFLAG )
  					com_int_Tx_disable(com);
  		}
  		if(IS_8251(com->pc98_if_type))
--- 1819,1825 ----
  #if defined(PC98)
  		else if (line_status & LSR_TXRDY) {
  			if(IS_8251(com->pc98om);
  		}
  		if(IS_8251(com->pc98_if_type))
***************
*** 2719,2725 ****
  			log(LOG_ERR, "sio%d: %u more %s%s (total %lu)\n",
  			    unit, delta, error_desc[errnum],
  			    delta == 1 ? "" : "s", total);
! #if 0
  			/*
  			 * XXX if we resurrect this then we should move
  			 * the dropping of the ftl to somewhere with less
--- 2737,2743 ----
  			log(LOG_ERR, "sio%d: %u more %s%s (total %lu)\n",
  			    unit, delta, error_desc[errnum],
  			    delta == 1 ? "" : "s", total);
! #if defined(RSB384)
  			/*
  			 * XXX if we resurrect this then we should move
  			 * the dropping of the ftl to somewhere with less
***************
*** 3261,3267 ****
  	com->pc98_prev_modem_status = msr;
  	delta = ( com->pc98_modem_delta |= delta );
  	splx(s);
! 	if ( tp->t_state & (TS_ISOPEN) ) {
  		if ( delta ) {
  			commint(dev);
  		}
--- 3279,3285 ----
  	com->pc98_prev_modem_status = msr;
  	delta = ( com->pc98_modem_delta |= delta );
  	splx(s);
! 	if ( com->modem_checking || ( tp->t_state & (TS_ISOPEN)) ) {
  		if ( delta ) {
  			commint(dev);
  		}
***************
*** 3303,3309 ****
--- 3321,3331 ----
  	mod |= ~(IEN_Tx|IEN_TxEMP|IEN_Rx);
  	COM_INT_DISABLE
  	tmp = inb( com->intr_ctrl_port ) & ~(IEN_Tx|IEN_TxEMP|IEN_Rx);
+ 	__asm __volatile("jmp .+2");
+ 	__asm __volatile("jmp .+2");
  	outb( com->intr_ctrl_port, (com->intr_enable&=~mod) | tmp );
+ 	__asm __volatile("jmp .+2");
+ 	__asm __volatile("jmp .+2");
  	COM_INT_ENABLE
  }
  
***************
*** 3314,3320 ****
--- 3336,3346 ----
  
  	COM_INT_DISABLE
  	tmp = inb( com->intr_ctrl_port ) & ~(IEN_Tx|IEN_TxEMP|IEN_Rx);
+ 	__asm __volatile("jmp .+2");
+ 	__asm __volatile("jmp .+2");
  	outb( com->intr_ctrl_port, (com->intr_enable|=mod) | tmp );
+ 	__asm __volatile("jmp .+2");
+ 	__asm __volatile("jmp .+2");
  	COM_INT_ENABLE
  }
  
***************
*** 3611,3617 ****
--- 3637,3647 ----
  			break;
  #endif
  	    default:
+ #if defined(RSB384)
+ 			if((iobase & 0x0f0) == 0xb0){
+ #else
  			if((iobase & 0x0f0) == 0xd0){
+ #endif
  				iod->if_type = MC16550;
  				return 0;
  			}

 --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---

 $B2?$+$"$j$^$7$?$i(B net80997@asciinet.or.jp $B$^$?$O(B ojima@maps.or.jp $B$^$G!#(B
 ( ojima@rsch.tuis.ac.jp $B$G$OFO$-$^$;$s$N$G$h$m$7$/!#(B)

                                           +--------------------------+
 +-----------------------------------------+ $B>.Eg(B  $B=_;V!wEl5~>pJsBg3X(B +-+
 | Atsushi Ojima ::::::::::::::::::::::::::+--------------------------+ |
 | Tokyo University of Information Sciences      ojima@rsch.tuis.ac.jp  |
 +------------------------------------------- net80997@asciinet.or.jp---+
