[comp.os.minix] Bruce Evans' TTY driver

jca@pnet01.cts.com (John C. Archambeau) (06/26/89)

I have applied the diffs to clean 1.3d source and I get this problem with term
and zterm.  No echoing back from the modem (/dev/tty1).  No results are
returned or anything.  I know /dev/tty1 works because the RD and SD lights on
my modem function as expected, I'm just not getting anything on back when
dialing out with /dev/tty1.  The kernel and file system recompile with no
problems.  Do I need to set a define?  I have looked through the various
.notes files and I'm uncertain as where to pinpoint the bug.  I have also
tried recompiling zterm, didn't work.  Any assistance will be appreciated.
 

 /*--------------------------------------------------------------------------*
  * Flames: /dev/null (on my Minix partition)
  *--------------------------------------------------------------------------*
  * APRA  : crash!pnet01!jca@nosc.mil
  * INET  : jca@pnet01.cts.com
  * UUCP  : {nosc ucsd hplabs!hd-sdd}!crash!pnet01!jca
  *--------------------------------------------------------------------------*/

jds@mimsy.UUCP (James da Silva) (06/28/89)

In article <4466@crash.cts.com> jca@pnet01.cts.com (John C. Archambeau) writes:
>I have applied the diffs to clean 1.3d source and I get this problem with term
>and zterm.  No echoing back from the modem (/dev/tty1).  No results are
>returned or anything.  I know /dev/tty1 works because the RD and SD lights on
>my modem function as expected, I'm just not getting anything on back when
>dialing out with /dev/tty1.

I had the same problem that John reported.  Tim Bunnell came up with a
patch, and Bruce Evans suggested some improvements to the patch.  I sent the
patch to John, and he reported this morning that it works for him too, so
here it is, with a description from Tim (Tim has trouble posting from Bitnet).

Jaime
...........................................................................
: domain: jds@mimsy.umd.edu				     James da Silva
: path:   uunet!mimsy!jds

==== 
The following is a patch to correct a problem several people have reported
with Bruce Evans' TTY driver.  The problem is a failure to receive
characters on the serial ports.  With help from Bruce and Jaime da Silva the
bug has been cornered in the initialization code for the serial ports in
rs232.c.

The UART register at base address + 1 serves two purposes: with the high
order bit of the Line Control Register clear the register is used to enable
interrupts; when the high order bit of the LCR is set, the same register is
used to load the MSB of the baud rate divisor.

Apparently, some UART chips come up during initialization with that control
bit set.  In that case, attempts to load the interrupt enable register fail.
The solution is to establish the correct state for the line control register
before trying to load the interrupt enable register.  The following patch
does so by calling rs_config (which leaves the line control register in the
correct state) before loading the interrupt enable register.  As a matter of
form, the patch also postpones enabling hardware interrupts until the
initialization sequence has been completed.

Tim Bunnell
Internet: tbunnell@gallux.gallaudet.edu
Bitnet:HTBUNNELL@GALLUE

----------------------------cut here------------------------------------
*** rs232.c     Tue Jun  6 23:57:28 1989
--- rs232.tb    Tue Jun  6 23:42:03 1989
***************
*** 300,306 ****
  int minor;
  {
    register struct rs232_s *rs;
!   int this_8250;

    rs = rs_addr( minor ) = &rs_lines[minor];

--- 301,307 ----
  int minor;
  {
    register struct rs232_s *rs;
!   int this_8250, baud;

    rs = rs_addr( minor ) = &rs_lines[minor];

***************
*** 340,356 ****
    inportb( rs->recv_port );
    inportb( rs->line_status_port );

!   /* Enable interrupts for both interrupt controller and device */
!   if ( minor & 1 )            /* COM2 on IRQ3 */
!     enable_irq( SECONDARY_IRQ );
!   else                                /* COM1 on IRQ4 */
!     enable_irq( RS232_IRQ );
    port_out( rs->int_enab_port, IE_LINE_STATUS_CHANGE | IE_MODEM_STATUS_CHANGE
                               | IE_RECEIVER_READY | IE_TRANSMITTER_READY );

!   /* Tell external device we are ready */
!   istart( rs );
!   return rs_config( minor, DEF_BAUD, DEF_BAUD, LC_NO_PARITY, 1, 8, RAW );
  }


--- 346,369 ----
    inportb( rs->recv_port );
    inportb( rs->line_status_port );

!   /*
!    * Configure the port
!   */
!   baud = rs_config( minor, DEF_BAUD, DEF_BAUD, LC_NO_PARITY, 1, 8, RAW );
!
    port_out( rs->int_enab_port, IE_LINE_STATUS_CHANGE | IE_MODEM_STATUS_CHANGE
                               | IE_RECEIVER_READY | IE_TRANSMITTER_READY );

!   /* Enable interrupts for both interrupt controller and device */
!   if ( minor & 1 )            /* COM2 on IRQ3 */
!     enable_irq( SECONDARY_IRQ );
!   else                                /* COM1 on IRQ4 */
!     enable_irq( RS232_IRQ );
!
!   /* Tell external device we are ready */
!   istart( rs );
!
!   return baud;
  }