Deleted Added
sdiff udiff text old ( 279904 ) new ( 280970 )
full compact
1/*-
2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
3 * Copyright (c) 2000, Michael Smith <msmith@freebsd.org>
4 * Copyright (c) 2000, BSDi
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: stable/10/sys/dev/pci/pci.c 279904 2015-03-12 07:07:41Z scottl $");
31
32#include "opt_bus.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/malloc.h>
37#include <sys/module.h>
38#include <sys/linker.h>

--- 48 unchanged lines hidden (view full) ---

87static int pci_porten(device_t dev);
88static int pci_memen(device_t dev);
89static void pci_assign_interrupt(device_t bus, device_t dev,
90 int force_route);
91static int pci_add_map(device_t bus, device_t dev, int reg,
92 struct resource_list *rl, int force, int prefetch);
93static int pci_probe(device_t dev);
94static int pci_attach(device_t dev);
95static void pci_load_vendor_data(void);
96static int pci_describe_parse_line(char **ptr, int *vendor,
97 int *device, char **desc);
98static char *pci_describe_device(device_t dev);
99static int pci_modevent(module_t mod, int what, void *arg);
100static void pci_hdrtypedata(device_t pcib, int b, int s, int f,
101 pcicfgregs *cfg);
102static void pci_read_cap(device_t pcib, pcicfgregs *cfg);

--- 19 unchanged lines hidden (view full) ---

122 u_int irq);
123
124static uint16_t pci_get_rid_method(device_t dev, device_t child);
125
126static device_method_t pci_methods[] = {
127 /* Device interface */
128 DEVMETHOD(device_probe, pci_probe),
129 DEVMETHOD(device_attach, pci_attach),
130 DEVMETHOD(device_detach, bus_generic_detach),
131 DEVMETHOD(device_shutdown, bus_generic_shutdown),
132 DEVMETHOD(device_suspend, pci_suspend),
133 DEVMETHOD(device_resume, pci_resume),
134
135 /* Bus interface */
136 DEVMETHOD(bus_print_child, pci_print_child),
137 DEVMETHOD(bus_probe_nomatch, pci_probe_nomatch),
138 DEVMETHOD(bus_read_ivar, pci_read_ivar),

--- 217 unchanged lines hidden (view full) ---

356Disable this if you depend on BIOS emulation of USB devices, that is\n\
357you use USB devices (like keyboard or mouse) but do not load USB drivers");
358
359static int pci_clear_bars;
360TUNABLE_INT("hw.pci.clear_bars", &pci_clear_bars);
361SYSCTL_INT(_hw_pci, OID_AUTO, clear_bars, CTLFLAG_RDTUN, &pci_clear_bars, 0,
362 "Ignore firmware-assigned resources for BARs.");
363
364static int pci_enable_ari = 1;
365TUNABLE_INT("hw.pci.enable_ari", &pci_enable_ari);
366SYSCTL_INT(_hw_pci, OID_AUTO, enable_ari, CTLFLAG_RDTUN, &pci_enable_ari,
367 0, "Enable support for PCIe Alternative RID Interpretation");
368
369static int
370pci_has_quirk(uint32_t devid, int quirk)
371{

--- 2849 unchanged lines hidden (view full) ---

3221 /* Disable interrupts */
3222 offs = bus_read_1(res, XHCI_CAPLENGTH);
3223 bus_write_4(res, offs + XHCI_USBCMD, 0);
3224 bus_read_4(res, offs + XHCI_USBSTS);
3225 }
3226 bus_release_resource(self, SYS_RES_MEMORY, rid, res);
3227}
3228
3229void
3230pci_add_resources(device_t bus, device_t dev, int force, uint32_t prefetchmask)
3231{
3232 struct pci_devinfo *dinfo;
3233 pcicfgregs *cfg;
3234 struct resource_list *rl;
3235 const struct pci_quirk *q;
3236 uint32_t devid;

--- 56 unchanged lines hidden (view full) ---

3293 xhci_early_takeover(dev);
3294 else if (pci_get_progif(dev) == PCIP_SERIALBUS_USB_EHCI)
3295 ehci_early_takeover(dev);
3296 else if (pci_get_progif(dev) == PCIP_SERIALBUS_USB_OHCI)
3297 ohci_early_takeover(dev);
3298 else if (pci_get_progif(dev) == PCIP_SERIALBUS_USB_UHCI)
3299 uhci_early_takeover(dev);
3300 }
3301}
3302
3303static struct pci_devinfo *
3304pci_identify_function(device_t pcib, device_t dev, int domain, int busno,
3305 int slot, int func, size_t dinfo_size)
3306{
3307 struct pci_devinfo *dinfo;
3308

--- 76 unchanged lines hidden (view full) ---

3385int
3386pci_attach_common(device_t dev)
3387{
3388 struct pci_softc *sc;
3389 int busno, domain;
3390#ifdef PCI_DMA_BOUNDARY
3391 int error, tag_valid;
3392#endif
3393
3394 sc = device_get_softc(dev);
3395 domain = pcib_get_domain(dev);
3396 busno = pcib_get_bus(dev);
3397 if (bootverbose)
3398 device_printf(dev, "domain=%d, physical bus=%d\n",
3399 domain, busno);
3400#ifdef PCI_DMA_BOUNDARY
3401 tag_valid = 0;
3402 if (device_get_devclass(device_get_parent(device_get_parent(dev))) !=
3403 devclass_find("pci")) {
3404 error = bus_dma_tag_create(bus_get_dma_tag(dev), 1,

--- 28 unchanged lines hidden (view full) ---

3433 * the parent pcib what our domain and bus numbers are.
3434 */
3435 domain = pcib_get_domain(dev);
3436 busno = pcib_get_bus(dev);
3437 pci_add_children(dev, domain, busno, sizeof(struct pci_devinfo));
3438 return (bus_generic_attach(dev));
3439}
3440
3441static void
3442pci_set_power_children(device_t dev, device_t *devlist, int numdevs,
3443 int state)
3444{
3445 device_t child, pcib;
3446 struct pci_devinfo *dinfo;
3447 int dstate, i;
3448

--- 499 unchanged lines hidden (view full) ---

3948 if (dinfo->cfg.msi.msi_alloc != 0 || dinfo->cfg.msix.msix_alloc != 0) {
3949 pci_printf(&dinfo->cfg, "Device leaked MSI vectors\n");
3950 (void)pci_release_msi(child);
3951 }
3952 if (resource_list_release_active(rl, dev, child, SYS_RES_MEMORY) != 0)
3953 pci_printf(&dinfo->cfg, "Device leaked memory resources\n");
3954 if (resource_list_release_active(rl, dev, child, SYS_RES_IOPORT) != 0)
3955 pci_printf(&dinfo->cfg, "Device leaked I/O resources\n");
3956
3957 pci_cfg_save(child, dinfo, 1);
3958}
3959
3960/*
3961 * Parse the PCI device database, if loaded, and return a pointer to a
3962 * description of the device.
3963 *

--- 400 unchanged lines hidden (view full) ---

4364
4365 /*
4366 * Perform lazy resource allocation
4367 */
4368 dinfo = device_get_ivars(child);
4369 rl = &dinfo->resources;
4370 cfg = &dinfo->cfg;
4371 switch (type) {
4372 case SYS_RES_IRQ:
4373 /*
4374 * Can't alloc legacy interrupt once MSI messages have
4375 * been allocated.
4376 */
4377 if (*rid == 0 && (cfg->msi.msi_alloc > 0 ||
4378 cfg->msix.msix_alloc > 0))
4379 return (NULL);

--- 543 unchanged lines hidden ---