Deleted Added
full compact
grackle.c (172394) grackle.c (174782)
1/*-
2 * Copyright 2003 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 *
1/*-
2 * Copyright 2003 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/powermac/grackle.c 172394 2007-09-30 11:05:18Z marius $
27 * $FreeBSD: head/sys/powerpc/powermac/grackle.c 174782 2007-12-19 18:00:50Z marcel $
28 */
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/module.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
35#include <sys/kernel.h>
36
37#include <dev/ofw/openfirm.h>
38#include <dev/ofw/ofw_pci.h>
39
40#include <dev/pci/pcivar.h>
41#include <dev/pci/pcireg.h>
42
43#include <machine/bus.h>
44#include <machine/md_var.h>
45#include <machine/nexusvar.h>
28 */
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/module.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
35#include <sys/kernel.h>
36
37#include <dev/ofw/openfirm.h>
38#include <dev/ofw/ofw_pci.h>
39
40#include <dev/pci/pcivar.h>
41#include <dev/pci/pcireg.h>
42
43#include <machine/bus.h>
44#include <machine/md_var.h>
45#include <machine/nexusvar.h>
46#include <machine/pio.h>
46#include <machine/resource.h>
47
48#include <sys/rman.h>
49
50#include <powerpc/ofw/ofw_pci.h>
51#include <powerpc/powermac/gracklevar.h>
52
53#include <vm/vm.h>

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

358
359static struct resource *
360grackle_alloc_resource(device_t bus, device_t child, int type, int *rid,
361 u_long start, u_long end, u_long count, u_int flags)
362{
363 struct grackle_softc *sc;
364 struct resource *rv;
365 struct rman *rm;
47#include <machine/resource.h>
48
49#include <sys/rman.h>
50
51#include <powerpc/ofw/ofw_pci.h>
52#include <powerpc/powermac/gracklevar.h>
53
54#include <vm/vm.h>

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

359
360static struct resource *
361grackle_alloc_resource(device_t bus, device_t child, int type, int *rid,
362 u_long start, u_long end, u_long count, u_int flags)
363{
364 struct grackle_softc *sc;
365 struct resource *rv;
366 struct rman *rm;
366 bus_space_tag_t bt;
367 int needactivate;
368
369 needactivate = flags & RF_ACTIVE;
370 flags &= ~RF_ACTIVE;
371
372 sc = device_get_softc(bus);
373
374 switch (type) {
375 case SYS_RES_MEMORY:
376 rm = &sc->sc_mem_rman;
367 int needactivate;
368
369 needactivate = flags & RF_ACTIVE;
370 flags &= ~RF_ACTIVE;
371
372 sc = device_get_softc(bus);
373
374 switch (type) {
375 case SYS_RES_MEMORY:
376 rm = &sc->sc_mem_rman;
377 bt = PPC_BUS_SPACE_MEM;
378 break;
379
380 case SYS_RES_IOPORT:
381 rm = &sc->sc_io_rman;
377 break;
378
379 case SYS_RES_IOPORT:
380 rm = &sc->sc_io_rman;
382 bt = PPC_BUS_SPACE_IO;
383 break;
384
385 case SYS_RES_IRQ:
386 return (bus_alloc_resource(bus, type, rid, start, end, count,
387 flags));
381 break;
382
383 case SYS_RES_IRQ:
384 return (bus_alloc_resource(bus, type, rid, start, end, count,
385 flags));
388 break;
389
390 default:
391 device_printf(bus, "unknown resource request from %s\n",
392 device_get_nameunit(child));
393 return (NULL);
394 }
395
396 rv = rman_reserve_resource(rm, start, end, count, flags, child);
397 if (rv == NULL) {
398 device_printf(bus, "failed to reserve resource for %s\n",
399 device_get_nameunit(child));
400 return (NULL);
401 }
402
403 rman_set_rid(rv, *rid);
386
387 default:
388 device_printf(bus, "unknown resource request from %s\n",
389 device_get_nameunit(child));
390 return (NULL);
391 }
392
393 rv = rman_reserve_resource(rm, start, end, count, flags, child);
394 if (rv == NULL) {
395 device_printf(bus, "failed to reserve resource for %s\n",
396 device_get_nameunit(child));
397 return (NULL);
398 }
399
400 rman_set_rid(rv, *rid);
404 rman_set_bustag(rv, bt);
401 rman_set_bustag(rv, &bs_le_tag);
405 rman_set_bushandle(rv, rman_get_start(rv));
406
407 if (needactivate) {
408 if (bus_activate_resource(child, type, *rid, rv) != 0) {
409 device_printf(bus,
410 "failed to activate resource for %s\n",
411 device_get_nameunit(child));
412 rman_release_resource(rv);

--- 144 unchanged lines hidden ---
402 rman_set_bushandle(rv, rman_get_start(rv));
403
404 if (needactivate) {
405 if (bus_activate_resource(child, type, *rid, rv) != 0) {
406 device_printf(bus,
407 "failed to activate resource for %s\n",
408 device_get_nameunit(child));
409 rman_release_resource(rv);

--- 144 unchanged lines hidden ---