Subject: port-i386/5177: PCMCIA port allocations may conflict with display
To: None <>
From: Andreas Gustafsson <>
List: netbsd-bugs
Date: 03/19/1998 16:03:10
>Number:         5177
>Category:       port-i386
>Synopsis:       PCMCIA port allocations may conflict with display
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 19 07:05:02 1998
>Originator:     Andreas Gustafsson
Araneus Information Systems Oy
>Release:        1.3

System: NetBSD 1.3 NetBSD 1.3 (GUAVA) #0: Thu Feb 12 12:46:34 EET 1998 i386


NetBSD 1.3 (i386) sometimes allocates I/O port 0x3c0 to a PCMCIA
device.  This loses, because port 0x3c0 (among others) is used by the
ubiquitous VGA display adapter.  Similar lossage may also occur with
the I/O ports of other display types such as CGA or MDA, but those are
rare on PCMCIA-equipped systems.

This happens because the default PCMCIA ISA I/O port allocation range
(0x300 - 0x3FF) happens to include the ports used by VGA, and the
console drivers fail to reserve these addresses by mapping them using


Attempt to boot a NetBSD 1.3 GENERIC kernel on an IBM ThinkPad 365XDT
with a D-Link DE650 Ethernet card (which, incidentally, is
misidentified as a Linksys card by NetBSD 1.3).  Notice the following
console output:

  ne2 at pcmcia0 function 0 port 0x3c0-0x3cf port 0x3d0-0x3df
  ne2: Linksys EthernetCard Ethernet
  ne2: where did the card go?

Boot the INSTALL kernel, notice that allocations now start at 0x340,
and that the card now works (although it is still misidentified as a


This could be fixed in several ways:

  1. Change pcic_isa_alloc_iobase / pcic_isa_alloc_iosize
     to exclude ports used by common display adapters

  2. Change the console drivers to bus_space_map the I/O ports
     of the display adapters

  3. Reserve the I/O ports used by common display adapters
     during machine-dependent initialization

Here is a patch which implements alternative 2. for the pccons driver
only.  If integrated, something similar needs to be added to pcvt,

*** pccons.c.old	Sat Nov  1 17:02:19 1997
--- pccons.c	Wed Mar 18 21:23:26 1998
*** 65,70 ****
--- 65,71 ----
  #include <machine/pc/display.h>
  #include <machine/pccons.h>
  #include <machine/conf.h>
+ #include <machine/bus.h>
  #include <dev/isa/isareg.h>
  #include <dev/isa/isavar.h>
*** 520,525 ****
--- 521,527 ----
  	struct pc_softc *sc = (void *)self;
  	struct isa_attach_args *ia = aux;
+         bus_space_handle_t ioh;
  	if (crtat == 0)
*** 530,535 ****
--- 532,549 ----
  	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
  	    IPL_TTY, pcintr, sc);
+ 	/* reserve i/o ports to keep pcmcia away */
+         if (bus_space_map(ia->ia_iot, addr_6845, 0x2, 0, &ioh)) {
+ 	    printf("pc: mapping of CRTC registers failed\n");
+ 	}
+ 	if (vs.color) {
+ 	    if (bus_space_map(ia->ia_iot, 0x3C0, 0x10, 0, &ioh)) {
+ 		printf("pc: mapping of VGA registers failed\n");
+ 	    }
+ 	}
  	 * Look for children of the keyboard controller.
  	 * XXX Really should decouple keyboard controller