Date: Wed, 20 Dec 2006 00:34:32 GMT From: Paolo Pisati <piso@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 111968 for review Message-ID: <200612200034.kBK0YWtc077213@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=111968 Change 111968 by piso@piso_newluxor on 2006/12/20 00:34:26 Teach them about filters. Affected files ... .. //depot/projects/soc2006/intr_filter/sparc64/fhc/fhc.c#4 edit .. //depot/projects/soc2006/intr_filter/sparc64/pci/psycho.c#7 edit .. //depot/projects/soc2006/intr_filter/sparc64/sbus/sbus.c#7 edit Differences ... ==== //depot/projects/soc2006/intr_filter/sparc64/fhc/fhc.c#4 (text+ko) ==== @@ -50,6 +50,7 @@ #include <sparc64/sbus/ofw_sbus.h> struct fhc_clr { + driver_filter_t *fc_filter; driver_intr_t *fc_func; void *fc_arg; void *fc_cookie; @@ -62,6 +63,7 @@ struct resource_list fdi_rl; }; +static int fhc_filter_stub(void *); static void fhc_intr_stub(void *); static void fhc_led_func(void *, int); static int fhc_print_res(struct fhc_devinfo *); @@ -238,9 +240,7 @@ fc = malloc(sizeof(*fc), M_DEVBUF, M_WAITOK | M_ZERO); if (fc == NULL) return (0); - /* - * XXX_FILTER this code doesn't take care of filters. - */ + fc->fc_filter = filter; fc->fc_func = func; fc->fc_arg = arg; fc->fc_bt = bt; @@ -249,7 +249,7 @@ bus_space_write_4(bt, bh, FHC_IMAP, inr); bus_space_read_4(bt, bh, FHC_IMAP); - error = bus_generic_setup_intr(bus, child, r, flags, filter, + error = bus_generic_setup_intr(bus, child, r, flags, fhc_filter_stub, fhc_intr_stub, fc, cookiep); if (error != 0) { free(fc, M_DEVBUF); @@ -279,15 +279,28 @@ return (error); } +static int +fhc_filter_stub(void *arg) +{ + struct fhc_clr *fc = arg; + int res; + + if (fc->fc_filter != NULL) + res = fc->fc_filter(fc->fc_arg); + else + res = FILTER_HANDLED | FILTER_SCHEDULE_THREAD; + + bus_space_write_4(fc->fc_bt, fc->fc_bh, FHC_ICLR, 0x0); + bus_space_read_4(fc->fc_bt, fc->fc_bh, FHC_ICLR); + return (res); +} + static void fhc_intr_stub(void *arg) { struct fhc_clr *fc = arg; fc->fc_func(fc->fc_arg); - - bus_space_write_4(fc->fc_bt, fc->fc_bh, FHC_ICLR, 0x0); - bus_space_read_4(fc->fc_bt, fc->fc_bh, FHC_ICLR); } struct resource * ==== //depot/projects/soc2006/intr_filter/sparc64/pci/psycho.c#7 (text+ko) ==== @@ -83,6 +83,7 @@ int, void *); static int psycho_find_intrmap(struct psycho_softc *, int, bus_addr_t *, bus_addr_t *, u_long *); +static int psycho_filter_stub(void *); static void psycho_intr_stub(void *); static bus_space_tag_t psycho_alloc_bus_tag(struct psycho_softc *, int); @@ -177,6 +178,7 @@ struct psycho_clr { struct psycho_softc *pci_sc; bus_addr_t pci_clr; /* clear register */ + driver_filter_t *pci_filter; driver_intr_t *pci_handler; /* handler to call */ void *pci_arg; /* argument for the handler */ void *pci_cookie; /* parent bus int. cookie */ @@ -940,6 +942,20 @@ return (ENOENT); } +static int +psycho_filter_stub(void *arg) +{ + struct psycho_clr *pc = arg; + int res; + + if (pc->pci_filter != NULL) + res = pc->pci_filter(pc->pci_arg); + else + res = FILTER_HANDLED | FILTER_SCHEDULE_THREAD; + PSYCHO_WRITE8(pc->pci_sc, pc->pci_clr, 0); + return (res); +} + /* Write to the correct clr register, and call the actual handler. */ static void psycho_intr_stub(void *arg) @@ -947,7 +963,6 @@ struct psycho_clr *pc = arg; pc->pci_handler(pc->pci_arg); - PSYCHO_WRITE8(pc->pci_sc, pc->pci_clr, 0); } static int @@ -988,18 +1003,16 @@ device_printf(dev, "%s: INO %d, map %#lx, clr %#lx\n", __func__, ino, (u_long)intrmapptr, (u_long)intrclrptr); #endif - /* - * XXX_FILTER this code doesn't take care of filters. - */ pc->pci_sc = sc; pc->pci_arg = arg; + pc->pci_filter = filter; pc->pci_handler = intr; pc->pci_clr = intrclrptr; /* Disable the interrupt while we fiddle with it */ mr = PSYCHO_READ8(sc, intrmapptr); PSYCHO_WRITE8(sc, intrmapptr, mr & ~INTMAP_V); error = BUS_SETUP_INTR(device_get_parent(dev), child, ires, flags, - filter, psycho_intr_stub, pc, cookiep); + psycho_filter_stub, psycho_intr_stub, pc, cookiep); if (error != 0) { free(pc, M_DEVBUF); return (error); ==== //depot/projects/soc2006/intr_filter/sparc64/sbus/sbus.c#7 (text+ko) ==== @@ -181,6 +181,7 @@ struct sbus_clr { struct sbus_softc *scl_sc; bus_addr_t scl_clr; /* clear register */ + driver_filter_t *scl_filter; driver_intr_t *scl_handler; /* handler to call */ void *scl_arg; /* argument for the handler */ void *scl_cookie; /* parent bus int. cookie */ @@ -209,6 +210,7 @@ static struct sbus_devinfo * sbus_setup_dinfo(device_t, struct sbus_softc *, phandle_t); static void sbus_destroy_dinfo(struct sbus_devinfo *); +static int sbus_filter_stub(void *); static void sbus_intr_stub(void *); static bus_space_tag_t sbus_alloc_bustag(struct sbus_softc *); static int sbus_overtemp(void *); @@ -634,6 +636,21 @@ return (&sdi->sdi_rl); } +static int +sbus_filter_stub(void *arg) +{ + struct sbus_clr *scl; + int res; + + scl = (struct sbus_clr *)arg; + if (scl->scl_handler != NULL) + res = scl->scl_filter(scl->scl_arg); + else + res = FILTER_HANDLED | FILTER_SCHEDULE_THREAD; + SYSIO_WRITE8(scl->scl_sc, scl->scl_clr, 0); + return (res); +} + /* Write to the correct clr register, and call the actual handler. */ static void sbus_intr_stub(void *arg) @@ -642,7 +659,6 @@ scl = (struct sbus_clr *)arg; scl->scl_handler(scl->scl_arg); - SYSIO_WRITE8(scl->scl_sc, scl->scl_clr, 0); } static int @@ -693,17 +709,15 @@ panic("%s: IRQ not found!", __func__); } - /* - * XXX_FILTER this code doesn't take care of filters. - */ scl->scl_sc = sc; scl->scl_arg = arg; + scl->scl_filter = filter; scl->scl_handler = intr; scl->scl_clr = intrclrptr; /* Disable the interrupt while we fiddle with it */ SYSIO_WRITE8(sc, intrmapptr, intrmap & ~INTMAP_V); error = BUS_SETUP_INTR(device_get_parent(dev), child, ires, flags, - filter, sbus_intr_stub, scl, cookiep); + sbus_filter_stub, sbus_intr_stub, scl, cookiep); if (error != 0) { free(scl, M_DEVBUF); return (error);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200612200034.kBK0YWtc077213>