Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Jun 2004 09:20:32 GMT
From:      Juli Mallett <jmallett@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 54461 for review
Message-ID:  <200406090920.i599KWxP063818@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=54461

Change 54461 by jmallett@jmallett_oingo on 2004/06/09 09:20:22

	Do evil GIO64 things which aren't really evil.  Gotta do hints stuff
	to be able to look up children rather than this crap done to check
	for products ala NetBSD.

Affected files ...

.. //depot/projects/mips/sys/mips/sgimips/gio/gio.c#2 edit

Differences ...

==== //depot/projects/mips/sys/mips/sgimips/gio/gio.c#2 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $P4: //depot/projects/mips/sys/mips/sgimips/gio/gio.c#1 $
+ * $P4: //depot/projects/mips/sys/mips/sgimips/gio/gio.c#2 $
  */
 
 #include <sys/cdefs.h>
@@ -34,9 +34,11 @@
 #include <sys/kernel.h>
 #include <sys/module.h>
 #include <sys/bus.h>
+#include <sys/rman.h>
 
 #include <platform/models.h>
 #include <platform/gio/gioreg.h>
+#include <platform/gio/giovar.h>
 
 static devclass_t gio_devclass;
 
@@ -44,12 +46,11 @@
  * Device methods
  */
 static int gio_probe(device_t);
-static int gio_attach(device_t);
 
 static device_method_t gio_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_probe,		gio_probe),
-	DEVMETHOD(device_attach,	gio_attach),
+	DEVMETHOD(device_attach,	bus_generic_attach),
 	DEVMETHOD(device_detach,	bus_generic_detach),
 	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
 
@@ -64,27 +65,72 @@
 	"gio", gio_methods, 1
 };
 
+static struct gio_device {
+	const char *gd_name;
+	uint32_t gd_product;
+} gio_devices[] = {
+	{ NULL, 0x00000000 }
+};
+
+static struct gio_ivar gio_slots[] = {
+	{ NULL, 0x1f000000 },
+	{ NULL, 0x1f400000 },
+	{ NULL, 0x1f600000 },
+	{ NULL, 0x00000000 }
+};
+
+static int
+gio_configure(device_t gio, struct gio_ivar *iv)
+{
+	struct gio_device *gd;
+	uint32_t product;
+	device_t dev;
+
+	product = bus_space_read_4(iv->gi_tag, iv->gi_handle, 0);
+	for (gd = gio_devices; gd->gd_name != NULL; gd++) {
+		if (gd->gd_product == product) {
+			dev = device_add_child(gio, gd->gd_name, -1);
+			if (dev != NULL) {
+				device_set_ivars(dev, iv);
+				return (0);
+			}
+		}
+	}
+	return (ENOENT);
+}
+
 static int
 gio_probe(device_t dev)
 {
+	struct gio_ivar *iv;
+	int count;
+	int error;
+
+	count = 0;
+
 	switch (mach_type) {
 	case MACH_SGI_IP22:
+		device_set_desc(dev, "GIO64 Bus");
+		for (iv = gio_slots; iv->gi_handle != 0; iv++) {
+			if (iv->gi_tag != NULL)
+				continue;
+			count++;
+			iv->gi_tag = device_space_tag;
+			error = gio_configure(dev, iv);
+			if (error != 0) {
+				iv->gi_tag = NULL;
+				count--;
+			}
+		}
+		if (count == 0)
+			device_printf(dev, "no children found\n");
+		device_add_child(dev, "hpc", 0);
+		device_add_child(dev, "hpc", 1);
+		device_add_child(dev, "hpc", 2);
 		return (0);
 	default:
 		return (ENOENT);
 	}
 }
 
-#define	GIO_READ_4(port, r)					\
-	(*(volatile uint32_t *)(MIPS_PHYS_TO_KSEG1(port) | r))
-
-#define	GIO_WRITE_4(port, r, v)					\
-	((*(volatile uint32_t *)(MIPS_PHYS_TO_KSEG1(port) | r)) = (v))
-
-static int
-gio_attach(device_t dev)
-{
-	return (0);
-}
-
 DRIVER_MODULE(gio, imc, gio_driver, gio_devclass, 0, 0);



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