PERFORCE change 133593 for review

Scott Long scottl at FreeBSD.org
Fri Jan 18 12:56:48 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=133593

Change 133593 by scottl at scottl-ix on 2008/01/18 20:55:47

	Hook up xenbus to xenhub and have it handle front-end bus stuff.

Affected files ...

.. //depot/projects/xen31-xenbus/sys/xen/xenbus/xenbus_probe.c#4 edit

Differences ...

==== //depot/projects/xen31-xenbus/sys/xen/xenbus/xenbus_probe.c#4 (text+ko) ====

@@ -980,13 +980,18 @@
 static int 
 xenhub_attach(device_t dev)
 {
+	struct xenbus_device *sc;
 	int err = 0, dom0;
 
 	DPRINTK("");
 
+	sc = device_get_softc(dev);
+
 	LIST_INIT(&xenbus_device_frontend_list);
 	LIST_INIT(&xenbus_device_backend_list);
 	LIST_INIT(&xendrv_list);
+	LIST_INIT(&sc->children);
+
 #if 0
 	if (xen_init() < 0) {
 		DPRINTK("failed");
@@ -1047,33 +1052,35 @@
 	/* Initialize the interface to xenstore. */
 	err = xs_init(); 
 	if (err) {
-			log(LOG_WARNING,
-			   "XENBUS: Error initializing xenstore comms: %i\n", err);
+		log(LOG_WARNING,
+		    "XENBUS: Error initializing xenstore comms: %i\n", err);
 		return err; 
 	}
 
 	if (!dom0) {
+		device_t child;
+
 		xenstored_ready = 1;
+
+		if (device_find_child(dev, "xenbus", 0) != NULL)
+			panic("xenhub: could not attach xen buses"); 
+
+		child = BUS_ADD_CHILD(dev, 0, "xenbus", -1);
+		if (child == NULL)
+			panic("xenhub: could not attach frontend bus"); 
+		device_set_desc(child, "Xen 3.x FrontEnd Bus");
+		device_set_ivars(child, &xenbus_frontend);
+
 #if 0
-		xenbus_dev = BUS_ADD_CHILD(parent, 0, "xenbus", 0);
-		if (xenbus_dev == NULL)
-			panic("xenbus: could not attach"); 
-		xenbus_backend_dev = BUS_ADD_CHILD(parent, 0, "xb_be", 0);
-		if (xenbus_backend_dev == NULL)
-			panic("xenbus: could not attach"); 
+		child = BUS_ADD_CHILD(dev, 0, "xenbus", -1);
+		if (child== NULL)
+			panic("xenhub: could not attach backend bus"); 
+		device_set_desc(child, "Xen 3.x BackEnd Bus");
+		device_set_ivars(child, &xenbus_backend);
 #endif
-		BUG_ON((xenstored_ready <= 0)); 
-	
 
-		
-		/* Enumerate devices in xenstore. */
-		xenbus_probe_devices(&xenbus_frontend);
-		register_xenbus_watch(&fe_watch);
-		xenbus_backend_probe_and_watch();
+		bus_generic_attach(dev);
 		
-		
-		/* Notify others that xenstore is up */
-		EVENTHANDLER_INVOKE(xenstore_event);
 	}
 
 	return 0;
@@ -1093,13 +1100,6 @@
 	return (0);
 }
 
-static int
-xenhub_add_child(device_t parent, device_t child)
-{
-
-	return (0);
-}
-
 static device_method_t xenhub_methods[] = { 
 	/* Device interface */ 
 	DEVMETHOD(device_identify,      xenhub_identify), 
@@ -1113,7 +1113,7 @@
  
 	/* Bus interface */ 
 	DEVMETHOD(bus_print_child,      bus_generic_print_child),
-	DEVMETHOD(bus_add_child,        xenhub_add_child), 
+	DEVMETHOD(bus_add_child,        bus_generic_add_child),
 	DEVMETHOD(bus_read_ivar,        bus_generic_read_ivar), 
 	DEVMETHOD(bus_write_ivar,       bus_generic_write_ivar), 
 #if 0
@@ -1166,6 +1166,11 @@
 
 	/* Enumerate device in xenstore */
 	xenbus_probe_devices(sc->xenbus);
+	register_xenbus_watch(&fe_watch);
+	xenbus_backend_probe_and_watch();
+
+	/* Notify others that xenstore is up */
+	EVENTHANDLER_INVOKE(xenstore_event);
 
 	return (0);
 }


More information about the p4-projects mailing list