Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 09 Dec 1996 10:04:26 -0800
From:      Paul Traina <pst@shockwave.com>
To:        Michael Smith <msmith@atrad.adelaide.edu.au>, Andrew.Gordon@net-tel.co.uk, nate@freebsd.org
Cc:        mobile@freebsd.org, hackers@freebsd.org, pst@jnx.com
Subject:   Re: need help with a PC CARD NE2000 clone...
Message-ID:  <199612091804.KAA01333@precipice.shockwave.com>

next in thread | raw e-mail | index | archive | help

[This is a response to Michael and Andrew's suggestions (thanks) with a
 comprehensive debugging session and some observations about the dumpcis
 output at the end.]

> Are you using stock -current. or have you added the PAO patches over the top?

-current

> Try removing the "ether" line if you are running stock -current.  This
> tells the PAO code to look in the CIS for the hardware address, while
> my modifications to the 'ed' driver dig it out from the normal
> location hung off the 8390 as per the NE-2000.

Tried both ways.

> > Code 240 not found

> I've never seen this message before.  Try paring your /etc/pccardd.conf
> file right down to the bone, in case this is a syntax error there.

Tried it.

> > I've set up ed0 and ed1 in my kernel config as follows (just in case the
> > card wanted to be at fixed places or have fixed irq's):
> 
> As long as you have a message coming up after the 'ed0' signon saying 
> "pccard driver ed0 added", there's a free 'ed' device for the card probe to
> attach to.

Yep, that's OK.  It seems to be bailing out long before we even play
driver games.

> I can't find an "allocate_memory" in any of the -current pccard-related
> sources, so I have to assume that you've applied the PAO patches.

No, I did /not/.  Sorry, gdb trace will explain all

> Note that if this really is an NE2000 clone, it doesn't need any
> memory address space  (the on-card RAM  is driven by i/o) - unlike some
> of the other cards supported by the ed driver.

Yeah, I agree.  Why does it have two blocks of memory?

> On the other hand, the card claims to have memory on it (from dumpcis).
> Perhaps its an "enhanced" NE2000 which can be memory-addressed in
> some proprietary way?  This could cause confusion, where pccardd
> knows the card has memory and that ed usually wants to use memory,
> but in this case has probed it as an NE2000 and decided that it
> doesn't need any.

I agree with you, but it's bailing long before it even decides to play
ed0 games (I think).  It's failing in assign_io() which is calling the
memory alloc block check routine with 1024 bytes, which is smaller than
MEMUNIT.  urk?

Here are all the details....


I did some more debugging on my ethernet card problem.  It looks like
we're failing long before we even start to play driver games.

To recap, here's the data, plus a gdb trace:

# cat /etc/pccard.conf
# Sample PCCARD configuration file
#
# Removing all IRQ conflicts from this file can't be done because of some
# IRQ-selfish PC-cards.  So if you want to use some of these cards in
# your machine, you will be forced to modify their IRQ parameters from
# the following list.
#
# IRQ == 0 means "allocate free IRQ from IRQ pool"
# IRQ == 16 means "do not use IRQ (e.g. PIO mode)"
#
# $Id: pccard.conf.sample,v 1.4 1996/06/19 01:28:07 nate Exp $

# Generally available IO ports
io	0x240-0x360
# Generally available IRQs (Built-in sound-card owners remove 5)
irq	3 5 10 11 13 15
# Available memory slots
memory	0xd0000  96k				(I've tried this at d4000)

card "PMX   " "PE-200"
	config	0x1 "ed0" 11
#	ether	0xff0				(I've tried it with & without)
	insert  echo PMX PE-200 Ethernet inserted
	insert	/etc/pccard_ether ed0
	remove  echo PMX PE-200 Ethernet removed
	remove	/sbin/ifconfig ed0 delete

dmesg: 

Copyright (c) 1992-1996 FreeBSD Inc.
Copyright (c) 1982, 1986, 1989, 1991, 1993
	The Regents of the University of California.  All rights reserved.

FreeBSD 2.2-961208-SNAP #1: Mon Dec  9 00:40:47  1996
    root@foo.shockwave.com:/usr/src/sys/compile/LAP
Calibrating clock(s) relative to mc146818A clock ... i8254 clock: 1193312 Hz
CPU: i486DX (486-class CPU)
real memory  = 8388608 (8192K bytes)

FreeBSD Kernel Configuration Utility - Version 1.1
 Type "help" for help or "visual" to go to the visual
 configuration interface (requires MGA/VGA display or
 serial terminal capable of displaying ANSI graphics).
config> ls
Device   port       irq   drq   iomem   iosize   unit  flags      enabled
fdc0     0x3f0      6     2     0x0     0        0     0x0        Yes
wdc0     0x1f0      14    -1    0x0     0        0     0x80ff80ff Yes
sc0      0x60       1     -1    0x0     0        0     0x0        Yes
sio0     0x3f8      4     -1    0x0     0        0     0x0        Yes
sio1     0x2f8      3     -1    0x0     0        1     0x0        Yes
pca0     0x40       -1    -1    0x0     0        0     0x0        Yes
lpt0     0xffffffff 7     -1    0x0     0        0     0x0        Yes
psm0     0x60       12    -1    0x0     0        0     0x0        Yes
ed0      0x300      11    -1    0xd8000 0        0     0x0        Yes
ed1      0x310      5     -1    0xd8000 0        1     0x0        Yes
npx0     0xf0       13    -1    0x0     0        0     0x0        Yes
apm0     0x0        -1    -1    0x0     0        0     0x0        Yes
config> iomem ed0 0xd4000
config> ls
Device   port       irq   drq   iomem   iosize   unit  flags      enabled
fdc0     0x3f0      6     2     0x0     0        0     0x0        Yes
wdc0     0x1f0      14    -1    0x0     0        0     0x80ff80ff Yes
sc0      0x60       1     -1    0x0     0        0     0x0        Yes
sio0     0x3f8      4     -1    0x0     0        0     0x0        Yes
sio1     0x2f8      3     -1    0x0     0        1     0x0        Yes
pca0     0x40       -1    -1    0x0     0        0     0x0        Yes
lpt0     0xffffffff 7     -1    0x0     0        0     0x0        Yes
psm0     0x60       12    -1    0x0     0        0     0x0        Yes
ed0      0x300      11    -1    0xd4000 0        0     0x0        Yes
ed1      0x310      5     -1    0xd8000 0        1     0x0        Yes
npx0     0xf0       13    -1    0x0     0        0     0x0        Yes
apm0     0x0        -1    -1    0x0     0        0     0x0        Yes
config> q
avail memory = 6819840 (6660K bytes)
PC-Card Intel 82365 (5 mem & 2 I/O windows)
pcic: controller irq 3
Probing for devices on the ISA bus:
sc0 at 0x60-0x6f irq 1 on motherboard
sc0: VGA color <16 virtual consoles, flags=0x0>
pccard driver ed added
ed0 not found at 0x300
ed1: disabled, not probed.
pccard driver sio added
sio0 at 0x3f8-0x3ff irq 4 on isa
sio0: type 16450
sio1 not found at 0x2f8
pca0 on motherboard
pca0: PC speaker audio driver
lpt0 at 0x378-0x37f irq 7 on isa
lpt0: Interrupt-driven port
lp0: TCP/IP capable interface
psm0 at 0x60-0x64 irq 12 on motherboard
psm0: device ID 0, 2 buttons?
fdc0 at 0x3f0-0x3f7 irq 6 drq 2 on isa
fdc0: NEC 765
fd0: 1.44MB 3.5in
wdc0 at 0x1f0-0x1f7 irq 14 flags 0x80ff80ff on isa
wdc0: unit 0 (wd0): <HITACHI_DK222A-54>, multi-block-16
wd0: 516MB (1058400 sectors), 1050 cyls, 16 heads, 63 S/T, 512 B/S
npx0 on motherboard
npx0: INT 16 interface
apm0 on isa
apm: found APM BIOS version 1.1
Card inserted, slot 1

# cat /etc/motd
FreeBSD 2.2-961208-SNAP (LAP) #1: Mon Dec  9 00:40:47  1996
(-current as of yesterday, no PAO patches)

# gdb pccardd
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.13 (i386-unknown-freebsd), 
Copyright 1994 Free Software Foundation, Inc...
(gdb) break assign_io
Breakpoint 1 at 0x1b39: file cardd.c, line 464.
(gdb) run -d -v
Starting program: /usr/src/usr.sbin/pccard/pccardd/pccardd -d -v
Card manuf PMX   , vers PE-200
Configuration entries:
	Index code = 0x1, driver name = ed0
Insert commands are:
	echo PMX PE-200 Ethernet inserted
	/etc/pccard_ether ed0
Remove commands are:
	echo PMX PE-200 Ethernet removed
	/sbin/ifconfig ed0 delete
Code 240 not found
Code 240 not found
code Unknown ignored

Breakpoint 1, assign_io (sp=0x19100) at cardd.c:464
464		cis = sp->cis;
(gdb) n
465		defconf = cis->def_config;
(gdb) print *cis
$1 = {tlist = 0x18160, manuf = "PMX   ", '\000' <repeats 13 times>, 
  vers = "PE-200", '\000' <repeats 13 times>, 
  add_info1 = "ETHERNET", '\000' <repeats 11 times>, 
  add_info2 = "R01", '\000' <repeats 16 times>, maj_v = 4 '\004', 
  min_v = 1 '\001', last_config = 1 '\001', ccrs = 1 '\001', reg_addr = 256, 
  attr_mem = {valid = 1 '\001', type = 5 '\005', speed = 3 '\003', 
    wps = 0 '\000', addr = 0 '\000', units = 1 '\001'}, common_mem = {
    valid = 1 '\001', type = 13 '\r', speed = 4 '\004', wps = 1 '\001', 
    addr = 0 '\000', units = 3 '\003'}, def_config = 0x1d080, conf = 0x1d080}
(gdb) n
466		for (cisconf = cis->conf; cisconf; cisconf = cisconf->next)
(gdb) n
467			if (cisconf->id == sp->config->index)
(gdb) print *cisconf
$2 = {next = 0x0, pwr = 0, timing = 0, iospace = 1, irq = 1, memspace = 1, 
  misc_valid = 0, id = 1 '\001', io_blks = 2 '\002', io_addr = 10 '\n', 
  io_bus = 2 '\002', io = 0x1a1c0, irqlevel = 0 '\000', irq_flags = 48 '0', 
  irq_mask = 48892, memwins = 2 '\002', mem = 0x1a1e0, misc = 0 '\000'}
(gdb) print *sp
$3 = {next = 0x19080, fd = 8, mask = 0, slot = 1, name = 0x1a0d0 "/dev/card1", 
  state = filled, cis = 0x19180, card = 0x180a0, config = 0x180c0, 
  card_config = 0x0, devname = '\000' <repeats 15 times>, 
  eaddr = "\000\000\000\000\000", io = {next = 0x0, addr = 0, size = 0, 
    flags = 0, cardaddr = 0}, mem = {next = 0x0, addr = 0, size = 0, 
    flags = 0, cardaddr = 0}, irq = 0}
(gdb) print *sp->config
$4 = {next = 0x0, index = 1 '\001', driver = 0x180e0, irq = 11, flags = 0, 
  inuse = 1 '\001'}
(gdb) n
469		if (cisconf == 0)
(gdb) n
471		sp->card_config = cisconf;
(gdb) n
477		if (cisconf->memspace || (defconf && defconf->memspace)) {
(gdb) n
480			mp = cisconf->mem;
(gdb) print cisconf->memspace
$5 = 1
(gdb) print defconf
$6 = (struct cis_config *) 0x1d080
(gdb) print defconf->memspace
$7 = 1
(gdb) print cisconf
$8 = (struct cis_config *) 0x1d080

NOTE: cisconf and defconf are the same???

(gdb) n
481			if (!cisconf->memspace)
(gdb) n
483			sp->mem.size = mp->length;
(gdb) n
484			sp->mem.cardaddr = mp->address;
(gdb) n
487			sp->mem.addr = sp->config->driver->mem;
(gdb) n
492			if (sp->mem.size && sp->mem.addr == 0) {
(gdb) print *sp
$9 = {next = 0x19080, fd = 8, mask = 0, slot = 1, name = 0x1a0d0 "/dev/card1", 
  state = filled, cis = 0x19180, card = 0x180a0, config = 0x180c0, 
  card_config = 0x1d080, devname = '\000' <repeats 15 times>, 
  eaddr = "\000\000\000\000\000", io = {next = 0x0, addr = 0, size = 0, 
    flags = 0, cardaddr = 0}, mem = {next = 0x0, addr = 0, size = 1024, 
    flags = 0, cardaddr = 0}, irq = 0}

NOTE: why is sp->mem.size == 1024? <----------------------------

(gdb) n
493				sp->mem.addr = alloc_memory(mp->length);
(gdb) s
alloc_memory (size=-272639028) at util.c:125
125		i = bit_fns(mem_avail, MEMBLKS, size / MEMUNIT);

(gdb) print *mem_avail @200  (oops, should have just printed 12 bytes)

$10 = {"\000\000\000\000\000\000\000\000\000\000\000\000\000PMX   \000\000\000\000\000\000\000\000\000\000PE-200\000\000\000\000\000\000\000\000\000\000ed0", '\000' <repeats 13 times>, "ed", '\000' <repeats 14 times>, "\220 \001\000\000P\001", '\000' <repeats 13 times>, " \201\001\000\000\000\000\000\000\000\000\0000 \001\000@P\001", '\000' <repeats 13 times>, "@\201\001\000\000\000\000\000\000\000\000\000/dev/card0\000\000\000\000\000\000/dev/card1\000\000\000\000\000\000\000!\001\000\001\000\000\000\003\000\000\000p \001\000\\003\000\000\000\000"}
(gdb) s
bit_fns (nm=0x1a030 "", nbits=96, count=0) at util.c:106
106		int     found = 0;
(gdb) where
#0  bit_fns (nm=0x1a030 "", nbits=96, count=0) at util.c:106
#1  0x341f in alloc_memory (size=1024) at util.c:125
#2  0x1bb6 in assign_io (sp=0x19100) at cardd.c:493
#3  0x18b5 in card_inserted (sp=0x19100) at cardd.c:323
#4  0x1696 in slot_change (sp=0x19100) at cardd.c:246
#5  0x15ec in readslots () at cardd.c:216
#6  0x1257 in main (argc=3, argv=0xefbfdd04) at cardd.c:105
(gdb) up
#1  0x341f in alloc_memory (size=1024) at util.c:125
125		i = bit_fns(mem_avail, MEMBLKS, size / MEMUNIT);
(gdb) print size
$12 = 1024
(gdb) n
108		for (i = 0; i < nbits; i++)
(gdb) print nbits
$13 = 96
(gdb) n
109			if (bit_test(nm, i)) {
(gdb) print 96 / 8
$14 = 12
(gdb) n
113				found = 0;
(gdb) n
108		for (i = 0; i < nbits; i++)
(gdb) print i
$15 = 0
(gdb) n
109			if (bit_test(nm, i)) {
(gdb) n
113				found = 0;
(gdb) n
108		for (i = 0; i < nbits; i++)
(gdb) n
109			if (bit_test(nm, i)) {
(gdb) n
113				found = 0;
(gdb) n
108		for (i = 0; i < nbits; i++)
(gdb) n
109			if (bit_test(nm, i)) {
(gdb) n
113				found = 0;
(gdb) n
108		for (i = 0; i < nbits; i++)
(gdb) n
109			if (bit_test(nm, i)) {
(gdb) n
113				found = 0;
(gdb) n
108		for (i = 0; i < nbits; i++)
(gdb) n
109			if (bit_test(nm, i)) {
(gdb) n
113				found = 0;
(gdb) n
108		for (i = 0; i < nbits; i++)
(gdb) n
109			if (bit_test(nm, i)) {
(gdb) n
113				found = 0;
(gdb) n
108		for (i = 0; i < nbits; i++)
(gdb) print i
$16 = 6
(gdb) fin
Run till exit from #0  bit_fns (nm=0x1a030 "", nbits=96, count=0) at util.c:108
0x341f in alloc_memory (size=1024) at util.c:125
125		i = bit_fns(mem_avail, MEMBLKS, size / MEMUNIT);
Value returned is $17 = -1
(gdb) n
126		if (i < 0)
(gdb) n
127			return (0);
(gdb) n
130	}
(gdb) n
assign_io (sp=0x19100) at cardd.c:494
494				if (sp->mem.addr == 0)
(gdb) print sp->mem.addr
$18 = 0
(gdb) n
536					return (-1);
(gdb) c
Continuing.
cardd: Resource allocation failure for PMX   

Here's the pccardc dumpcis output again (look where I put arrows):


Code 240 not found
Code 240 not found
code Unknown ignored
Configuration data for card in slot 1
Tuple #1, code = 0x1 (Common memory descriptor), length = 3
    000:  dc 03 ff
	Common memory device information:
		Device number 1, type Function specific, WPS = ON
		Speed = 100nS, Memory block size = 32Kb, 1 units
Tuple #2, code = 0x17 (Attribute memory descriptor), length = 3
    000:  53 01 ff
	Attribute memory device information:
		Device number 1, type FLASH EEPROM, WPS = OFF
		Speed = 150nS, Memory block size = 2Kb, 1 units
Tuple #3, code = 0x21 (Functional ID), length = 2
    000:  06 03
	Network/LAN adapter - POST initialize - Card has ROM
Tuple #4, code = 0x15 (Version 1 info), length = 30
    000:  04 01 50 4d 58 20 20 20 00 50 45 2d 32 30 30 00
    010:  45 54 48 45 52 4e 45 54 00 52 30 31 00 ff
	Version = 4.1, Manuf = [PMX   ],card vers = [PE-200]
	Addit. info = [ETHERNET],[R01]
Tuple #5, code = 0x1a (Configuration map), length = 5
    000:  01 01 00 01 01
	Reg len = 2, config register addr = 0x100, last config = 0x1
	Registers: X------- 
Tuple #6, code = 0x1b (Configuration entry), length = 25
    000:  c1 81 78 ca 61 00 03 0f 10 03 0f 30 fc be c9 04
    010:  00 00 40 0d 40 40 00 40 0d
	Config index = 0x1(default)
	Interface byte = 0x81 (I/O)  wait signal supported
	Card decodes 10 address lines, limited 8/16 Bit I/O
		I/O address # 1: block start = 0x300 block length = 0x10
		I/O address # 2: block start = 0x310 block length = 0x10
		IRQ modes: Level
		IRQs:  4 5 10 11 12 13 14 15
-> why? what could this be for?  It's 1k long?
->	Memory descriptor 1
->		 blk length = 0x400 card addr = 0x000 host addr = 0xd4000
	Memory descriptor 2
		 blk length = 0x4000 card addr = 0x4000 host addr = 0xd4000
Tuple #7, code = 0x0 (Null tuple), length = 9
    000:  57 42 20 4c 41 4e 20 20 ff
Tuple #8, code = 0x14 (No link), length = 0
Tuple #9, code = 0xff (Terminator), length = 0
2 slots found



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612091804.KAA01333>