Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Apr 2006 00:00:24 GMT
From:      John-Mark Gurney <jmg@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 94499 for review
Message-ID:  <200604030000.k3300OmM012771@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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, &reg, &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)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604030000.k3300OmM012771>