1/*- 2 * Copyright 2002 by Peter Grehan. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * |
27 * $FreeBSD: head/sys/powerpc/psim/iobus.c 174782 2007-12-19 18:00:50Z marcel $ |
28 */ 29 30/* 31 * PSIM 'iobus' local bus. Should be set up in the device tree like: 32 * 33 * /iobus@0x80000000/name psim-iobus 34 * 35 * Code borrowed from various nexus.c and uninorth.c :-) --- 270 unchanged lines hidden (view full) --- 306static struct resource * 307iobus_alloc_resource(device_t bus, device_t child, int type, int *rid, 308 u_long start, u_long end, u_long count, u_int flags) 309{ 310 struct iobus_softc *sc; 311 int needactivate; 312 struct resource *rv; 313 struct rman *rm; |
314 315 sc = device_get_softc(bus); 316 317 needactivate = flags & RF_ACTIVE; 318 flags &= ~RF_ACTIVE; 319 320 switch (type) { 321 case SYS_RES_MEMORY: 322 case SYS_RES_IOPORT: 323 rm = &sc->sc_mem_rman; |
324 break; 325 case SYS_RES_IRQ: 326 return (bus_alloc_resource(bus, type, rid, start, end, count, |
327 flags)); |
328 default: 329 device_printf(bus, "unknown resource request from %s\n", |
330 device_get_nameunit(child)); |
331 return (NULL); 332 } 333 334 rv = rman_reserve_resource(rm, start, end, count, flags, child); 335 if (rv == NULL) { 336 device_printf(bus, "failed to reserve resource for %s\n", 337 device_get_nameunit(child)); 338 return (NULL); 339 } 340 341 rman_set_rid(rv, *rid); |
342 rman_set_bustag(rv, &bs_le_tag); |
343 rman_set_bushandle(rv, rman_get_start(rv)); 344 345 if (needactivate) { 346 if (bus_activate_resource(child, type, *rid, rv) != 0) { 347 device_printf(bus, 348 "failed to activate resource for %s\n", 349 device_get_nameunit(child)); 350 rman_release_resource(rv); --- 63 unchanged lines hidden --- |