Date: Thu, 30 Aug 2007 12:31:20 GMT From: Rafal Jaworowski <raj@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 125855 for review Message-ID: <200708301231.l7UCVKbL026884@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=125855 Change 125855 by raj@raj_booke_intgr on 2007/08/30 12:30:23 Adapt E500 kernel to the 7.0 changes - convert OpenPIC/ocpbus to the recently reworked OpenPIC interface - introduce setting up IRQ at the ocpbus level - other minor updates and cleanups Affected files ... .. //depot/projects/e500/sys/powerpc/booke/interrupt.c#3 edit .. //depot/projects/e500/sys/powerpc/booke/pmap.c#3 edit .. //depot/projects/e500/sys/powerpc/mpc85xx/ocpbus.c#3 edit .. //depot/projects/e500/sys/powerpc/mpc85xx/opic.c#2 edit Differences ... ==== //depot/projects/e500/sys/powerpc/booke/interrupt.c#3 (text+ko) ==== @@ -53,10 +53,13 @@ #include <machine/cpu.h> #include <machine/db_machdep.h> #include <machine/frame.h> +#include <machine/intr_machdep.h> +#include <machine/md_var.h> #include <machine/pcb.h> #include <machine/psl.h> #include <machine/trap.h> -#include <machine/interruptvar.h> + +#include "pic_if.h" extern void decr_intr(struct trapframe *); extern void trap(struct trapframe *); @@ -70,12 +73,6 @@ void unserviced_intr(struct trapframe *); - -/* - * External interrupt install routine - */ -static void (*powerpc_extintr_handler)(void); - static void dump_frame(struct trapframe *frame) { @@ -128,12 +125,6 @@ atomic_subtract_int(&td->td_intr_nesting_level, 1); } -void -ext_intr_install(void (*new_extint)(void)) -{ - powerpc_extintr_handler = new_extint; -} - /* * External input interrupt routine */ @@ -144,10 +135,7 @@ td = PCPU_GET(curthread); atomic_add_int(&td->td_intr_nesting_level, 1); - if (powerpc_extintr_handler == NULL) - printf("powerpc_extintr: no external interrupt handler!\n"); - else - (*powerpc_extintr_handler)(); + PIC_DISPATCH(pic, framep); atomic_subtract_int(&td->td_intr_nesting_level, 1); } ==== //depot/projects/e500/sys/powerpc/booke/pmap.c#3 (text+ko) ==== @@ -92,6 +92,12 @@ #define TODO panic("%s: not implemented", __func__); #define memmove(d, s, l) bcopy(s, d, l) +#include "opt_sched.h" +#ifndef SCHED_4BSD +#error "e500 only works with SCHED_4BSD which uses a global scheduler lock." +#endif +extern struct mtx sched_lock; + /* Kernel physical load address. */ extern uint32_t kernload; ==== //depot/projects/e500/sys/powerpc/mpc85xx/ocpbus.c#3 (text+ko) ==== @@ -39,7 +39,7 @@ #include <machine/spr.h> #include <machine/pio.h> #include <machine/ocpbus.h> -#include <machine/openpicvar.h> +#include <machine/intr_machdep.h> #include <machine/md_var.h> #include <machine/vmparam.h> #include <machine/bootinfo.h> @@ -52,6 +52,7 @@ struct ocpbus_softc { struct rman sc_mem; + struct rman sc_irq; device_t sc_pic; }; @@ -72,7 +73,7 @@ struct resource *); static int ocpbus_read_ivar(device_t, device_t, int, uintptr_t *); static int ocpbus_setup_intr(device_t, device_t, struct resource *, int, - driver_intr_t *, void *, void **); + driver_filter_t *, driver_intr_t *, void *, void **); static int ocpbus_teardown_intr(device_t, device_t, struct resource *, void *); /* @@ -213,9 +214,10 @@ static int ocpbus_attach (device_t dev) { - struct ocpbus_softc *sc; - int error, i; - uint32_t sr; + struct ocpbus_softc *sc; + int error, i; + uint32_t sr; + u_long start, end; sc = device_get_softc(dev); @@ -236,6 +238,17 @@ ocpbus_mk_child(dev, OCPBUS_DEVTYPE_I2C, 0); ocpbus_mk_child(dev, OCPBUS_DEVTYPE_I2C, 1); + /* Set up IRQ rman */ + start = 0; + end = INTR_VECTORS - 1; + sc->sc_irq.rm_start = start; + sc->sc_irq.rm_end = end; + sc->sc_irq.rm_type = RMAN_ARRAY; + sc->sc_irq.rm_descr = "Interrupt request lines"; + if (rman_init(&sc->sc_irq) || rman_manage_region(&sc->sc_irq, start, end)) + panic("ocpbus_attach IRQ rman"); + + /* Set up I/O mem rman */ sc->sc_mem.rm_type = RMAN_ARRAY; sc->sc_mem.rm_descr = "OCPBus Device Memory"; error = rman_init(&sc->sc_mem); @@ -287,9 +300,11 @@ const struct ocp_resource mpc8555_resources[] = { {OCPBUS_DEVTYPE_PIC, 0, SYS_RES_MEMORY, 0, OCPE500_OPENPIC_OFF, OCPE500_OPENPIC_SIZE}, + {OCPBUS_DEVTYPE_QUICC, 0, SYS_RES_MEMORY, 0, OCPE500_QUICC_OFF, OCPE500_QUICC_SIZE}, {OCPBUS_DEVTYPE_QUICC, 0, SYS_RES_IRQ, 0, PIC_IRQ_INT(30), 1}, + {OCPBUS_DEVTYPE_TSEC, 0, SYS_RES_MEMORY, 0, OCPE500_TSEC0_OFF, OCPE500_TSEC_SIZE}, {OCPBUS_DEVTYPE_TSEC, 0, SYS_RES_IRQ, 0, PIC_IRQ_INT(13), 1}, @@ -310,12 +325,14 @@ {OCPBUS_DEVTYPE_TSEC, 3, SYS_RES_IRQ, 0, PIC_IRQ_INT(21), 1}, {OCPBUS_DEVTYPE_TSEC, 3, SYS_RES_IRQ, 1, PIC_IRQ_INT(22), 1}, {OCPBUS_DEVTYPE_TSEC, 3, SYS_RES_IRQ, 2, PIC_IRQ_INT(23), 1}, + {OCPBUS_DEVTYPE_UART, 0, SYS_RES_MEMORY, 0, OCPE500_UART0_OFF, OCPE500_UART_SIZE}, {OCPBUS_DEVTYPE_UART, 0, SYS_RES_IRQ, 0, PIC_IRQ_INT(26), 1}, {OCPBUS_DEVTYPE_UART, 1, SYS_RES_MEMORY, 0, OCPE500_UART1_OFF, OCPE500_UART_SIZE}, {OCPBUS_DEVTYPE_UART, 1, SYS_RES_IRQ, 0, PIC_IRQ_INT(26), 1}, + {OCPBUS_DEVTYPE_PCIB, 0, SYS_RES_MEMORY, 0, OCPE500_PCI0_OFF, OCPE500_PCI_SIZE}, {OCPBUS_DEVTYPE_PCIB, 0, SYS_RES_MEMORY, 1, 0, OCPE500_TGTIF_PCI0}, @@ -328,9 +345,11 @@ OCPE500_PCI_SIZE}, {OCPBUS_DEVTYPE_PCIB, 2, SYS_RES_MEMORY, 1, 0, OCPE500_TGTIF_PCI2}, {OCPBUS_DEVTYPE_PCIB, 2, SYS_RES_IOPORT, 1, 0, OCPE500_TGTIF_PCI2}, + {OCPBUS_DEVTYPE_LBC, 0, SYS_RES_MEMORY, 0, OCPE500_LBC_OFF, OCPE500_LBC_SIZE}, {OCPBUS_DEVTYPE_LBC, 0, SYS_RES_MEMORY, 1, 0, OCPE500_TGTIF_LBC}, + {OCPBUS_DEVTYPE_I2C, 0, SYS_RES_MEMORY, 0, OCPE500_I2C0_OFF, OCPE500_I2C_SIZE}, {OCPBUS_DEVTYPE_I2C, 0, SYS_RES_IRQ, 0, PIC_IRQ_INT(27), 1}, @@ -413,8 +432,9 @@ if (error) return (NULL); } - rv = PIC_ALLOCATE_INTR(sc->sc_pic, child, rid, - start - PIC_IRQ_START, flags); + + rv = rman_reserve_resource(&sc->sc_irq, start - PIC_IRQ_START, + start - PIC_IRQ_START, 1, flags, child); return (rv); } @@ -527,22 +547,34 @@ } static int -ocpbus_setup_intr(device_t dev, device_t child, struct resource *res, - int flags, driver_intr_t *intr, void *arg, void **cookiep) +ocpbus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, + driver_filter_t *filter, driver_intr_t *ihand, void *arg, void **cookiep) { - struct ocpbus_softc *sc; + int error; + + if (res == NULL) + panic("ocpbus_setup_intr: NULL irq resource!"); + + *cookiep = 0; + if ((rman_get_flags(res) & RF_SHAREABLE) == 0) + flags |= INTR_EXCL; + + /* + * We depend here on rman_activate_resource() being idempotent. + */ + error = rman_activate_resource(res); + if (error) + return (error); + + error = powerpc_setup_intr(device_get_nameunit(child), + rman_get_start(res), filter, ihand, arg, flags, cookiep); - sc = device_get_softc(dev); - return (openpic_setup_intr(sc->sc_pic, child, res, flags, NULL, intr, arg, - cookiep)); + return (error); } static int ocpbus_teardown_intr(device_t dev, device_t child, struct resource *res, - void *ih) + void *cookie) { - struct ocpbus_softc *sc; - - sc = device_get_softc(dev); - return (openpic_teardown_intr(sc->sc_pic, child, res, ih)); + return (powerpc_teardown_intr(cookie)); } ==== //depot/projects/e500/sys/powerpc/mpc85xx/opic.c#2 (text+ko) ==== @@ -33,27 +33,22 @@ #include <sys/module.h> #include <sys/bus.h> #include <sys/rman.h> -#include <sys/sockio.h> -#include <sys/mbuf.h> -#include <sys/malloc.h> -#include <sys/socket.h> -#include <sys/queue.h> #include <sys/bus.h> -#include <sys/rman.h> -#include <net/if.h> + +#include <machine/bus.h> +#include <machine/intr.h> +#include <machine/intr_machdep.h> #include <machine/openpicvar.h> -#include <machine/spr.h> #include <machine/ocpbus.h> #include "pic_if.h" static int openpic_ocpbus_probe(device_t); -static int openpic_ocpbus_attach(device_t); struct openpic_ocpbus_softc { - struct openpic_softc osc; - int sc_rrid; - struct resource *sc_memr; /* iobus mem resource */ + struct openpic_softc osc; + int sc_rrid; + struct resource *sc_memr; /* mem resource */ }; /* @@ -61,14 +56,15 @@ */ static device_method_t openpic_ocpbus_methods[] = { /* Device interface */ - DEVMETHOD(device_probe, openpic_ocpbus_probe), - DEVMETHOD(device_attach, openpic_ocpbus_attach), + DEVMETHOD(device_probe, openpic_ocpbus_probe), + DEVMETHOD(device_attach, openpic_attach), /* PIC interface */ - DEVMETHOD(pic_allocate_intr, openpic_allocate_intr), - DEVMETHOD(pic_setup_intr, openpic_setup_intr), - DEVMETHOD(pic_teardown_intr, openpic_teardown_intr), - DEVMETHOD(pic_release_intr, openpic_release_intr), + DEVMETHOD(pic_dispatch, openpic_dispatch), + DEVMETHOD(pic_enable, openpic_enable), + DEVMETHOD(pic_eoi, openpic_eoi), + DEVMETHOD(pic_mask, openpic_mask), + DEVMETHOD(pic_unmask, openpic_unmask), { 0, 0 }, }; @@ -79,12 +75,8 @@ sizeof(struct openpic_ocpbus_softc) }; -static devclass_t openpic_devclass; - -DRIVER_MODULE(openpic, ocpbus, openpic_ocpbus_driver, - openpic_devclass, 0, 0); +DRIVER_MODULE(openpic, ocpbus, openpic_ocpbus_driver, openpic_devclass, 0, 0); - static int openpic_ocpbus_probe (device_t dev) { @@ -100,28 +92,6 @@ if (devtype != OCPBUS_DEVTYPE_PIC) return (ENXIO); - device_set_desc(dev, "OpenPIC in on-chip peripheral bus"); + device_set_desc(dev, OPENPIC_DEVSTR); return (BUS_PROBE_DEFAULT); } - -static int -openpic_ocpbus_attach (device_t dev) -{ - struct openpic_ocpbus_softc *sc; - - sc = device_get_softc(dev); - - sc->sc_rrid = 0; - sc->sc_memr = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rrid, - RF_ACTIVE); - - if (sc->sc_memr == NULL) { - device_printf (dev, "couldn't map memory\n"); - return (ENXIO); - } - sc->osc.sc_bt = rman_get_bustag(sc->sc_memr); - sc->osc.sc_bh = rman_get_bushandle(sc->sc_memr); - sc->osc.sc_altdev = dev; - - return (openpic_attach(dev)); -}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708301231.l7UCVKbL026884>