Fix multiple abuses of __RMAN_RESOURCE_VISIBLE in the arm code.

Spotted out by:	phk
This commit is contained in:
Olivier Houchard 2005-09-25 21:06:50 +00:00
parent 5d3ea8713c
commit 0cc67e3dd6
9 changed files with 55 additions and 44 deletions

View File

@ -42,7 +42,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#define __RMAN_RESOURCE_VISIBLE
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@ -129,7 +128,7 @@ nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags,
driver_intr_t *intr, void *arg, void **cookiep)
{
arm_setup_irqhandler(device_get_nameunit(child),
intr, arg, res->r_start, flags, cookiep);
intr, arg, rman_get_start(res), flags, cookiep);
return (0);
}
@ -138,7 +137,7 @@ nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
{
int error;
arm_mask_irq(r->r_start);
arm_mask_irq(rman_get_start(r));
error = arm_remove_irqhandler(ih);
return (error);
}
@ -216,7 +215,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
return 0;
rman_set_bustag(rv, (void*)ARM_BUS_SPACE_MEM);
rman_set_bushandle(rv, rv->r_start);
rman_set_bushandle(rv, rman_get_start(rv));
if (needactivate) {
if (bus_activate_resource(child, type, *rid, rv)) {

View File

@ -59,7 +59,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#define __RMAN_RESOURCE_VISIBLE
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@ -70,6 +69,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/interrupt.h>
#include <sys/module.h>
#include <sys/rman.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
@ -83,7 +83,6 @@ __FBSDID("$FreeBSD$");
#include <arm/sa11x0/sa11x0_ppcreg.h>
#include <arm/sa11x0/sa11x0_gpioreg.h>
#include <machine/bus.h>
#include <sys/rman.h>
extern void sa11x0_activateirqs(void);
@ -105,12 +104,12 @@ sa1110_setup_intr(device_t dev, device_t child,
int saved_cpsr;
if (flags & INTR_TYPE_TTY)
ires->r_start = 15;
rman_set_start(ires, 15);
else if (flags & INTR_TYPE_CLK) {
if (ires->r_start == 0)
ires->r_start = 26;
if (rman_get_start(ires) == 0)
rman_set_start(ires, 26);
else
ires->r_start = 27;
rman_set_start(ires, 27);
}
saved_cpsr = SetCPSR(I32_bit, I32_bit);
@ -124,9 +123,11 @@ static struct resource *
sa1110_alloc_resource(device_t bus, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
{
struct resource *res = malloc(sizeof(*res), M_DEVBUF, M_WAITOK);
/* XXX */
res->r_start = *rid;
struct resource *res;
res = rman_reserve_resource(&sa11x0_softc->sa11x0_rman, *rid, *rid,
count, flags, child);
return (res);
}
static int
@ -227,6 +228,11 @@ sa11x0_attach(device_t dev)
/*
* Attach each devices
*/
sc->sa11x0_rman.rm_type = RMAN_ARRAY;
sc->sa11x0_rman.rm_descr = "SA11x0 IRQs";
if (rman_init(&sc->sa11x0_rman) != 0 ||
rman_manage_region(&sc->sa11x0_rman, 0, 32) != 0)
panic("sa11x0_attach: failed to set up rman");
device_add_child(dev, "uart", 0);
device_add_child(dev, "saost", 0);
bus_generic_probe(dev);

View File

@ -86,6 +86,8 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/bus.h>
#include <sys/interrupt.h>
#include <sys/rman.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
@ -111,7 +113,8 @@ arm_get_next_irq()
{
int irq;
if ((irq = (bus_space_read_4(sc->sc_iot, sc->sc_ioh, SAIPIC_IP) &
if ((irq = (bus_space_read_4(sa11x0_softc->sc_iot, sa11x0_softc->sc_ioh,
SAIPIC_IP) &
sa11x0_irq_mask)) != 0)
return (ffs(irq) - 1);
return (-1);

View File

@ -45,6 +45,7 @@
#include <sys/bus.h>
#include <machine/bus.h>
#include <sys/rman.h>
struct sa11x0_softc {
device_t sc_dev;
@ -55,6 +56,7 @@ struct sa11x0_softc {
bus_space_handle_t sc_dmach;
bus_space_handle_t sc_reseth;
u_int32_t sc_intrmask;
struct rman sa11x0_rman;
};
/* Attach args all devices */

View File

@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
#define __RMAN_RESOURCE_VISIBLE
#include <sys/rman.h>
#include <machine/bus.h>
@ -353,16 +352,9 @@ i80321_pci_alloc_resource(device_t bus, device_t child, int type, int *rid,
bus_space_tag_t bt = NULL;
bus_space_handle_t bh = 0;
if (type == SYS_RES_IRQ) {
rv = malloc(sizeof(*rv), M_DEVBUF, M_WAITOK);
rv->r_start = start;
rv->r_end = end;
rv->r_rid = *rid;
return (rv);
}
switch (type) {
case SYS_RES_IRQ:
rm = &sc->sc_mem_rman;
rm = &sc->sc_irq_rman;
break;
case SYS_RES_MEMORY:
rm = &sc->sc_mem_rman;

View File

@ -43,6 +43,7 @@
#include <sys/queue.h>
#include <dev/pci/pcivar.h>
#include <sys/rman.h>
/*
* There are roughly 32 interrupt sources.
@ -107,6 +108,7 @@ struct i80321_softc {
/* GPIO state */
uint8_t sc_gpio_dir; /* GPIO pin direction (1 == output) */
uint8_t sc_gpio_val; /* GPIO output pin value */
struct rman sc_irq_rman;
};
void i80321_sdram_bounds(bus_space_tag_t, bus_space_handle_t,

View File

@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/malloc.h>
#define __RMAN_RESOURCE_VISIBLE
#include <sys/rman.h>
#include <machine/bus.h>
#include <machine/intr.h>
@ -251,6 +250,12 @@ iq80321_attach(device_t dev)
busno = PCIXSR_BUSNO(busno);
if (busno == 0xff)
busno = 0;
sc->sc_irq_rman.rm_type = RMAN_ARRAY;
sc->sc_irq_rman.rm_descr = "i80321 IRQs";
if (rman_init(&sc->sc_irq_rman) != 0 ||
rman_manage_region(&sc->sc_irq_rman, 0, 25) != 0)
panic("i80321_attach: failed to set up IRQ rman");
device_add_child(dev, "obio", 0);
device_add_child(dev, "itimer", 0);
device_add_child(dev, "iopwdog", 0);
@ -291,12 +296,11 @@ static struct resource *
iq80321_alloc_resource(device_t dev, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
{
if (type == SYS_RES_IRQ) {
struct resource *res = malloc(sizeof(*res), M_DEVBUF, M_WAITOK);
res->r_start = start;
res->r_end = end;
return (res);
}
struct i80321_softc *sc = device_get_softc(dev);
if (type == SYS_RES_IRQ)
return (rman_reserve_resource(&sc->sc_irq_rman,
start, end, count, flags, child));
return (NULL);
}
@ -307,7 +311,7 @@ iq80321_setup_intr(device_t dev, device_t child,
{
BUS_SETUP_INTR(device_get_parent(dev), child, ires, flags, intr, arg,
cookiep);
intr_enabled |= 1 << ires->r_start;
intr_enabled |= 1 << rman_get_start(ires);
i80321_set_intrmask();
return (0);

View File

@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
#define __RMAN_RESOURCE_VISIBLE
#include <sys/rman.h>
#include <sys/malloc.h>
@ -82,6 +81,11 @@ obio_attach(device_t dev)
rman_manage_region(&sc->oba_rman,
sc->oba_addr, sc->oba_addr + sc->oba_size) != 0)
panic("obio_attach: failed to set up I/O rman");
sc->oba_irq_rman.rm_type = RMAN_ARRAY;
sc->oba_irq_rman.rm_descr = "OBIO IRQ";
if (rman_init(&sc->oba_irq_rman) != 0 ||
rman_manage_region(&sc->oba_irq_rman, 28, 28) != 0)
panic("obio_attach: failed to set up IRQ rman");
device_add_child(dev, "uart", 0);
bus_generic_probe(dev);
bus_generic_attach(dev);
@ -94,34 +98,32 @@ obio_alloc_resource(device_t bus, device_t child, int type, int *rid,
{
struct resource *rv;
struct rman *rm;
bus_space_tag_t bt;
bus_space_handle_t bh;
bus_space_tag_t bt = NULL;
bus_space_handle_t bh = 0;
struct obio_softc *sc = device_get_softc(bus);
if (type == SYS_RES_IRQ) {
rv = malloc(sizeof(*rv), M_DEVBUF, M_WAITOK);
rv->r_start = 28;
rv->r_end = 28;
rv->r_rid = *rid;
return (rv);
}
switch (type) {
case SYS_RES_IRQ:
rm = &sc->oba_irq_rman;
break;
case SYS_RES_MEMORY:
return (NULL);
case SYS_RES_IOPORT:
rm = &sc->oba_rman;
bt = sc->oba_st;
bh = sc->oba_addr;
start = bh;
break;
default:
return (NULL);
}
start = bh;
rv = rman_reserve_resource(rm, start, end, count, flags, child);
if (rv == NULL)
return (NULL);
if (type == SYS_RES_IRQ)
return (rv);
rman_set_bustag(rv, bt);
rman_set_bushandle(rv, bh);

View File

@ -41,7 +41,8 @@
#ifndef _IQ80321_OBIOVAR_H_
#define _IQ80321_OBIOVAR_H_
#ifdef __RMAN_RESOURCE_VISIBLE
#include <sys/rman.h>
struct obio_softc {
bus_space_tag_t oba_st; /* bus space tag */
bus_addr_t oba_addr; /* address of device */
@ -49,9 +50,9 @@ struct obio_softc {
int oba_width; /* bus width */
int oba_irq; /* XINT interrupt bit # */
struct rman oba_rman;
struct rman oba_irq_rman;
};
#endif /* __RMAN_RESOURCE_VISIBLE */
extern struct bus_space obio_bs_tag;
#endif /* _IQ80321_OBIOVAR_H_ */