apb.c (133589) | apb.c (145610) |
---|---|
1/*- 2 * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier 3 * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> 4 * Copyright (c) 2000 BSDi 5 * Copyright (c) 2001, 2003 Thomas Moestl <tmm@FreeBSD.org> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 16 unchanged lines hidden (view full) --- 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * from: FreeBSD: src/sys/dev/pci/pci_pci.c,v 1.3 2000/12/13 32 * | 1/*- 2 * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier 3 * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> 4 * Copyright (c) 2000 BSDi 5 * Copyright (c) 2001, 2003 Thomas Moestl <tmm@FreeBSD.org> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 16 unchanged lines hidden (view full) --- 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * from: FreeBSD: src/sys/dev/pci/pci_pci.c,v 1.3 2000/12/13 32 * |
33 * $FreeBSD: head/sys/sparc64/pci/apb.c 133589 2004-08-12 17:41:33Z marius $ | 33 * $FreeBSD: head/sys/sparc64/pci/apb.c 145610 2005-04-28 03:33:46Z marcel $ |
34 */ 35 36/* 37 * Support for the Sun APB (Advanced PCI Bridge) PCI-PCI bridge. 38 * This bridge does not fully comply to the PCI bridge specification, and is 39 * therefore not supported by the generic driver. 40 * We can use some of the pcib methods anyway. 41 */ --- 110 unchanged lines hidden (view full) --- 152 printf("%s0x%lx-0x%lx", first ? "" : ", ", 153 i * scale, (i + 1) * scale - 1); 154 first = 0; 155 } 156 } 157} 158 159static int | 34 */ 35 36/* 37 * Support for the Sun APB (Advanced PCI Bridge) PCI-PCI bridge. 38 * This bridge does not fully comply to the PCI bridge specification, and is 39 * therefore not supported by the generic driver. 40 * We can use some of the pcib methods anyway. 41 */ --- 110 unchanged lines hidden (view full) --- 152 printf("%s0x%lx-0x%lx", first ? "" : ", ", 153 i * scale, (i + 1) * scale - 1); 154 first = 0; 155 } 156 } 157} 158 159static int |
160apb_map_checkrange(u_int8_t map, u_long scale, u_long start, u_long end) | 160apb_checkrange(u_int8_t map, u_long scale, u_long start, u_long end) |
161{ 162 int i, ei; 163 164 i = start / scale; 165 ei = end / scale; 166 if (i > 7 || ei > 7) 167 return (0); 168 for (; i <= ei; i++) --- 39 unchanged lines hidden (view full) --- 208 */ 209static struct resource * 210apb_alloc_resource(device_t dev, device_t child, int type, int *rid, 211 u_long start, u_long end, u_long count, u_int flags) 212{ 213 struct apb_softc *sc; 214 215 sc = device_get_softc(dev); | 161{ 162 int i, ei; 163 164 i = start / scale; 165 ei = end / scale; 166 if (i > 7 || ei > 7) 167 return (0); 168 for (; i <= ei; i++) --- 39 unchanged lines hidden (view full) --- 208 */ 209static struct resource * 210apb_alloc_resource(device_t dev, device_t child, int type, int *rid, 211 u_long start, u_long end, u_long count, u_int flags) 212{ 213 struct apb_softc *sc; 214 215 sc = device_get_softc(dev); |
216 |
|
216 /* 217 * If this is a "default" allocation against this rid, we can't work 218 * out where it's coming from (we should actually never see these) so 219 * we just have to punt. 220 */ | 217 /* 218 * If this is a "default" allocation against this rid, we can't work 219 * out where it's coming from (we should actually never see these) so 220 * we just have to punt. 221 */ |
221 if ((start == 0) && (end == ~0)) { | 222 if (start == 0 && end == ~0) { |
222 device_printf(dev, "can't decode default resource id %d for " 223 "%s%d, bypassing\n", *rid, device_get_name(child), 224 device_get_unit(child)); | 223 device_printf(dev, "can't decode default resource id %d for " 224 "%s%d, bypassing\n", *rid, device_get_name(child), 225 device_get_unit(child)); |
225 } else { 226 /* 227 * Fail the allocation for this range if it's not supported. 228 * XXX we should probably just fix up the bridge decode and 229 * soldier on. 230 */ 231 switch (type) { 232 case SYS_RES_IOPORT: 233 if (!apb_map_checkrange(sc->sc_iomap, APB_IO_SCALE, 234 start, end)) { 235 device_printf(dev, "device %s%d requested " 236 "unsupported I/O range 0x%lx-0x%lx\n", 237 device_get_name(child), 238 device_get_unit(child), start, end); 239 return (NULL); 240 } 241 if (bootverbose) 242 device_printf(sc->sc_bsc.ops_pcib_sc.dev, 243 "device %s%d requested decoded I/O range " 244 "0x%lx-0x%lx\n", device_get_name(child), 245 device_get_unit(child), start, end); 246 break; | 226 goto passup; 227 } |
247 | 228 |
248 case SYS_RES_MEMORY: 249 if (!apb_map_checkrange(sc->sc_memmap, APB_MEM_SCALE, 250 start, end)) { 251 device_printf(dev, "device %s%d requested " 252 "unsupported memory range 0x%lx-0x%lx\n", 253 device_get_name(child), 254 device_get_unit(child), start, end); 255 return (NULL); 256 } 257 if (bootverbose) 258 device_printf(sc->sc_bsc.ops_pcib_sc.dev, 259 "device %s%d requested decoded memory " 260 "range 0x%lx-0x%lx\n", 261 device_get_name(child), 262 device_get_unit(child), start, end); 263 break; | 229 /* 230 * Fail the allocation for this range if it's not supported. 231 * XXX we should probably just fix up the bridge decode and 232 * soldier on. 233 */ 234 switch (type) { 235 case SYS_RES_IOPORT: 236 if (!apb_checkrange(sc->sc_iomap, APB_IO_SCALE, start, end)) { 237 device_printf(dev, "device %s%d requested unsupported " 238 "I/O range 0x%lx-0x%lx\n", device_get_name(child), 239 device_get_unit(child), start, end); 240 return (NULL); 241 } 242 if (bootverbose) 243 device_printf(sc->sc_bsc.ops_pcib_sc.dev, "device " 244 "%s%d requested decoded I/O range 0x%lx-0x%lx\n", 245 device_get_name(child), device_get_unit(child), 246 start, end); 247 break; |
264 | 248 |
265 default: 266 break; | 249 case SYS_RES_MEMORY: 250 if (!apb_checkrange(sc->sc_memmap, APB_MEM_SCALE, start, end)) { 251 device_printf(dev, "device %s%d requested unsupported " 252 "memory range 0x%lx-0x%lx\n", 253 device_get_name(child), device_get_unit(child), 254 start, end); 255 return (NULL); |
267 } | 256 } |
257 if (bootverbose) 258 device_printf(sc->sc_bsc.ops_pcib_sc.dev, "device " 259 "%s%d requested decoded memory range 0x%lx-0x%lx\n", 260 device_get_name(child), device_get_unit(child), 261 start, end); 262 break; 263 264 default: 265 break; |
|
268 } 269 | 266 } 267 |
268 passup: |
|
270 /* 271 * Bridge is OK decoding this resource, so pass it up. 272 */ 273 return (bus_generic_alloc_resource(dev, child, type, rid, start, end, 274 count, flags)); 275} | 269 /* 270 * Bridge is OK decoding this resource, so pass it up. 271 */ 272 return (bus_generic_alloc_resource(dev, child, type, rid, start, end, 273 count, flags)); 274} |