Commit Graph

53 Commits

Author SHA1 Message Date
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
Alfred Perlstein
78b226dc81 Silence warning.
When casting a "const void *" to a "struct foo **" you want to actually
cast it to "struct foo * const *" not simply "const struct foo **".
2002-06-01 16:20:27 +00:00
Takanori Watanabe
80f1001813 Make oldcard and newcard kernel module work. 2002-05-30 17:38:00 +00:00
Warner Losh
21677473c6 Revert most of the recent PCI merge. This has proven to be too
unstable for the coming DP1 release.  Instead, I'll develop that on
the IMP_CB_MERGE branch until it is more stable.
2002-03-15 06:41:01 +00:00
Warner Losh
86d1f89423 Cleanup the recent cardbus cleanups. This fixes some of the panics
that I introduced with -v.  However, other problems still remain (including
the loss of interrupts).
2002-03-13 05:38:19 +00:00
Warner Losh
a268f9dbeb Don't use __FBSDID yet. Looks like most (all?) of the rest of the kernel
doesn't do that.
2002-03-07 08:12:40 +00:00
Warner Losh
b3889b6815 Implement hw.cardbus.debug and hw.cardbus.cis_debug to help debug some
of the cardbus problems that people may start seeing.
2002-03-07 08:10:42 +00:00
Warner Losh
a3133b5897 Two style(9) fixes:
- return(foo);	(note parens)
- use __FBSDID()
2002-03-07 00:11:42 +00:00
Warner Losh
8e635fb764 Check for NULL on resource allocation. For the moment, punt, but we should
be smarter about a) cleanup and b) fallback.
2002-03-07 00:05:26 +00:00
Warner Losh
7ba175ac23 Use the pci.c code wherever possible, rather than copying all the pci
code into cardbus and s/pci/cardbus.  This exposes a few pci_*
functions that are now static.

This work is similar to work Justin posted to the mobile list about a
year or two ago, which I have neglected since then.

This is a subset of his current work with the multiple inheritance
newbus architecutre.  When completed, that will eliminate the need for
pci/pci_private.h.

Similar work is needed for the cardbus_cis and pccard_cis code as well.
2002-02-27 05:09:14 +00:00
Jonathan Chen
63fa9f4c0d Part two of this NEWCARD update:
Briefly, the significant changes include:
 * Way better resource management in pccbb, pccard and cardbus.
 * pccard hot-removal now appears to work.
 * support pre-fetchable memory in cardbus.
 * update cardbus to support new pci bus interface functions.
 * Fix CIS reading to no longer use rman_get_virtual().

What's not there, but in the works:
 * pccard needs to do interrupt properly and not read the ISR on single
   function cards.
 * real resource management for pccard
 * a complete implementation of CIS parsing
 * need to look into how to correctly use mutex in pccbb
2001-08-27 00:09:42 +00:00
Jonathan Chen
255b159f5f Non-functional changes to NEWCARD stuff.
This is the first part of a two-part update to NEWCARD.  Changes in this
commit are non-functional, and includes the following:
 * indentation and other changes to meet style(9).
 * other minor style consistancy changes
 * addition of comments
 * renaming of device_t variables to be consistant across all of NEWCARD.

(note that not all style violations are fixed in this commit -- those that
 aren't will be clobbered by the next commit.)
2001-08-26 23:55:34 +00:00
Warner Losh
ca604d262f Use bus_space when reading CIS. This allows us to access it in 8 bit
mode, which is what the standard mandates.

Submitted by: Takanori Watanabe-san
Reviewed by: jhb
2001-06-05 23:42:51 +00:00
Peter Wemm
6f39832c71 This cannot possibly be right:
foo(int *nret)
{
   for (i = 0; i < nret; i++) {
      free(array[i], ....
Fix to do the logically correct thing..  (s/nret/*nret/)
2001-01-07 20:52:42 +00:00
Jonathan Chen
0c95c70577 * Better kld support in pccbb/cardbus
- pccbb no longer needs to remember whether a card is inserted.
  - pccbb reissues insertion on load of cardbus/pccard modules.
  - got rid of unnecessary delays in power functions.
  - Cardbus children are no longer deleted if probe/attach fails.
  - non-attached child devices are reprobed at driver_added.

* CARD interface to read CIS
  - added card_cis_read/card_cis_free interface to read arbitrary CIS
    data.  This currently is only implemented in cardbus.

* pccard begins to work
  - pccard can now use higher memory space (and uses it by default).
  - set_memory_offset interface changed.
  - fixed ccr access, which was broken at multiple locations.
  - implement an interrupt handler - pccard can now share interrupts.
  - resource alloc/release/activate/deactivate functions gutted: some
    resources are allocated by the bridge before the child device is
    probed or attached.  Thus the resource "belongs" to the bridge, and
    the pccard_*_resource functions need to fudge the owner/rid.
  - changed some error conditions to panics to speed debugging.

* Mutex fix - Giant is entered at the beginning of thread
2001-01-06 18:04:55 +00:00
Justin T. Gibbs
fd121bf8af Remove an unused variable.
Properly advance to the next image while searching for the ROM image
that contains CIS data.

KNF an if statement.
2000-11-30 19:14:26 +00:00
Jonathan Chen
d58b9dbc97 This fixes several problems with CIS as suggested by Justin Gibbs:
4) The cardbus CIS code treats the CIS_PTR as a mapping register if
   it is mentioned in the CIS.  I don't have a spec handy to understand
   why the CIS_PTR is mentioned in the CIS, but allocating a memory range
   for it is certainly bogus.  My patch ignores bar #6 to prevent the
   mapping.
   [The pccard spec says that BAR 0 and 7 (-1 and 6 in thic case since we
    did a minus one) is "reserved".  The off by 1 error has been fixed.
    also bar=5 is invalid for IO maps, so we check it.]

5) The CIS code allocated duplicate resources to those already found
   by cardbus_add_resources().  The fix is to pass in the bar computed
   from the CIS instead of the particular resource ID for that bar,
   so bus_generic_alloc_resource succeeds in finding the old resource.
   [fixed, also removed superfluous (and incorrect) writing back to the
    PCI config space.]

7) The CIS code seems to use the wrong bit to determine rather a particular
   register mapping is for I/O or memory space.  From looking at the
   two cards I have, it seems TPL_BAR_REG_AS should be 0x10 instead
   of 0x08.  Otherwise, all registers that should be I/O mapped gain
   a second mapping in memory space.
   [Oops, the spec does say 0x10..., fixed]

Submitted by: Justin Gibbs
2000-11-29 19:38:25 +00:00
Jonathan Chen
49f158ccc8 Oops, broke CIS reading from ROM on my last commit.
This should fix it.
2000-11-29 16:08:01 +00:00