Subject: PCMCIA hot swap working
To: None <current-users@netbsd.org>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: current-users
Date: 11/17/1998 13:17:26
Hi folks...

Some of you may have noticed the work I've been doing on PCMCIA
device hot-swap.  This work is a combined effort by Chris Demetriou
(who wrote the config_detach() code), Ken Hornstein, Bill Studenmund,
and myself.

Device detachment now works, and I am able to hot-swap my Xircom
PCMCIA Ethernet card.  I am using this as a test device since my
driver for it is not yet finished, and it doesn't glue itself into
the rest of the network code.  For other PCMCIA Ethernet devices to
support this, some changes to the generic network interface code are
required.  Bill Studenmund has written this code, and it should be
committed shortly.  (Every network driver in the tree will have to
change.)

Note that if you try and swap a device now, the kernel will panic:

    panic: config_detach: forced detach of <device> failed (<error>)

This is because the drivers will return an error code.  Once the ifnet
changes are made, this will stop happening.

For devices which do not yet have a detach entry point, the above
panic will also occur.

I plan on looking at what is required to hot-swap serial devices soon,
and then attack SCSI and IDE controllers.

Below is a demonstration of hot-swap at work.  Once the system was
running, I popped in the Xircom card, then removed it, then popped it
in again.

NetBSD 1.3H (ICKY) #153: Tue Nov 17 11:05:52 PST 1998
    thorpej@icky:/u1/netbsd/src/sys/arch/i386/compile/ICKY
cpu0: family 5 model 4 step 4
cpu0: Intel Pentium/MMX (586-class)
real mem  = 49938432
avail mem = 43954176
using 635 buffers containing 2600960 bytes of memory
mainbus0 (root)
pci0 at mainbus0 bus 0: configuration mode 1
pci0: i/o enabled, memory enabled
pchb0 at pci0 dev 0 function 0
pchb0: Intel 82437MX Mobile System Controller (MTSC) (rev. 0x02)
pcib0 at pci0 dev 1 function 0
pcib0: Intel 82371MX Mobile PCI I/O IDE Xcelerator (MPIIX) (rev. 0x03)
vga1 at pci0 dev 2 function 0: Chips and Technologies 65550 (rev. 0x45)
wsdisplay0 at vga1: console (80x25, vt100 emulation)
Texas Instruments PCI1130 (CardBus bridge, revision 0x04) at pci0 dev 3 function 0 not configured
Texas Instruments PCI1130 (CardBus bridge, revision 0x04) at pci0 dev 3 function 1 not configured
isa0 at pcib0
com0 at isa0 port 0x3f8-0x3ff irq 4: ns16550a, working fifo
com1 at isa0 port 0x2f8-0x2ff irq 3: ns16550a, working fifo
com2 at isa0 port 0x3e8-0x3ef irq 5: ns16550a, working fifo
lpt0 at isa0 port 0x378-0x37b irq 7
wdc0 at isa0 port 0x1f0-0x1f7 irq 14
wd0 at wdc0 channel 0 drive 0: <IBM-DTNA-22160>
wd0: drive supports 16-sector pio transfers, lba addressing
wd0: 2067MB, 4200 cyl, 16 head, 63 sec, 512 bytes/sect x 4233600 sectors
wd0: 32-bits data port
wd0: drive supports PIO mode 4, DMA mode 2
sb0 at isa0 port 0x220-0x237 irq 5 drq 1 drq2 5: dsp v4.13
midi0 at sb0: <SB MIDI UART>
audio0 at sb0
opl0 at sb0: model OPL3
midi1 at opl0: <Yamaha OPL3>
pckbc0 at isa0 port 0x60-0x64
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard
psm0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at psm0
pcppi0 at isa0 port 0x61
midi2 at pcppi0: <PC speaker>
spkr0 at pcppi0
sysbeep0 at pcppi0
npx0 at isa0 port 0xf0-0xff: using exception 16
fdc0 at isa0 port 0x3f0-0x3f7 irq 6 drq 2
pcic0 at isa0 port 0x3e0-0x3e1 iomem 0xd0000-0xd3fff irq 10
pcic0: controller 0 (Intel 82365SL Revision 1) has sockets A and B
pcmcia0 at pcic0 controller 0 socket 0
ne0 at pcmcia0 function 0 port 0x400-0x40f port 0x410-0x41f
ne0: Planet SmartCOM 2000 Ethernet
ne0: Ethernet address 00:00:e8:12:8e:0f
pcmcia1 at pcic0 controller 0 socket 1
apm0 at mainbus0: Power Management spec V1.1
apm0: battery life expectancy: 74%
apm0: A/C state: off
apm0: battery charge state: high
biomask 4040 netmask 4040 ttymask 54c2
wscons: wskbd0 glued to wsdisplay0 (console)
Kernelized RAIDframe activated
WARNING: old BSD partition ID!
boot device: wd0
root on wd0a dumps on wd0b
root file system type: ffs
xe0 at pcmcia1 function 0 port 0x420-0x42f: Xircom CreditCard CE2 Ethernet
xe0: Ethernet address 00:80:c7:45:43:8e, hardware rev. 0
xe0: 10base-2, 10base-T, default 10base-2
xe0 detached
xe0 at pcmcia1 function 0 port 0x420-0x42f: Xircom CreditCard CE2 Ethernet
xe0: Ethernet address 00:80:c7:45:43:8e, hardware rev. 0
xe0: 10base-2, 10base-T, default 10base-2

Jason R. Thorpe                                       thorpej@nas.nasa.gov
NASA Ames Research Center                            Home: +1 408 866 1912
NAS: M/S 258-5                                       Work: +1 650 604 0935
Moffett Field, CA 94035                             Pager: +1 650 940 5942