Commit Graph

70 Commits

Author SHA1 Message Date
John Baldwin
3a6b4b04ab Fix an error case I missed in the previous change so that the CIS resource
is fully cleaned up if we fail to find the CIS in the devices ROM.
2009-12-30 22:34:26 +00:00
John Baldwin
767dff0ac9 Delete the CIS resource after releasing it. This is needed when the CIS is
stored in a BAR since the CIS BAR is mapped before the PCI bus driver
enumerates all the BARs.  Without this change, the PCI bus driver would
attempt to initialize a BAR that was already allocated resulting in a panic.
2009-12-30 20:49:13 +00:00
John Baldwin
4e8790e943 Teach the PCI bus driver to handle PCIR_BIOS BARs properly and remove special
handling for the PCIR_BIOS decoding enable bit from the cardbus driver.
The PCIR_BIOS BAR does include type bits like other BARs.  Instead, it is
always a 32-bit non-prefetchable memory BAR where the low bit is used as a
flag to enable decoding.

Reviewed by:	imp
2009-12-30 20:47:14 +00:00
John Baldwin
f26d7f8e95 Use bus_*() rather than bus_space_*(). 2009-12-30 20:42:07 +00:00
Warner Losh
e6d3b1bd2a Minorly improved debugging. Use the DEVPRINTF macro and report the
offset for memory when mapping in the CIS.
2009-03-13 05:31:27 +00:00
Warner Losh
a7de0b74a7 Overhaul of CIS parsing, next step: keep a cached copy of the CIS,
read before we configure the card, so we can implement
/dev/cardbus*.cis.  Also, do this on a per-child basis, so we now have
a different name than before.  I think i'll have to fix that for some
legacy tools to keep working.

I can now do a dumpcis on my running atheros card and have it still work!
2008-11-17 01:32:29 +00:00
Warner Losh
e371fa4547 First step in cleaning up CIS parsing and /dev/cardbus*.cis: remove
redundant malloc/free.  Add comments about how this should really be
done.  Fix an overly verbose comment about under 1MB mapping: go ahead
and set the bits, but we ignore them.
2008-11-15 05:22:06 +00:00
Warner Losh
89558ee870 Use child (the card) in preference to cbdev (the bridge) when
allocating resources to read the CIS.  I'm not sure when this changed,
but it is totally wrong.  Also, add a minor improvement to the
debugging.

This should help everybody trying to run dumpcis on atheros wireless
card as well.

MFC after:	2 days
2008-11-03 06:06:22 +00:00
Warner Losh
17ee700be6 gcc 4.2 thinks that tupleid is uninitialized. Or might be used
uninitialized.  It gets passed into other routines that initialize
it...  Cope by initializing.

Submitted by: mjacob
2007-06-08 04:03:57 +00:00
Warner Losh
4b3337405d Change PCIM_CIS_ASI_TUPLE to _CONFIG.
Add PCI_MAX_BAR_0
minor style nit.
Add PCIM_CIS_CONFIG_MASK
2007-05-16 18:42:38 +00:00
Warner Losh
1acd1e20a1 Minor cleanup of CIS parsing. 2006-06-12 03:28:42 +00:00
Warner Losh
9dfcc6624c Better error message when the CIS is a non-standards conforming '0'. 2006-06-12 03:20:44 +00:00
Warner Losh
bee89c7386 Use the child to allocate the resource rather than bridge, since we're
allocating a resource that's in the card itself.

Remove more now-redundant resource_list_add, and now-redunant code
that lives in the pci layer.

# This fixes the atheros card that I have which had its CIS in one of
# the BARs.  Don't know yet if this fixes the amd64 issues reported.
2006-01-03 03:36:17 +00:00
Warner Losh
c732cf3b2c Minor style(9) hacking, plus use a macro in place of (struct resource *)~0UL
(what the heck does that mean?).
2006-01-03 03:16:53 +00:00
Tai-hwa Liang
93d9fd1136 Fixing build bustage. 2005-12-31 01:45:40 +00:00
Warner Losh
f3d3468db3 The RID2BAR macro returns a number, not a bitmask. Fix this.
Spotted by: ru, jhb
2005-12-30 19:23:32 +00:00
Warner Losh
3cd242d123 Retire BARBIT in favor of new PCI_RID2BAR. 2005-12-29 23:41:29 +00:00
Warner Losh
47147ce799 Implement /dev/cardbus%d.cis, same thing as /dev/pccard%d.cis. There
are some rough edges with this still, but it seems to work well enough
to commit.
2005-12-29 01:43:47 +00:00
Warner Losh
41ac33a2b6 Eliminate even more duplication, and move some definitions into pcireg.h 2005-10-28 05:55:52 +00:00
Warner Losh
495036f25b Simplify code a little, prefer PCI?_FOO registers where possible. 2005-10-28 05:30:47 +00:00
Warner Losh
509cfe6fb0 Be more verbose on errors with CIS reading. This should be a noop, but
appears to fix the ath problem that had been reported.  I don't see how
it can, so there's likely some other hidden bug.
2005-02-20 20:36:16 +00:00
Warner Losh
440b5ade31 Move resource allocation routines from cardbus_cis.c to cardbus.c.
They have nothing at all to do with CIS parsing.

Remove some unused funce parsing: nothing used the results.

Use more of pccard_cis.h's deifnitions for the cardbus specific cis
parsing we do.  More work is needed in this area.

This reduces the size of the cardbus module by 380 bytes or so...
2005-02-06 21:03:13 +00:00
Warner Losh
2dd5c91ebb Use the standard FreeBSD license
Approved by: imp, jon
2005-01-13 19:12:10 +00:00
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Warner Losh
a7c43559c1 Add note about why we're ignoring the below 1MB bit. 2004-04-11 19:22:25 +00:00
Nate Lawson
5f96beb9e0 Convert callers to the new bus_alloc_resource_any(9) API.
Submitted by:	Mark Santcroos <marks@ripe.net>
Reviewed by:	imp, dfr, bde
2004-03-17 17:50:55 +00:00
Warner Losh
4ea2d18aa4 remove obsolete quirks for cardbus cis. none have proven to be needed. 2003-10-07 03:40:17 +00:00
Warner Losh
a294cdb6b5 o move the cis tuple definitions into a common file.
o minor optimization of cardbus_cis processing.  Remove a bunch of generic
  entries that are handled by generic.
o no longer need the card_get_type stuff.
2003-10-07 03:33:54 +00:00
John Baldwin
5e7c50d04d Remove prototype for decode_tuple_copy() which was axed in the last
revision to fix compile.
2003-10-06 21:21:55 +00:00
Warner Losh
f6e01094a4 remove the cardbus cis reading code. nobody ever used it and it has
locking issues down to the api level.
2003-10-06 15:56:29 +00:00
John Baldwin
e27951b29c Use PCIR_BAR(x) instead of PCIR_MAPS.
Glanced over by:	imp, gibbs
Tested by:		i386 LINT
2003-09-02 17:30:40 +00:00
David E. O'Brien
aad970f1fe Use __FBSDID().
Also some minor style cleanups.
2003-08-24 17:55:58 +00:00
Poul-Henning Kamp
b44f808797 Don't leak "barlist" allocation on failure.
Found by:	FlexeLint
2003-06-01 09:24:17 +00:00
Warner Losh
f9aedaa4ba Ignore the 'must allocate below 1MB' flag for the TPL_BAR_REG. It is
set on realtek cards, but they work without it (and don't work with
it).  The standard seems to imply that this is just a hint anyway, so
this should be harmless.  It doesn't appear to be set on any other
cardbus cards that I have (or have seen).

This should make the rl based CardBus cards work again.  I've been
running it for about a month now.

Approved by: re@ (jhb)
2003-05-24 23:23:41 +00:00
Warner Losh
6d9fcd03be MFp4: when you can't allocate a resource, print a message, don't panic. 2003-04-08 07:05:16 +00:00
Warner Losh
a163d034fa Back out M_* changes, per decision of the TRB.
Approved by: trb
2003-02-19 05:47:46 +00:00
Warner Losh
51715fe79d Move the resource handling down into the pci bus as well.
Minor CIS resource allocation code cleanup
Remove some fairly useless debug writes.

This finishes the work to move as much cardbus code as possible into
pci.  We wind up removing 800-odd lines from cardbus.c: we go from
1285 to 400 lines.

Reviewed by: mdodd
2003-02-18 21:24:00 +00:00
Scott Long
72d3502e50 Sanity check the BAR length reported by the CIS with the BAR length that
is encoded in the PCI BAR.  The latter is more reliable.

This allows the sio/modem function of the Xircom RealPort ethernet+modem
card to work.  Note that there still seem to be issues with sio_pci not
releasing resources on detach.
2003-02-17 23:47:31 +00:00
Scott Long
1e962d0012 Clean up the CIS BAR parsing code by removing several pointless checks.
Don't complain about the Option ROM BAR type since it's perfectly valid.
2003-02-16 00:20:24 +00:00
Warner Losh
22acd92b68 MF-p4:
Kill the slightly bogus #define for DECODE_PROTOTYPE
	Be less verbose.  Hide most (all I hope) of the CIS
	parsing behind cardbus_debug_cis (which is set with
	hw.cardbus.debug_cis=1).

	This doesn't fix problems with parsing, but should make cardbus
	less chatty.  There appears to be some issues still with the
	parsing of the CIS, but this won't fix them.

Prompted by: scottl
2003-02-12 06:11:47 +00:00
Warner Losh
0cba409706 Whitespace nits. 2003-02-12 04:48:15 +00:00
Warner Losh
66e390feb6 MFp4:
u_int*_t -> uint*_t to conform more closely with C99.
2003-01-27 05:47:01 +00:00
Alfred Perlstein
44956c9863 Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
2003-01-21 08:56:16 +00:00
Warner Losh
fbe9cff112 Implement PCI_IVAR_ETHADDR. Cardbus has the MAC addr in the CIS,
sometimes, so return it when requested and it does.  Also a little
more infrastructure for a few other things.

Submitted by: sam
Approved by: re (blanket for NEWCARD)
2002-11-27 06:56:29 +00:00
Warner Losh
01f2fb65c3 minor correction to comment 2002-11-14 05:10:16 +00:00
Scott Long
9fb92b64ad When parsing the CIS, if a BAR tuple is encountered, enable the corresponding
bit in the PCI command register for the device.  Otherwise, device drivers
that look at this register to see which types of BARs are usable will think
that none of them are.
This allows my Adaptec 1480A cardbus card to finally work.

Reviewed by:	imp
2002-11-13 22:53:48 +00:00
Scott Long
1e06ae9969 Fix two typos from the previous commit. This code is definitely infectious. 2002-11-12 09:45:59 +00:00
Scott Long
e6e272b905 Step one of cleaning and fixing cardbus:
- Fix some especially bad style in the CIS BAR tuple parsing code.
 - activate Option ROMS correctly.
 - de-obfuscate the Option ROM image selection code.
 - Fix mis-interpretation of the PCI spec that prevented Option ROMs whose
   CIS section wasn't in the first image from working.
 - Fix mis-interpretation of the PCI spec that prevented CIS's mapped into
   MEMIO space from working at all.
 - Reject invalid CIS pointers.

Reviewed by:	imp
2002-11-12 08:23:27 +00:00
John Baldwin
02ccdce8db Use the explicit value 0xffffffff instead of assuming that is what ~0UL
equals.

Approved by:	imp
2002-11-06 20:40:29 +00:00
Warner Losh
214c0b3da4 Don't leak the bar list for each thing we allocate.
# This code really needs a rewrite

Spotted by the eagle eyes of: phk
2002-09-29 18:07:29 +00:00