From owner-p4-projects@FreeBSD.ORG Sun Apr 9 04:04:06 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 08F6816A405; Sun, 9 Apr 2006 04:04:06 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CB7D216A401 for ; Sun, 9 Apr 2006 04:04:04 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7E12743D46 for ; Sun, 9 Apr 2006 04:04:04 +0000 (GMT) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k39444I4064653 for ; Sun, 9 Apr 2006 04:04:04 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k39444mK064650 for perforce@freebsd.org; Sun, 9 Apr 2006 04:04:04 GMT (envelope-from kmacy@freebsd.org) Date: Sun, 9 Apr 2006 04:04:04 GMT Message-Id: <200604090404.k39444mK064650@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 94831 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Apr 2006 04:04:06 -0000 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)