Commit Graph

304 Commits

Author SHA1 Message Date
Poul-Henning Kamp
7ac40f5f59 Gigacommit to improve device-driver source compatibility between
branches:

Initialize struct cdevsw using C99 sparse initializtion and remove
all initializations to default values.

This patch is automatically generated and has been tested by compiling
LINT with all the fields in struct cdevsw in reverse order on alpha,
sparc64 and i386.

Approved by:    re(scottl)
2003-03-03 12:15:54 +00:00
Stefan Eßer
1fa4dd2f14 Make /dev/pci use MAJOR_AUTO. 2003-03-01 08:57: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
2c422e4625 Include class designation in pnpinfo for generic driver loading 2003-02-18 03:25:57 +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
180811460d These don't need to be semi-public after all. 2003-02-17 19:47:02 +00:00
Warner Losh
594b5aeb67 Use rman_get_device rather than rle->resl->r_dev.
make pci_hdrtypedata and pci_read_extcap accessible (but maybe in the end
   we'll make them private again).
2003-02-16 02:02:44 +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
Benno Rice
2c2d1d071e Make the base pcib_route_interrupt method available to other pci-pci bridge
sub-classes.

This allows the powerpc kernel to build again.

Forgotten by:	benno
Spotted by:	grehan
2003-01-14 11:37:56 +00:00
Warner Losh
a8b354a809 Properly account for prefetchable memory when a request is being made.
We allow the request to go through if it matches either a prefetchable
or a non-prefetchable part of the bridge.  We do not check to make
sure it is the right kind of memory because most drivers to not yet
properly set RF_PREFETCHABLE (only cardbus seems to do so, and I'm not
entirely sure it does it right).  RF_PREFETCHABLE was invented for
cardbus, so hasn't been properly documented yet.

This is still overridable by hw.pci.allow_unsupported_io_ranges, but
the need for that is greatly reduced, especially for the nvida driver.

Approved by: re
Reviewed by: jhb and many testers
Submitted by: Matt Emmerton (although this has been reworked somewhat)
2002-12-03 08:34:20 +00:00
Warner Losh
ba5fc4eed2 Add a new cardbus specific ivar: PCI_IVAR_ETHADDR. Some pci-like
buses support querying the MAC address in a standard-for-that-bus way.
The base pci bus returns NULL for this IVAR always.

Submitted by: sam
Approved by: re (blanket for NEWCARD)
2002-11-27 06:41:28 +00:00
John Baldwin
1bbf246462 Fix a couple of bugs in host_pcib_get_busno():
- If a PCI device is not present, then a 32-bit read_config() is going to
  return 0xffffffff not 0xffff.
- For the 82454NX chipset, the MIOC that we read the bus numbers of the
  various host-PCI bridges from is at function (slot) 0x10 not 0x0.

Approved by:	re (rwatson)
2002-11-25 21:53:14 +00:00
John Baldwin
b173edafc7 Add a function host_pcib_get_bnsno() that attempts to determine the bus
number of the child bus of a host to PCI bridge by reading from proprietary
configuration registers in the host to PCI bridge devices.

Approved by:	re
2002-11-22 17:50:47 +00:00
Maxime Henrion
d541eb80c6 Unbreak kernel build.
Submitted by:	Hiten Pandya <hiten@angelica.unixdaemons.com>
2002-11-13 17:34:12 +00:00
Matthew N. Dodd
1c54ff3315 Convert kernel compile option PCI_ALLOW_UNSUPPORTED_IO_RANGE to
a loader tunable hw.pci.allow_unsupported_io_range.

Submitted by:	 Hiten Pandya <hiten@angelica.unixdaemons.com>
Approved by:	 re (murray)
2002-11-13 09:42:25 +00:00
Matthew N. Dodd
04211a9bcc Staticize local variable.
Submitted by:	 Hiten Pandya <hiten@angelica.unixdaemons.com>
Obtained from:	 re (murray)
2002-11-13 09:40:09 +00:00
Ian Dowse
58164331e3 Save and restore the interrupt Edge/Level Control Registers (ELCR)
across system suspends on the Intel 82371AB PCI-ISA bridge. On a
Sony Vaio C1XD that I have, these registers are not set correctly
after an ACPI resume. The result is that after resuming, a shared
IRQ is left in edge-triggered mode so the interrupt can later become
jammed in a state where the line remains asserted, but the handler
is never called.

Reviewed by:	jhb
2002-10-30 19:55:06 +00:00
John Baldwin
f371d460e6 Whitespace. 2002-10-16 19:11:59 +00:00
Bruce Evans
7e3998a3de Removed the only PCI_DEBUG ifdef in the kernel. PCI_DEBUG was not a
supported option and it disabled a whole 2 lines of bootverbose messages.
I wanted to see 1 of the messages (about the latency timers).  This
is a wrong place to decode pci configurations, but the code is already
here and handles more details than pciconf(8).
2002-10-01 13:28:24 +00:00
Poul-Henning Kamp
b13866404a The bus number is unsigned, it cannot be less than zero.
Found by:	FlexeLint
2002-10-01 10:18:22 +00:00
Poul-Henning Kamp
b28a0fe196 Don't use GCC shorthand for ?: unless it really matters. 2002-09-28 17:47:51 +00:00
John Baldwin
38906aed9a Export pcib_attach() as a "protected" for use in subclasses of the PCI-PCI
bridge driver.
2002-09-06 22:14:00 +00:00
John Baldwin
cea0a89545 Prefer the physical bus number of the PCI bus as the unit of the pciX
device created.
2002-09-06 16:09:07 +00:00
John Baldwin
c6a121ab5e Make the printf messages when routing interrupts more consistent in the
various PCI bridge drivers.
2002-09-05 17:08:35 +00:00
John Baldwin
dd699396ce Fix up a comment. 2002-09-04 03:53:21 +00:00
John Baldwin
1d62131385 - Make pci_load_vendor_data() static and do it during MOD_LOAD instead of
when the first PCI bus attaches.
- Create /dev/pci during MOD_LOAD as well.
- Destroy /dev/pci during MOD_UNLOAD (not that you can kldunload pci, but
  might as well get the code right)
2002-09-04 03:13:16 +00:00
Guido van Rooij
7251aa2022 Add a new command: show pciregs, equivalent to pciconf -l
Reviewed by:	Doug Rabson (quite some time ago)
MFC after:	1 week
2002-08-28 10:02:59 +00:00
John Baldwin
2ccfc93222 Overhaul the ACPI PCI bridge driver a bit:
- Add an ACPI PCI-PCI bridge driver (the previous driver just handled
  Host-PCI bridges) that is a PCI driver that is a subclass of the generic
  PCI-PCI bridge driver.  It overrides probe, attach, read_ivar, and
  pci_route_interrupt.
  - The probe routine only succeeds if our parent is an ACPI PCI bus which
    we test for by seeing if we can read our ACPI_HANDLE as an ivar.
  - The attach routine saves a copy of our handle and calls the new
    acpi_pcib_attach_common() function described below.
  - The read_ivar routine handles normal PCI-PCI bridge ivars and adds an
    ivar to return the ACPI_HANDLE of the bus this bridge represents.
  - The route_interrupt routine fetches the _PRT (PCI Interrupt Routing
    Table) from the bridge device's softc and passes it off to
    acpi_pcib_route_interrupt() to route the interrupt.
- Split the old ACPI Host-PCI bridge driver into two pieces.  Part of
  the attach routine and most of the route_interrupt routine remain in
  acpi_pcib.c and are shared by both ACPI PCI bridge drivers.
  - The attach routine verifies the PCI bridge is present, reads in
    the _PRT for the bridge, and attaches the child PCI bus.
  - The route_interrupt routine uses the passed in _PRT to route a PCI
    interrupt.
  The rest of the driver is the ACPI Host-PCI bridge specific bits that
  live in acpi_pcib_acpi.c.
  - We no longer duplicate pcib_maxslots but use it directly.
  - The driver now uses the pcib devclass instead of its own devclass.
    This means that PCI busses are now only children of pcib devices.
  - Allow the ACPI_HANDLE for the child PCI bus to be read as an ivar
    of the child bus.
  - Fetch the _PRT for routing PCI interrupts directly from our softc
    instead of walking the devclass to find ourself and then fetch our
    own softc.

With this change and the new ACPI PCI bus driver, ACPI can now properly
route interrupts for devices behind PCI-PCI bridges.  That is, the
Itanium2 with like 10 PCI busses can now boot ok and route all the PCI
interrupts.  Hopefully this will also fix problems people are having with
CardBus bridges behind PCI-PCI bridges not properly routing interrupts
when ACPI is used.

Tested on:	i386, ia64
2002-08-26 18:30:27 +00:00
John Baldwin
6f0d58848f Export a few symbols as globals to allow subclassing of this driver. In
OOP speak, you would mark these as 'protected' members.  Specifically:
- Make the pcib_softc struct public so it can be used by subclasses.
- Make pcib_{read,write}_ivar(), pcib_alloc_resource(), pcib_maxslots(),
  and pcib_{read,write}_config() globals that can be used by subclasses.
- Make the pcib devclass a global variable.
- Move most of the pcib_attach() function into a global
  pcib_attach_common() function that can be called by the attach routines
  of subclasses.

Tested on:	i386, alpha, sparc64, ia64
2002-08-26 15:57:08 +00:00
John Baldwin
42dbeaee02 Various changes to make it easier to subclass the PCI bus device.
- Make the pci devclass a global variable.
- Add child devices in pci_attach() instead of pci_probe().  Change
  pci_probe() to just check for a valid bus number from the associated
  bridge and return -1000 if successful.  This allows subclasses of the
  PCI bus driver to override the generic driver.
- Move the code to load the vendor data into its own public function.
  Really though, doing this at attach is just plain wrong.  This should
  really be done in the module load routine instead.  As a side effect,
  the 'busno' variable in pci_attach() is now no longer static (minor
  bug that was harmless so far.)
- Change pci_add_children() to take an extra argument that is the size of
  the device info structure passed to pci_read_device() and make it public
  so subclasses of the PCI bus can call it in their attach routines.
- Move the bits to attach a probed PCI child to a PCI bus into a global
  pci_add_child() function.  This will allow subclasses that can detect
  a PCI device not found in the normal PCI probe to add those devices in
  their own attach routine.  (I have seen this in the ACPI tree on my
  laptop for example.)  As a side effect, change the static function
  pci_add_resources() to get the busno, slot, and func from the passed
  in dinfo structure instead of requiring them as function arguments.

Tested on:	i386, alpha, ia64, sparc64
2002-08-26 15:23:52 +00:00
Maxime Henrion
258682384f style(9) nit. 2002-08-19 22:51:23 +00:00
Maxime Henrion
e9cf2ddb50 Use the __BUS_ACCESSOR macro for PCIB_ACCESSOR instead of
reimplementing it.

Reviewed by:	tmm
2002-08-19 22:50:08 +00:00
Warner Losh
b8182b24d7 While PCI interrupts are shareable, this should not have been committed just
yet.
2002-08-02 22:26:03 +00:00
Warner Losh
a850203de0 Make PCI_ENABLE_IO_MODES a sysctl hw.pci.enable_io_modes. It can also
be set at boot time.  It defaults to 1 now since it can be set in the
boot loader.  If this proves unwise, we can reset it to defaulting to 0.
2002-07-26 07:58:16 +00:00
Warner Losh
a1e85ec6fb 0 is not an invalid interrupt in the PCI world (just in the ia32
world), do not treat it as such.  This fixes the alpha boot problem.

Reviewed by: drew, des
2002-06-07 15:28:16 +00:00
Justin T. Gibbs
eda578ae9f Add some PCI-X register definitions.
PCIM_CMD_SERREN -> PCIM_CMD_SERRESPEN to be consistent with
the PERR definition.
2002-06-05 22:25:51 +00:00
Warner Losh
d508dd347c Use PCI_INTERRUPT_VALI in stead of hard coded 255 2002-06-01 05:48:58 +00:00
Warner Losh
3c2d2c7cea More style(9) nits 2002-06-01 05:44:45 +00:00
Warner Losh
f60115a36c Define a PCI_INVALID_IRQ to augment PCI_INTERRUPT_VALID 2002-06-01 05:40:33 +00:00
Warner Losh
c9579f73e0 Make this file mostly conform to style(9).
Approved by: msmith in principle before walkabout
2002-06-01 03:41:02 +00:00
Matthew N. Dodd
10e38949b4 Add MODULE_VERSION. 2002-04-17 00:31:32 +00:00
Warner Losh
8961964d97 Fix an edge case wrt membase, but more changes needed 2002-04-13 05:52:35 +00:00
Nick Hibma
2334e40985 intline == 0 is not a valid intline on 386. See pci_cfgintr() in
sys/i386/pci/pci_cfgreg.c.

This should resolve some cases where adding USB support to the kernel
produced an interrupt storm.
2002-04-10 07:35:28 +00:00
Warner Losh
20fe00734b Add 5th parameter to pci_read_device specifying the size of the object
to create.
2002-03-13 16:32:11 +00:00
John Baldwin
a854ed9893 Simple p_ucred -> td_ucred changes to start using the per-thread ucred
reference.
2002-02-27 18:32:23 +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
1efefb2d4d Fix warnings introduced in the PCI_ALLOW_UNSUPPORTED_IO_RANGE case. 2002-02-26 03:31:35 +00:00
Poul-Henning Kamp
6e47a4f646 Allow PCI_ALLOW_UNSUPPORTED_IO_RANGE to leave broken setups broken enough
to work.
2002-02-22 11:21:02 +00:00
Warner Losh
12b8c86eee Put the stard/end adjustments back. They are needed. Also make start
== 0 a special case.  I hope this fixes the real problem that phk and
others were seeing.
2002-02-19 07:05:22 +00:00
Mike Smith
8046c4b998 Don't claim to have routed an interrupt when the method actually returned an
error.
2002-02-12 01:28:49 +00:00