Commit Graph

63 Commits

Author SHA1 Message Date
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
Warner Losh
5794c59372 Move the pnp and location info into the common pci bus. Make all known
pci busses implement this.

Also minor comment smithing in cardbus.  Fix copyright to this year
with my name on it since I've been doing a lot to this file.

Reviewed by: jhb
2003-02-17 21:20:35 +00:00
Warner Losh
29575b16f5 Kill a now-bogus comment 2003-02-17 19:48:39 +00:00
Warner Losh
50cc4892cb Move call to pci_print_verbose until after all the variables that it
depends on.

Pointy hat to: imp (anybody know if these things are accepted at Eco-Cycle?)
2003-02-17 04:13:44 +00:00
Warner Losh
387ca2cc8a Checkpoint a work in progress:
o Use the common pci_* routines in preference to the copied and hacked
  routines from an ancient pci.c.

This saves 509 lines in cardbus.c.  More savings to follow when I
convert the resource code over.  In the past when I've done this the
resource code conversion breaks cardbus in subtle ways so I'm doing a
1/2 way checkpoint this time.  cardbus still works for me the same as
it did before.

It also looks like cardbus devices now show up as pci bus devices to
pciconf -l, but maybe that was happening before.

Inspired by a patch from Justin Gibbs many moons ago.  When he
finishes his kobj multiple inheritance work, we can transition the
finished version of this work to that fairly easily.
2003-02-16 02:06:50 +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
9476c349dd MFp4:
Second part of the kldload patches for cardbus.  This makes
	kldload of a driver for a device that's inserted now appears
	to work.  To make it work, we only do a power cycle of the card
	if there's no children drivers attached.

	This likely is papering over bogosities in the power system.  The
	power sequence needs to be re-written, so I'll not worry about
	the papering over until the re-write.
2003-02-12 05:57:02 +00:00
Warner Losh
78b389be87 MFp4:
Don't reach inside of rman to r_dev.  Use rman_get_device instead.
2003-02-12 05:54:22 +00:00
Warner Losh
0cba409706 Whitespace nits. 2003-02-12 04:48:15 +00:00
Warner Losh
9ca938eb11 Don't turn off the power of cards when new drivers are added
unconditionally.  kldloading a cardbus driver was shooting down other
attached devices because most drivers assume that one cannot
power-cycle cards w/o the driver knowning about it.

Submitted by: simokawa-san
2003-02-11 05:31:35 +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
3a28284461 Need more parens here.
Approved by: re (blanket)
2002-11-27 17:30:41 +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
d0c36f94f7 MFp4:
o Add a diagnostic for an 'impossible' condition.
o Collapse common code.
2002-11-14 05:12:02 +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
bcaa6b0541 MFp4:
o Always release the resources on device detach.
o Attach resources the same with driver added as we do we do in the insert
  case (maybe this should be a routine).
o signal the wakeup of the thread on resume instead of trying to force an
  interrupt.
o Minor debug hacks.
o use 0xffffffff instead of -1 for uint32_t items.
o Don't complain when we're asked to detach no cards.  This is normal.
o Eliminate the now worthless second parameter to card_detach_card.
o minor style(9)isms

Some of these patches may be from: iwasaki-san, jhb, iadowse
2002-11-02 23:00:28 +00:00
Warner Losh
aa7bc3b3fc o Add routines to return the location and pnpinfo for this card.
Note, we return the PCI pnp info, but in fact that's wrong to do
  since that data is not defined for CardBus cards.  CardBus says that
  these registers are undefined and one should use the CIS to do
  device matching.  To date, all CardBus cards have had these
  registered defined, no doubt because they are using common silicon
  to produce both the PCI cards and the CardBus cards.  However, it isn't
  any worse than the rest of the system, so just note it in passing and
  move on.
o Also sort prototypes while I'm here.
2002-10-07 23:00:51 +00:00
Warner Losh
0a9e69cc6f Don't abuse the fact that -a == ~a + 1. Signed vs unsigned checkers
complain when a is a unsigned type.  So instead use the latter here
and be on our way.

Spotted by: flexlint by way of phk
2002-10-07 22:58:24 +00:00
Warner Losh
c5d5c855b7 Add extra set of parens around the barbit macro to make it clear what
we're intending to shift.

Spotted by: flexlint by way of phk (should fix about 40 messages)
2002-10-07 22:57:07 +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
Andrew R. Reiter
b2c6ac5b2b - Forgot to remove cardattached declaration in revision 1.22. 2002-09-10 16:50:06 +00:00
Warner Losh
17a39a01e9 Remove more bogus reprobe code. I don't think it is needed here either. 2002-09-10 06:37:02 +00:00
Warner Losh
6c596e8d0b pccbb -> cbb 2002-08-15 08:02:23 +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
Warner Losh
3799207059 Get rid of the bogus DETACH_NOWARN and don't warn when asked to detach
a card that isn't there unless we're booting verbose.  It serves no
purpose.
2002-02-07 06:43:02 +00:00
Warner Losh
a432b68b87 Add support for suspending/resuming CardBus bridges.
We really should have and use power state information, but none exists
today.

Submitted by: YAMAMOTO Shigeru-san <shigeru@iij.ad.jp>
2001-12-15 05:58:28 +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
Warner Losh
887e2e5d65 Fix memory leaks with dev_get_children().
Submitted by: Jeroen Ruigrok/Asmodai <asmodai@wxs.nl>
2001-02-08 21:47:45 +00:00
Jeroen Ruigrok van der Werven
f09deb6962 Fix typo: wierd -> weird.
There is no such thing as wierd in the english language.
2001-02-06 09:25:10 +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