Commit Graph

228 Commits

Author SHA1 Message Date
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
Doug Rabson
d37a68d05a Don't try to enable io or memory access for non-standard resource
addresses. This stops resource allocations for e.g. amdpm failing - this
has its own special ways of enabling access.
2003-09-01 15:01:49 +00:00
John Baldwin
729d7ffbcf - Rename PCIx_HEADERTYPE* to PCIx_HDRTYPE* so the constants aren't so long.
- Add a new PCIM_HDRTYPE constant for the field in PCIR_HDRTYPE that holds
  the header type.
- Replace several magic numbers with appropriate constants for the header
  type register and a couple of PCI_FUNCMAX.
- Merge to amd64 the fix to the i386 bridge code to skip devices with
  unknown header types.

Requested by:	imp (1, 2)
2003-08-28 21:22:25 +00:00
Warner Losh
b0cb115fb7 Prefer the uintXX_t to the u_intXX_t names. 2003-08-22 03:11:53 +00:00
Warner Losh
8d50cc0e3e Define PCI_MAXHDRTYPE to be 2. We know about header types 0, 1 and 2.
Update the MI device scanning code to use PCI_MAXHDRTYPE rather than
the hard coded 2.
2003-08-01 21:45:56 +00:00
John Baldwin
3f2a1b0656 Update the 'ps', 'show pci', and 'show ktr' ddb commands to use the new
pager callout instead of homerolling their own paging facility.
2003-07-31 17:29:42 +00:00
Thomas Moestl
3920999db7 Add a new PCI interface method, assign_interrupt, to determine the
interrupt to be used for a device. This is intended solely for internal
use of PCI bus implementations, and exists so that PCI bus drivers
implementing special interrupt assignment methods which require
additional work at the bus level to work right can be easily derived
from the generic driver (or any other one) without resorting to hacks.

It will be used in the sparc64 ofw_pcibus driver, which will be
committed shortly.

Make use of this method in the generic implementation, and add it to
the method table of bus drivers derived from the PCI one.

Reviewed by:	imp, -hackers
2003-07-01 14:08:33 +00:00
Thomas Moestl
036c2cfbfa Allow to write the intpin ivar using the pci_set_intpin() accessor. There
are some Sun PCI devices around which bogusly set intpin to 0, although
they use the intline mechanism; this allows the device driver to correct
that.

Reviewed by:	imp
2003-07-01 13:54:10 +00:00
Yoshihiro Takahashi
403579314a Re-enabled PCI irq routing on pc98. 2003-06-22 06:09:14 +00:00
John-Mark Gurney
e3ee6a27a9 use a REG macro that was already defined.
Reorder how the pci probing in handled.  before adding devices, check to
see if the slot is a multi-function device to see if we should probe all
the functions.

Original idea by:	imp
2003-06-22 02:26:17 +00:00
John Baldwin
bd77aaf980 When we re-route a PCI interrupt, write the new IRQ value into the intline
register.

Reviewed by:	imp
2003-06-09 18:08:46 +00:00
Yoshihiro Takahashi
82cdd526b1 Don't route PCI irq on pc98. 2003-06-08 11:18:35 +00:00
John Baldwin
1beb381637 - Adjust the comment about re-routing PCI interrupts to be less
ia64-specific.
- When trying to re-route interrupts, don't change cfg->intline if the
  re-route fails by returning an invalid vector.  This fixes machines
  without any way of routing interrupts such as older PC's without a
  $PIR table.

We do not currently write the new intline value back to the hardware, but
we should.  That will likely be added in a later commit.
2003-06-07 15:00:19 +00:00
John Baldwin
ba90ccc69a Batton down the hatches!!!
Always route PCI interrupts on i386 UP machines.  I was planning to enable
this for i386 anyways once SMP support is done.  Having this enabled fixes
problems on many people's laptops.

Requested by:	imp
2003-06-04 21:10:15 +00:00
Poul-Henning Kamp
60db3b9e60 Remove unused variable(s).
Remove break after return;

Found by:       FlexeLint
2003-05-31 20:34:36 +00:00
Matthew N. Dodd
c047e5b1a9 Return status for PCI methods '{enable,disable}_{io,busmaster}'.
Reviewed by:	imp
2003-04-16 03:15:08 +00:00
Warner Losh
7f2af527b0 When the driver allocates memory or I/O ports, enable that bit in the
command config register.  At the present, this represents a nop
because these bits should have been set earlier in the process.  In
the future, we'll only set these bits when the driver requests the
resource, not when the bus code detects the resource.

Reviewed by: mdodd
2003-04-15 19:38:18 +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
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
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
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
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
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
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
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
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
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
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
Matthew N. Dodd
ced8202c20 Implement 2 small helper functions:
pci_find_bsf() - Find a device_t by bus/slot/function.
	pci_find_device() - Find a device_t by vendor/device ID.
2002-01-10 00:56:02 +00:00
Thomas Moestl
b7c69fe442 Use the new resource_list_print_type() function to print resource list
contents, and the new __BUS_ACCESSOR macro to construct the accessor
functions.
2001-12-21 21:49:57 +00:00
Jim Pirzyk
417c87d137 Add support for the Intel 82443MX chipset
PR:		kern/33032
MFC after:	1 month
2001-12-21 01:28:59 +00:00
Matthew N. Dodd
47676b530c Don't put variable declarations in header files, put prototypes.
'pci_devq' provides useful information now.
2001-12-19 08:49:11 +00:00
Jonathan Lemon
ae4da68827 Add PCI_ENABLE_IO_MODES option, for BIOSen that neglect this.
Submitted by: Andrew R. Reiter arr@watson.org
2001-10-25 04:44:50 +00:00
Doug Rabson
aa55386965 Re-route interrupts on ia64 so that we can get the I/O SAPIC interrupt
numbers (the BIOS leaves legacy PIC interrupt numbers in the intline
registers).
2001-10-05 10:33:42 +00:00
Nick Hibma
c2d7a52a1b Small nit: Make both prints use 'at device %d.%d'. 2001-09-01 23:06:14 +00:00