proto_bus_pci.c (284079) | proto_bus_pci.c (284315) |
---|---|
1/*- 2 * Copyright (c) 2014 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 10 unchanged lines hidden (view full) --- 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2014 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 10 unchanged lines hidden (view full) --- 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> |
27__FBSDID("$FreeBSD: head/sys/dev/proto/proto_bus_pci.c 284079 2015-06-06 16:09:25Z marcel $"); | 27__FBSDID("$FreeBSD: head/sys/dev/proto/proto_bus_pci.c 284315 2015-06-12 12:27:10Z marcel $"); |
28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/bus.h> 32#include <sys/conf.h> 33#include <sys/kernel.h> 34#include <sys/module.h> 35#include <machine/bus.h> --- 41 unchanged lines hidden (view full) --- 77 return (BUS_PROBE_HOOVER); 78} 79 80static int 81proto_pci_attach(device_t dev) 82{ 83 struct proto_softc *sc; 84 struct resource *res; | 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/bus.h> 32#include <sys/conf.h> 33#include <sys/kernel.h> 34#include <sys/module.h> 35#include <machine/bus.h> --- 41 unchanged lines hidden (view full) --- 77 return (BUS_PROBE_HOOVER); 78} 79 80static int 81proto_pci_attach(device_t dev) 82{ 83 struct proto_softc *sc; 84 struct resource *res; |
85 uint32_t val; |
|
85 int bar, rid, type; 86 87 sc = device_get_softc(dev); 88 89 proto_add_resource(sc, PROTO_RES_PCICFG, 0, NULL); 90 proto_add_resource(sc, PROTO_RES_BUSDMA, 0, NULL); 91 92 for (bar = 0; bar < PCIR_MAX_BAR_0; bar++) { 93 rid = PCIR_BAR(bar); | 86 int bar, rid, type; 87 88 sc = device_get_softc(dev); 89 90 proto_add_resource(sc, PROTO_RES_PCICFG, 0, NULL); 91 proto_add_resource(sc, PROTO_RES_BUSDMA, 0, NULL); 92 93 for (bar = 0; bar < PCIR_MAX_BAR_0; bar++) { 94 rid = PCIR_BAR(bar); |
94 type = SYS_RES_MEMORY; | 95 val = pci_read_config(dev, rid, 4); 96 type = (PCI_BAR_IO(val)) ? SYS_RES_IOPORT : SYS_RES_MEMORY; |
95 res = bus_alloc_resource_any(dev, type, &rid, RF_ACTIVE); | 97 res = bus_alloc_resource_any(dev, type, &rid, RF_ACTIVE); |
96 if (res == NULL) { 97 type = SYS_RES_IOPORT; 98 res = bus_alloc_resource_any(dev, type, &rid, 99 RF_ACTIVE); 100 } 101 if (res != NULL) 102 proto_add_resource(sc, type, rid, res); | 98 if (res == NULL) 99 continue; 100 proto_add_resource(sc, type, rid, res); 101 if (type == SYS_RES_IOPORT) 102 continue; 103 /* Skip over adjacent BAR for 64-bit memory BARs. */ 104 if ((val & PCIM_BAR_MEM_TYPE) == PCIM_BAR_MEM_64) 105 bar++; |
103 } 104 105 rid = 0; 106 type = SYS_RES_IRQ; 107 res = bus_alloc_resource_any(dev, type, &rid, RF_ACTIVE | RF_SHAREABLE); 108 if (res != NULL) 109 proto_add_resource(sc, type, rid, res); 110 return (proto_attach(dev)); 111} 112 113DRIVER_MODULE(proto, pci, proto_pci_driver, proto_devclass, NULL, NULL); | 106 } 107 108 rid = 0; 109 type = SYS_RES_IRQ; 110 res = bus_alloc_resource_any(dev, type, &rid, RF_ACTIVE | RF_SHAREABLE); 111 if (res != NULL) 112 proto_add_resource(sc, type, rid, res); 113 return (proto_attach(dev)); 114} 115 116DRIVER_MODULE(proto, pci, proto_pci_driver, proto_devclass, NULL, NULL); |