From owner-p4-projects@FreeBSD.ORG Mon Apr 3 00:00:26 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 F02CF16A48C; Mon, 3 Apr 2006 00:00:25 +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 B4E2C16A484 for ; Mon, 3 Apr 2006 00:00:25 +0000 (UTC) (envelope-from jmg@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A3FA243D55 for ; Mon, 3 Apr 2006 00:00:24 +0000 (GMT) (envelope-from jmg@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 k3300OvT012774 for ; Mon, 3 Apr 2006 00:00:24 GMT (envelope-from jmg@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3300OmM012771 for perforce@freebsd.org; Mon, 3 Apr 2006 00:00:24 GMT (envelope-from jmg@freebsd.org) Date: Mon, 3 Apr 2006 00:00:24 GMT Message-Id: <200604030000.k3300OmM012771@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jmg@freebsd.org using -f From: John-Mark Gurney To: Perforce Change Reviews Cc: Subject: PERFORCE change 94499 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: Mon, 03 Apr 2006 00:00:26 -0000 http://perforce.freebsd.org/chv.cgi?CH=94499 Change 94499 by jmg@jmg_carbon-60 on 2006/04/02 23:59:55 add ivar stuff to get the bus number... the OF_getprop stuff probably won't work because last time I tried this is broke... Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/hv_pcivar.h#2 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hv_pci.c#14 edit Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/hv_pcivar.h#2 (text+ko) ==== @@ -32,6 +32,7 @@ struct hvpci_softc { devhandle_t hs_devhandle; + uint8_t hs_busnum; }; #endif /* _HV_PCIVAR_H_ */ ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hv_pci.c#14 (text+ko) ==== @@ -82,6 +82,8 @@ /* Bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, hvpci_read_ivar), + DEVMETHOD(bus_write_ivar, hvpci_write_ivar), DEVMETHOD(bus_setup_intr, hvpci_setup_intr), DEVMETHOD(bus_teardown_intr, hvpci_teardown_intr), DEVMETHOD(bus_alloc_resource, hvpci_alloc_resource), @@ -125,18 +127,25 @@ hvpci_attach(device_t dev) { struct hvpci_softc *sc; - phandle_t node; #if 0 uint32_t cell; #endif uint64_t reg, nreg; + int br[2]; + int n; node = ofw_bus_get_node(dev); if (node == -1) panic("%s: ofw_bus_get_node failed.", __func__); sc = device_get_softc(dev); + n = OF_getprop(node, "bus-range", (void *)br, sizeof br); + if (n == -1) + panic("%s: could not get bus-range", __func__); + if (n != sizeof(psycho_br)) + panic("%s: broken bus-range (%d)", __func__, n); + sc->hs_busnum = br[0]; #if 0 if (OF_getprop(node, "reg", &cell, sizeof cell) == -1) panic("%s: OF_getprop failed.", __func__); @@ -144,10 +153,10 @@ #else bus_get_resource(dev, SYS_RES_MEMORY, 0, ®, &nreg); sc->hs_devhandle = SUN4V_REG_SPEC2CFG_HDL(reg); - #endif - printf("%s, devhandle=0x%lx\n", __func__, sc->hs_devhandle); + printf("%s, devhandle=0x%lx, busnum: %hhu\n", __func__, + sc->hs_devhandle, sc->hs_busnum); device_add_child(dev, "pci", -1); @@ -241,6 +250,36 @@ #endif static int +hypci_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct hvpci_softc *sc; + + sc = device_get_softc(dev); + + switch (which) { + case PCIB_IVAR_BUS: + *result = sc->hs_busnum; + return (0); + } + + return (ENOENT); +} + +static int +hypci_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct hvpci_softc *sc; + + sc = device_get_softc(dev); + case PCIB_IVAR_BUS: + sc->hs_busnum = value; + return (0); + } + + return (ENOENT); +} + +static int hvpci_setup_intr(device_t dev, device_t child, struct resource *ires, int flags, driver_intr_t *intr, void *arg, void **cookiep) {