Deleted Added
full compact
pci.c (253120) pci.c (253450)
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>
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: head/sys/dev/pci/pci.c 253120 2013-07-09 23:12:26Z marius $");
30__FBSDID("$FreeBSD: head/sys/dev/pci/pci.c 253450 2013-07-18 15:17:11Z jhb $");
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>

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

146
147 DEVMETHOD(bus_get_dma_tag, pci_get_dma_tag),
148 DEVMETHOD(bus_get_resource_list,pci_get_resource_list),
149 DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
150 DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
151 DEVMETHOD(bus_delete_resource, pci_delete_resource),
152 DEVMETHOD(bus_alloc_resource, pci_alloc_resource),
153 DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
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>

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

146
147 DEVMETHOD(bus_get_dma_tag, pci_get_dma_tag),
148 DEVMETHOD(bus_get_resource_list,pci_get_resource_list),
149 DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
150 DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
151 DEVMETHOD(bus_delete_resource, pci_delete_resource),
152 DEVMETHOD(bus_alloc_resource, pci_alloc_resource),
153 DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
154 DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource),
154 DEVMETHOD(bus_release_resource, pci_release_resource),
155 DEVMETHOD(bus_activate_resource, pci_activate_resource),
156 DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
157 DEVMETHOD(bus_child_detached, pci_child_detached),
158 DEVMETHOD(bus_child_pnpinfo_str, pci_child_pnpinfo_str_method),
159 DEVMETHOD(bus_child_location_str, pci_child_location_str_method),
160 DEVMETHOD(bus_remap_intr, pci_remap_intr_method),
161
162 /* PCI interface */

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

4267out:
4268 return (res);
4269}
4270
4271struct resource *
4272pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
4273 u_long start, u_long end, u_long count, u_int flags)
4274{
155 DEVMETHOD(bus_activate_resource, pci_activate_resource),
156 DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
157 DEVMETHOD(bus_child_detached, pci_child_detached),
158 DEVMETHOD(bus_child_pnpinfo_str, pci_child_pnpinfo_str_method),
159 DEVMETHOD(bus_child_location_str, pci_child_location_str_method),
160 DEVMETHOD(bus_remap_intr, pci_remap_intr_method),
161
162 /* PCI interface */

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

4267out:
4268 return (res);
4269}
4270
4271struct resource *
4272pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
4273 u_long start, u_long end, u_long count, u_int flags)
4274{
4275 struct pci_devinfo *dinfo = device_get_ivars(child);
4276 struct resource_list *rl = &dinfo->resources;
4275 struct pci_devinfo *dinfo;
4276 struct resource_list *rl;
4277 struct resource_list_entry *rle;
4278 struct resource *res;
4277 struct resource_list_entry *rle;
4278 struct resource *res;
4279 pcicfgregs *cfg = &dinfo->cfg;
4279 pcicfgregs *cfg;
4280
4281 if (device_get_parent(child) != dev)
4282 return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child,
4283 type, rid, start, end, count, flags));
4284
4285 /*
4286 * Perform lazy resource allocation
4287 */
4280
4281 if (device_get_parent(child) != dev)
4282 return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child,
4283 type, rid, start, end, count, flags));
4284
4285 /*
4286 * Perform lazy resource allocation
4287 */
4288 dinfo = device_get_ivars(child);
4289 rl = &dinfo->resources;
4290 cfg = &dinfo->cfg;
4288 switch (type) {
4289 case SYS_RES_IRQ:
4290 /*
4291 * Can't alloc legacy interrupt once MSI messages have
4292 * been allocated.
4293 */
4294 if (*rid == 0 && (cfg->msi.msi_alloc > 0 ||
4295 cfg->msix.msix_alloc > 0))

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

4335 return (NULL);
4336 }
4337 }
4338 return (resource_list_alloc(rl, dev, child, type, rid,
4339 start, end, count, flags));
4340}
4341
4342int
4291 switch (type) {
4292 case SYS_RES_IRQ:
4293 /*
4294 * Can't alloc legacy interrupt once MSI messages have
4295 * been allocated.
4296 */
4297 if (*rid == 0 && (cfg->msi.msi_alloc > 0 ||
4298 cfg->msix.msix_alloc > 0))

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

4338 return (NULL);
4339 }
4340 }
4341 return (resource_list_alloc(rl, dev, child, type, rid,
4342 start, end, count, flags));
4343}
4344
4345int
4346pci_release_resource(device_t dev, device_t child, int type, int rid,
4347 struct resource *r)
4348{
4349 struct pci_devinfo *dinfo;
4350 struct resource_list *rl;
4351 pcicfgregs *cfg;
4352
4353 if (device_get_parent(child) != dev)
4354 return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child,
4355 type, rid, r));
4356
4357 dinfo = device_get_ivars(child);
4358 cfg = &dinfo->cfg;
4359#ifdef NEW_PCIB
4360 /*
4361 * PCI-PCI bridge I/O window resources are not BARs. For
4362 * those allocations just pass the request up the tree.
4363 */
4364 if (cfg->hdrtype == PCIM_HDRTYPE_BRIDGE &&
4365 (type == SYS_RES_IOPORT || type == SYS_RES_MEMORY)) {
4366 switch (rid) {
4367 case PCIR_IOBASEL_1:
4368 case PCIR_MEMBASE_1:
4369 case PCIR_PMBASEL_1:
4370 return (bus_generic_release_resource(dev, child, type,
4371 rid, r));
4372 }
4373 }
4374#endif
4375
4376 rl = &dinfo->resources;
4377 return (resource_list_release(rl, dev, child, type, rid, r));
4378}
4379
4380int
4343pci_activate_resource(device_t dev, device_t child, int type, int rid,
4344 struct resource *r)
4345{
4346 struct pci_devinfo *dinfo;
4347 int error;
4348
4349 error = bus_generic_activate_resource(dev, child, type, rid, r);
4350 if (error)

--- 447 unchanged lines hidden ---
4381pci_activate_resource(device_t dev, device_t child, int type, int rid,
4382 struct resource *r)
4383{
4384 struct pci_devinfo *dinfo;
4385 int error;
4386
4387 error = bus_generic_activate_resource(dev, child, type, rid, r);
4388 if (error)

--- 447 unchanged lines hidden ---