Subject: ESP patches to com.c
To: Robert Dobbs <banshee@gabriella.resort.com>
From: Michael L. VanLoon -- HeadCandy.com <michaelv@HeadCandy.com>
List: port-i386
Date: 09/10/1995 20:46:29
I finally found a patch you sent in late August to the port-i386 list
which makes com.c look for and use a Hayes ESP card.  It seems to work
ok (haven't had any problems), but the probing has a logic error in
it.  You assume that the port number the ESP returns (PC COM1-4, I
assume) is the same as the port it has been assigned to in NetBSD,
which is incorrect.  For example (from a patched com.c)...

        /* Check for ability to emulate 16550: bit 8 == 1 */
        outb(iobase + ESP_CMD1, ESP_GETDIPS);
1) ==>  val = inb(iobase + ESP_STATUS1);
        if ((val & 0x80) == 0) {
                printf(": ESP slave");
                return;
        }

        /* Determine which com port this ESP card services: bits 0,1 */
1) ==>  val &= 0x03;    /* Mask off all but bits 0,1 */

        /* sc->sc_dev.dv_unit is the com port: 0..3 */
2) ==>  if (sc->sc_dev.dv_unit == val) {
                sc->sc_hwflags |= COM_HW_ESP;
                printf(": ESP");
        }

In (1), you get the PC COM port the ESP has been configured to use.
In (2), you get the NetBSD com port.  In my config, these aren't the
same.  From dmesg:

	com0 at isa0 port 0x3e8-0x3ef irq 9: ns16550a, working fifo
	com1 at isa0 port 0x3f8-0x3ff irq 4: ns16550a, working fifo
	com2 at isa0 port 0x2f8-0x2ff irq 3: ESP: ns16550a, working fifo

>From my config file:

	# Hayes ESP board:
	com0    at isa? port 0x3e8 irq 9        # at PC COM3

	# "standard" PeeCee com ports:
	com1    at isa? port 0x3f8 irq 4        # at PC COM1
	com2    at isa? port 0x2f8 irq 3        # at PC COM2

As you can see, I have my ESP configured to think it is PC COM3 (out
of 1-4).  However, I place it in the NetBSD com list at com0 (out of
0-3).  Don't ask why -- I just do. :-) PC COM1 and COM2 (out of 1-4)
are at NetBSD com1 and com2 (out of 0-3).  As you can see, it
identifies my 16550 port, which in hardware is a boca serial/parallel
card, as the ESP because of this matching.

I don't have the ESP programming spec, so I can't implement the
change.  But, what I think might be the solution is for you to probe
the ESP for which PC COM base address it thinks it's supposed to use
(like 0x3f8, 0x3e8, etc.), and see if that matches iobase.  What do
you think?

Anyway, thanks for the driver.  I'm glad to see someone persevered and
actually spent the time to get this thing functional beyond the base
16550 emulation.

-----------------------------------------------------------------------------
  Michael L. VanLoon                                 michaelv@HeadCandy.com
       --<  Free your mind and your machine -- NetBSD free un*x  >--
     NetBSD working ports: 386+PC, Mac, Amiga, HP300, Sun3, Sun4, PC532,
                           DEC pmax (MIPS R2k/3k), DEC/AXP (Alpha)
     NetBSD ports in progress: VAX and others...
-----------------------------------------------------------------------------