Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Mar 2005 08:34:24 GMT
From:      Juli Mallett <jmallett@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 73510 for review
Message-ID:  <200503190834.j2J8YOc5087797@repoman.freebsd.org>

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

Change 73510 by jmallett@jmallett_windward on 2005/03/19 08:34:09

	Prepare to attach everything below ARCS.

Affected files ...

.. //depot/projects/mips/sys/dev/arcs/arcs.c#6 edit
.. //depot/projects/mips/sys/dev/arcs/arcs.h#6 edit
.. //depot/projects/mips/sys/dev/arcs/arcs_dev.c#2 edit
.. //depot/projects/mips/sys/dev/arcs/arcs_disk.c#4 edit
.. //depot/projects/mips/sys/mips/sgimips/hpc/hpc.c#4 edit
.. //depot/projects/mips/sys/mips/sgimips/imc/imc.c#11 edit
.. //depot/projects/mips/sys/mips/sgimips/mainbus.c#4 edit

Differences ...

==== //depot/projects/mips/sys/dev/arcs/arcs.c#6 (text+ko) ====

@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003 Juli Mallett <jmallett@FreeBSD.org>
+ * Copyright (c) 2003-2005 Juli Mallett <jmallett@FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -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/dev/arcs/arcs.c#5 $
+ * $P4: //depot/projects/mips/sys/dev/arcs/arcs.c#6 $
  */
 
 #include <sys/param.h>
@@ -49,6 +49,7 @@
 
 #define	ARCS_FV_Reboot_Offset			(6 * sizeof (ARCS_Pointer_t))
 #define	ARCS_FV_EnterInteractiveMode_Offset	(7 * sizeof (ARCS_Pointer_t))
+#define	ARCS_FV_GetPeer_Offset			(9 * sizeof (ARCS_Pointer_t))
 #define	ARCS_FV_GetChild_Offset			(10 * sizeof (ARCS_Pointer_t))
 #define	ARCS_FV_GetMemoryDescriptor_Offset	(18 * sizeof (ARCS_Pointer_t))
 #define	ARCS_FV_Open_Offset			(23 * sizeof (ARCS_Pointer_t))
@@ -254,6 +255,21 @@
 }
 
 struct ARCS_Component *
+ARCS_GetPeer(const struct ARCS_Component *component)
+{
+	ARCS_Pointer_t (*GetPeer)(ARCS_Pointer_t);
+	struct ARCS_Component *next;
+	ARCS_Pointer_t componentd;
+	ARCS_Pointer_t nextd;
+
+	GetPeer = (ARCS_Pointer_t (*)(ARCS_Pointer_t))(intptr_t)*(ARCS_Pointer_t *)&ARCS_FV[ARCS_FV_GetPeer_Offset];
+	componentd = (ARCS_Pointer_t)(intptr_t)component;
+	nextd = (*GetPeer)(componentd);
+	next = (struct ARCS_Component *)(intptr_t)nextd;
+	return (next);
+}
+
+struct ARCS_Component *
 ARCS_GetChild(const struct ARCS_Component *component)
 {
 	ARCS_Pointer_t (*GetChild)(ARCS_Pointer_t);

==== //depot/projects/mips/sys/dev/arcs/arcs.h#6 (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/dev/arcs/arcs.h#5 $
+ * $P4: //depot/projects/mips/sys/dev/arcs/arcs.h#6 $
  */
 
 #ifndef	_DEV_ARCS_ARCS_H_
@@ -104,8 +104,34 @@
 /* Used to enumerate system components. */
 struct ARCS_Component {
 	uint32_t Class;
+#if defined(sgimips)
+#define	ARCS_Component_Class_SystemClass	0
+#define	ARCS_Component_Class_ProcessorClass	1
+#define	ARCS_Component_Class_CacheClass		2
+#define	ARCS_Component_Class_MemoryClass	3
+#define	ARCS_Component_Class_AdapterClass	4
+#define	ARCS_Component_Class_ControllerClass	5
+#define	ARCS_Component_Class_PeripheralClass	6
+#else
+#define	ARCS_Component_Class_SystemClass	0
+#define	ARCS_Component_Class_ProcessorClass	1
+#define	ARCS_Component_Class_CacheClass		2
+#define	ARCS_Component_Class_AdapterClass	3
+#define	ARCS_Component_Class_ControllerClass	4
+#define	ARCS_Component_Class_PeripheralClass	5
+#define	ARCS_Component_Class_MemoryClass	6
+#endif
 	uint32_t Type;
+#define	ARCS_Component_Type_Processor_CPU	1
+#define	ARCS_Component_Type_Processor_FPU	2
 	uint32_t Flags;
+#define	ARCS_Component_Flags_Failed		(0x01)
+#define	ARCS_Component_Flags_ReadOnly		(0x02)
+#define	ARCS_Component_Flags_Removable		(0x04)
+#define	ARCS_Component_Flags_ConsoleIn		(0x08)
+#define	ARCS_Component_Flags_ConsoleOut		(0x10)
+#define	ARCS_Component_Flags_Input		(0x20)
+#define	ARCS_Component_Flags_Output		(0x40)
 	uint16_t Version;
 	uint16_t Revision;
 	uint32_t Key;
@@ -128,6 +154,7 @@
 int ARCS_GetReadStatus(int);
 size_t ARCS_Write(int, const char *, size_t);
 int ARCS_Seek(int, off_t *, int);
+struct ARCS_Component *ARCS_GetPeer(const struct ARCS_Component *);
 struct ARCS_Component *ARCS_GetChild(const struct ARCS_Component *);
 
 #endif /* _DEV_ARCS_ARCS_H_ */

==== //depot/projects/mips/sys/dev/arcs/arcs_dev.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/dev/arcs/arcs_dev.c#1 $
+ * $P4: //depot/projects/mips/sys/dev/arcs/arcs_dev.c#2 $
  */
 
 #include <sys/param.h>
@@ -42,11 +42,13 @@
  * ARCS bus interface.
  */
 static int	arcs_probe(device_t);
-static int	arcs_attach(device_t);
 
 static device_method_t	arcs_methods[] = {
 	DEVMETHOD(device_probe, 	arcs_probe),
-	DEVMETHOD(device_attach,	arcs_attach),
+	DEVMETHOD(device_attach,	bus_generic_attach),
+	DEVMETHOD(device_detach,	bus_generic_detach),
+	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
+
 	{ 0, 0 }
 };
 
@@ -60,32 +62,93 @@
 
 DRIVER_MODULE(arcs, mainbus, arcs_driver, arcs_devclass, 0, 0);
 
-static const char *arcs_children[] = {
-	"arcs_disk",
-	NULL
-};
+static void
+arcs_configure(device_t parent, struct ARCS_Component *this)
+{
+	struct ARCS_Component *c;
+	device_t me;
+
+	me = parent;
+	if (this != NULL) {
+		const char *device;
+		int unit;
+
+		device = NULL;
+		unit = this->Key;
+
+		switch (this->Class) {
+		case ARCS_Component_Class_SystemClass:
+			device = "arcs_system";
+			unit = 0;
+			break;
+		case ARCS_Component_Class_ProcessorClass:
+			switch (this->Type) {
+			case ARCS_Component_Type_Processor_CPU:
+				device = "arcs_cpu";
+				break;
+			case ARCS_Component_Type_Processor_FPU:
+				device = "arcs_fpu";
+				break;
+			default:
+				device_printf(parent,
+					      "Unknown ARCS CPU %d\n",
+					      this->Class);
+			}
+			break;
+		case ARCS_Component_Class_CacheClass:
+			/* Not yet. */
+			break;
+		case ARCS_Component_Class_MemoryClass:
+			/* Not yet. */
+			break;
+		case ARCS_Component_Class_AdapterClass:
+			/* Not yet. */
+			break;
+		case ARCS_Component_Class_ControllerClass:
+			/* Not yet. */
+			break;
+		case ARCS_Component_Class_PeripheralClass:
+			/* Not yet. */
+			break;
+		default:
+			device_printf(parent,
+				      "Unknown ARCS class %d\n",
+				      this->Class);
+		}
+		if (device != NULL) {
+			me = device_add_child(parent, device, unit);
+			if (me != NULL) {
+				device_set_desc(me,
+						(const char *)
+						(intptr_t)
+						this->Identifier);
+			}
+		} else {
+			device_printf(parent,
+				      "Not attaching ARCS device "
+				      "class %d, type %d, #%d: %s\n",
+				      this->Class, this->Type,
+				      this->Key, (const char *)
+						(intptr_t)
+						this->Identifier);
+		}
+		c = ARCS_GetPeer(this);
+		if (c != NULL)
+			arcs_configure(parent, c);
+	}
 
-static int
-arcs_probe(device_t dev)
-{
-	if (arcs_systemid() == NULL)
-		return (ENXIO);
-	device_set_desc(dev, "ARCS");
-	return (0);
+	c = ARCS_GetChild(this);
+	if (c != NULL)
+		arcs_configure(me, c);
 }
 
 static int
-arcs_attach(device_t dev)
+arcs_probe(device_t dev)
 {
-	const char **child;
-	struct ARCS_Component *c;
+	if (device_get_unit(dev) != 0)
+		panic("can't have more than one ARCS");
 
-	for (c = ARCS_GetChild(NULL); c != NULL; c = ARCS_GetChild(c)) {
-		device_printf(dev, "Component %s\n",
-			      (const char *)(intptr_t)c->Identifier);
-	}
-
-	for (child = arcs_children; *child != NULL; child++)
-		device_add_child(dev, *child, -1);
+	device_set_desc(dev, "ARCS Component Tree");
+	arcs_configure(dev, NULL);
 	return (0);
 }

==== //depot/projects/mips/sys/dev/arcs/arcs_disk.c#4 (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/dev/arcs/arcs_disk.c#3 $
+ * $P4: //depot/projects/mips/sys/dev/arcs/arcs_disk.c#4 $
  */
 
 #include <sys/param.h>
@@ -57,6 +57,9 @@
 static device_method_t	arcs_disk_methods[] = {
 	DEVMETHOD(device_probe, 	arcs_disk_probe),
 	DEVMETHOD(device_attach,	arcs_disk_attach),
+	DEVMETHOD(device_detach,	bus_generic_detach),
+	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
+
 	{ 0, 0 }
 };
 

==== //depot/projects/mips/sys/mips/sgimips/hpc/hpc.c#4 (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/hpc/hpc.c#3 $
+ * $P4: //depot/projects/mips/sys/mips/sgimips/hpc/hpc.c#4 $
  */
 
 #include <sys/cdefs.h>
@@ -114,9 +114,7 @@
 
 	device_printf(dev, "port %#lx\n", (long)sc->sc_handle);
 
-	bus_generic_attach(dev);
-
-	return (0);
+	return (bus_generic_attach(dev));
 }
 
 DRIVER_MODULE(hpc, gio, hpc_driver, hpc_devclass, 0, 0);

==== //depot/projects/mips/sys/mips/sgimips/imc/imc.c#11 (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/imc/imc.c#10 $
+ * $P4: //depot/projects/mips/sys/mips/sgimips/imc/imc.c#11 $
  */
 
 #include <sys/cdefs.h>
@@ -186,9 +186,7 @@
 	}
 	IMC_WRITE_4(port, IMC_GIO64ARB, reg);
 
-	bus_generic_attach(dev);
-
-	return (0);
+	return (bus_generic_attach(dev));
 }
 
 static void

==== //depot/projects/mips/sys/mips/sgimips/mainbus.c#4 (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/mainbus.c#3 $
+ * $P4: //depot/projects/mips/sys/mips/sgimips/mainbus.c#4 $
  */
 
 #include <sys/cdefs.h>
@@ -53,11 +53,6 @@
 	DEVMETHOD(device_detach,	bus_generic_detach),
 	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
 
-	/* XXX should move interrupt controller (or some perversion thereof)
-	 *     here since all real busses will attach below here.  should we
-	 *     just attach ioc/int here and attach off that?  hmm.
-	 * TODO TODO
-	 */
 	/* Bus interface */
 	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
@@ -69,17 +64,9 @@
 	"mainbus", mainbus_methods, 1
 };
 
-static const char *mainbus_devices[] = {
-	"imc",
-	"arcs",
-	NULL
-};
-
 static int
 mainbus_probe(device_t dev)
 {
-	const char **namep;
-
 	if (device_get_unit(dev) != 0)
 		panic("can't have more than one mainbus");
 
@@ -89,8 +76,7 @@
 			device_set_desc(dev, "SGI IP22 (Indigo2)");
 		else
 			device_set_desc(dev, "SGI IP24 (Indy)");
-		for (namep = mainbus_devices; *namep != NULL; namep++)
-			device_add_child(dev, *namep, -1);
+		device_add_child(dev, "arcs", device_get_unit(dev));
 		break;
 	default:
 		panic("can't attach mainbus for unknown system %d", mach_type);



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