Date: Sun, 9 Apr 2006 04:04:04 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 94831 for review Message-ID: <200604090404.k39444mK064650@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=94831 Change 94831 by kmacy@kmacy_storage:sun4v_rwbuf on 2006/04/09 04:03:19 add interrupt setup for sun4v Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/nexus.c#3 edit Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/nexus.c#3 (text+ko) ==== @@ -163,6 +163,8 @@ extern struct bus_space_tag nexus_bustag; +#define SUN4V_REG_SPEC2CFG_HDL(x) ((x >> 32) & ~(0xfull << 28)) + static int nexus_inlist(const char *name, const char **list) { @@ -277,10 +279,87 @@ type != NULL ? type : "unknown"); } +#ifdef SUN4V + + static int nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, driver_intr_t *intr, void *arg, void **cookiep) { + + uint64_t reg, nreg; + uint64_t ihdl, cfg; + uint64_t ino, nino; + int error, cpuid; + + if (res == NULL) + panic("%s: NULL interrupt resource!", __func__); + + printf("dev=%s child=%s\n", ofw_bus_get_name(dev), ofw_bus_get_name(child)); + + if ((error = bus_get_resource(child, SYS_RES_MEMORY, 0, ®, &nreg))) + goto fail; + + if ((error = bus_get_resource(child, SYS_RES_IRQ, 0, &ino, &nino))) + goto fail; + + printf("child=%s reg=0x%lx ino=0x%lx\n", ofw_bus_get_name(child), + reg, ino); + + cfg = SUN4V_REG_SPEC2CFG_HDL(reg); + + if (hvio_intr_devino_to_sysino(cfg, (uint32_t)ino, &ihdl) != H_EOK) { + error = ENXIO; + goto fail; + } + + cpuid = 0; + + if (hvio_intr_settarget(ihdl, cpuid) != H_EOK) { + error = ENXIO; + goto fail; + } + + if (hvio_intr_setstate(ihdl, HV_INTR_IDLE_STATE) != H_EOK) { + error = ENXIO; + goto fail; + } + + if (hvio_intr_setvalid(ihdl, HV_INTR_VALID) != H_EOK) { + error = ENXIO; + goto fail; + } + + if ((rman_get_flags(res) & RF_SHAREABLE) == 0) + flags |= INTR_EXCL; + + /* We depend here on rman_activate_resource() being idempotent. */ + if ((error = rman_activate_resource(res))) + goto fail; + + error = inthand_add(device_get_nameunit(child), ihdl, + intr, arg, flags, cookiep); + + printf("inthandler added\n"); +fail: + + return (error); +} + +static int +nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih) +{ + + inthand_remove(rman_get_start(r), ih); + return (0); +} + +#else + +static int +nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, + driver_intr_t *intr, void *arg, void **cookiep) +{ int error; if (res == NULL) @@ -308,6 +387,8 @@ return (0); } +#endif + static struct resource * nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604090404.k39444mK064650>