1 /******************************************************************************
2 * Copyright (C) 2010 Spectra Logic Corporation
3 * Copyright (C) 2008 Doug Rabson
4 * Copyright (C) 2005 Rusty Russell, IBM Corporation
5 * Copyright (C) 2005 Mike Wray, Hewlett-Packard
6 * Copyright (C) 2005 XenSource Ltd
8 * This file may be distributed separately from the Linux kernel, or
9 * incorporated into other software packages, subject to the following license:
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this source file (the "Software"), to deal in the Software without
13 * restriction, including without limitation the rights to use, copy, modify,
14 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
15 * and to permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
33 * \brief Shared support functions for managing the NewBus buses that contain
34 * Xen front and back end device instances.
36 * The NewBus implementation of XenBus attaches a xenbusb_front and xenbusb_back
37 * child bus to the xenstore device. This strategy allows the small differences
38 * in the handling of XenBus operations for front and back devices to be handled
39 * as overrides in xenbusb_front/back.c. Front and back specific device
40 * classes are also provided so device drivers can register for the devices they
41 * can handle without the need to filter within their probe routines. The
42 * net result is a device hierarchy that might look like this:
54 #include <sys/cdefs.h>
55 __FBSDID("$FreeBSD$");
57 #include <sys/param.h>
59 #include <sys/kernel.h>
61 #include <sys/malloc.h>
62 #include <sys/module.h>
64 #include <sys/sysctl.h>
65 #include <sys/syslog.h>
66 #include <sys/systm.h>
68 #include <sys/taskqueue.h>
70 #include <machine/xen/xen-os.h>
71 #include <machine/stdarg.h>
73 #include <xen/gnttab.h>
74 #include <xen/xenstore/xenstorevar.h>
75 #include <xen/xenbus/xenbusb.h>
76 #include <xen/xenbus/xenbusvar.h>
78 /*------------------------- Private Functions --------------------------------*/
80 * \brief Deallocate XenBus device instance variables.
82 * \param ivars The instance variable block to free.
85 xenbusb_free_child_ivars(struct xenbus_device_ivars *ivars)
87 if (ivars->xd_otherend_watch.node != NULL) {
88 xs_unregister_watch(&ivars->xd_otherend_watch);
89 free(ivars->xd_otherend_watch.node, M_XENBUS);
90 ivars->xd_otherend_watch.node = NULL;
93 if (ivars->xd_local_watch.node != NULL) {
94 xs_unregister_watch(&ivars->xd_local_watch);
95 ivars->xd_local_watch.node = NULL;
98 if (ivars->xd_node != NULL) {
99 free(ivars->xd_node, M_XENBUS);
100 ivars->xd_node = NULL;
102 ivars->xd_node_len = 0;
104 if (ivars->xd_type != NULL) {
105 free(ivars->xd_type, M_XENBUS);
106 ivars->xd_type = NULL;
109 if (ivars->xd_otherend_path != NULL) {
110 free(ivars->xd_otherend_path, M_XENBUS);
111 ivars->xd_otherend_path = NULL;
113 ivars->xd_otherend_path_len = 0;
115 free(ivars, M_XENBUS);
119 * XenBus watch callback registered against the "state" XenStore
120 * node of the other-end of a split device connection.
122 * This callback is invoked whenever the state of a device instance's
125 * \param watch The xs_watch object used to register this callback
127 * \param vec An array of pointers to NUL terminated strings containing
128 * watch event data. The vector should be indexed via the
129 * xs_watch_type enum in xs_wire.h.
130 * \param vec_size The number of elements in vec.
133 xenbusb_otherend_watch_cb(struct xs_watch *watch, const char **vec,
134 unsigned int vec_size __unused)
136 struct xenbus_device_ivars *ivars;
140 enum xenbus_state newstate;
142 ivars = (struct xenbus_device_ivars *)watch->callback_data;
143 child = ivars->xd_dev;
144 bus = device_get_parent(child);
146 path = vec[XS_WATCH_PATH];
147 if (ivars->xd_otherend_path == NULL
148 || strncmp(ivars->xd_otherend_path, path, ivars->xd_otherend_path_len))
151 newstate = xenbus_read_driver_state(ivars->xd_otherend_path);
152 XENBUSB_OTHEREND_CHANGED(bus, child, newstate);
156 * XenBus watch callback registered against the XenStore sub-tree
157 * represnting the local half of a split device connection.
159 * This callback is invoked whenever any XenStore data in the subtree
160 * is modified, either by us or another privledged domain.
162 * \param watch The xs_watch object used to register this callback
164 * \param vec An array of pointers to NUL terminated strings containing
165 * watch event data. The vector should be indexed via the
166 * xs_watch_type enum in xs_wire.h.
167 * \param vec_size The number of elements in vec.
171 xenbusb_local_watch_cb(struct xs_watch *watch, const char **vec,
172 unsigned int vec_size __unused)
174 struct xenbus_device_ivars *ivars;
179 ivars = (struct xenbus_device_ivars *)watch->callback_data;
180 child = ivars->xd_dev;
181 bus = device_get_parent(child);
183 path = vec[XS_WATCH_PATH];
184 if (ivars->xd_node == NULL
185 || strncmp(ivars->xd_node, path, ivars->xd_node_len))
188 XENBUSB_LOCALEND_CHANGED(bus, child, &path[ivars->xd_node_len]);
192 * Search our internal record of configured devices (not the XenStore)
193 * to determine if the XenBus device indicated by \a node is known to
196 * \param dev The XenBus bus instance to search for device children.
197 * \param node The XenStore node path for the device to find.
199 * \return The device_t of the found device if any, or NULL.
201 * \note device_t is a pointer type, so it can be compared against
205 xenbusb_device_exists(device_t dev, const char *node)
209 struct xenbus_device_ivars *ivars;
212 if (device_get_children(dev, &kids, &count))
216 for (i = 0; i < count; i++) {
217 ivars = device_get_ivars(kids[i]);
218 if (!strcmp(ivars->xd_node, node)) {
229 xenbusb_delete_child(device_t dev, device_t child)
231 struct xenbus_device_ivars *ivars;
233 ivars = device_get_ivars(child);
236 * We no longer care about the otherend of the
237 * connection. Cancel the watches now so that we
238 * don't try to handle an event for a partially
241 if (ivars->xd_otherend_watch.node != NULL)
242 xs_unregister_watch(&ivars->xd_otherend_watch);
243 if (ivars->xd_local_watch.node != NULL)
244 xs_unregister_watch(&ivars->xd_local_watch);
246 device_delete_child(dev, child);
247 xenbusb_free_child_ivars(ivars);
251 * \param dev The NewBus device representing this XenBus bus.
252 * \param child The NewBus device representing a child of dev%'s XenBus bus.
255 xenbusb_verify_device(device_t dev, device_t child)
257 if (xs_exists(XST_NIL, xenbus_get_node(child), "") == 0) {
260 * Device tree has been removed from Xenbus.
261 * Tear down the device.
263 xenbusb_delete_child(dev, child);
268 * \brief Enumerate the devices on a XenBus bus and register them with
269 * the NewBus device tree.
271 * xenbusb_enumerate_bus() will create entries (in state DS_NOTPRESENT)
272 * for nodes that appear in the XenStore, but will not invoke probe/attach
273 * operations on drivers. Probe/Attach processing must be separately
274 * performed via an invocation of xenbusb_probe_children(). This is usually
275 * done via the xbs_probe_children task.
277 * \param xbs XenBus Bus device softc of the owner of the bus to enumerate.
279 * \return On success, 0. Otherwise an errno value indicating the
283 xenbusb_enumerate_bus(struct xenbusb_softc *xbs)
290 error = xs_directory(XST_NIL, xbs->xbs_node, "", &type_count, &types);
294 for (type_idx = 0; type_idx < type_count; type_idx++)
295 XENBUSB_ENUMERATE_TYPE(xbs->xbs_dev, types[type_idx]);
297 free(types, M_XENSTORE);
303 * Handler for all generic XenBus device systcl nodes.
306 xenbusb_device_sysctl_handler(SYSCTL_HANDLER_ARGS)
311 dev = (device_t)arg1;
313 case XENBUS_IVAR_NODE:
314 value = xenbus_get_node(dev);
316 case XENBUS_IVAR_TYPE:
317 value = xenbus_get_type(dev);
319 case XENBUS_IVAR_STATE:
320 value = xenbus_strstate(xenbus_get_state(dev));
322 case XENBUS_IVAR_OTHEREND_ID:
323 return (sysctl_handle_int(oidp, NULL,
324 xenbus_get_otherend_id(dev),
327 case XENBUS_IVAR_OTHEREND_PATH:
328 value = xenbus_get_otherend_path(dev);
333 return (SYSCTL_OUT_STR(req, value));
337 * Create read-only systcl nodes for xenbusb device ivar data.
339 * \param dev The XenBus device instance to register with sysctl.
342 xenbusb_device_sysctl_init(device_t dev)
344 struct sysctl_ctx_list *ctx;
345 struct sysctl_oid *tree;
347 ctx = device_get_sysctl_ctx(dev);
348 tree = device_get_sysctl_tree(dev);
351 SYSCTL_CHILDREN(tree),
354 CTLTYPE_STRING | CTLFLAG_RD,
357 xenbusb_device_sysctl_handler,
359 "XenStore path to device");
362 SYSCTL_CHILDREN(tree),
365 CTLTYPE_STRING | CTLFLAG_RD,
368 xenbusb_device_sysctl_handler,
370 "XenBus device type");
373 SYSCTL_CHILDREN(tree),
375 "xenbus_connection_state",
376 CTLTYPE_STRING | CTLFLAG_RD,
379 xenbusb_device_sysctl_handler,
381 "XenBus state of peer connection");
384 SYSCTL_CHILDREN(tree),
387 CTLTYPE_INT | CTLFLAG_RD,
389 XENBUS_IVAR_OTHEREND_ID,
390 xenbusb_device_sysctl_handler,
392 "Xen domain ID of peer");
395 SYSCTL_CHILDREN(tree),
397 "xenstore_peer_path",
398 CTLTYPE_STRING | CTLFLAG_RD,
400 XENBUS_IVAR_OTHEREND_PATH,
401 xenbusb_device_sysctl_handler,
403 "XenStore path to peer device");
407 * \brief Decrement the number of XenBus child devices in the
408 * connecting state by one and release the xbs_attch_ch
409 * interrupt configuration hook if the connecting count
412 * \param xbs XenBus Bus device softc of the owner of the bus to enumerate.
415 xenbusb_release_confighook(struct xenbusb_softc *xbs)
417 mtx_lock(&xbs->xbs_lock);
418 KASSERT(xbs->xbs_connecting_children > 0,
419 ("Connecting device count error\n"));
420 xbs->xbs_connecting_children--;
421 if (xbs->xbs_connecting_children == 0
422 && (xbs->xbs_flags & XBS_ATTACH_CH_ACTIVE) != 0) {
423 xbs->xbs_flags &= ~XBS_ATTACH_CH_ACTIVE;
424 mtx_unlock(&xbs->xbs_lock);
425 config_intrhook_disestablish(&xbs->xbs_attach_ch);
427 mtx_unlock(&xbs->xbs_lock);
432 * \brief Verify the existance of attached device instances and perform
433 * probe/attach processing for newly arrived devices.
435 * \param dev The NewBus device representing this XenBus bus.
437 * \return On success, 0. Otherwise an errno value indicating the
441 xenbusb_probe_children(device_t dev)
444 struct xenbus_device_ivars *ivars;
447 if (device_get_children(dev, &kids, &count) == 0) {
448 for (i = 0; i < count; i++) {
449 if (device_get_state(kids[i]) != DS_NOTPRESENT) {
451 * We already know about this one.
452 * Make sure it's still here.
454 xenbusb_verify_device(dev, kids[i]);
458 error = device_probe_and_attach(kids[i]);
459 if (error == ENXIO) {
460 struct xenbusb_softc *xbs;
463 * We don't have a PV driver for this device.
464 * However, an emulated device we do support
465 * may share this backend. Hide the node from
466 * XenBus until the next rescan, but leave it's
467 * state unchanged so we don't inadvertently
468 * prevent attachment of any emulated device.
470 xenbusb_delete_child(dev, kids[i]);
473 * Since the XenStore state of this device
474 * still indicates a pending attach, manually
475 * release it's hold on the boot process.
477 xbs = device_get_softc(dev);
478 xenbusb_release_confighook(xbs);
483 * Transition device to the closed state
484 * so the world knows that attachment will
487 xenbus_set_state(kids[i], XenbusStateClosed);
490 * Remove our record of this device.
491 * So long as it remains in the closed
492 * state in the XenStore, we will not find
493 * it again. The state will only change
494 * if the control domain actively reconfigures
497 xenbusb_delete_child(dev, kids[i]);
502 * Augment default newbus provided dynamic sysctl
503 * variables with the standard ivar contents of
506 xenbusb_device_sysctl_init(kids[i]);
509 * Now that we have a driver managing this device
510 * that can receive otherend state change events,
511 * hook up a watch for them.
513 ivars = device_get_ivars(kids[i]);
514 xs_register_watch(&ivars->xd_otherend_watch);
515 xs_register_watch(&ivars->xd_local_watch);
524 * \brief Task callback function to perform XenBus probe operations
525 * from a known safe context.
527 * \param arg The NewBus device_t representing the bus instance to
528 * on which to perform probe processing.
529 * \param pending The number of times this task was queued before it could
533 xenbusb_probe_children_cb(void *arg, int pending __unused)
535 device_t dev = (device_t)arg;
538 * Hold Giant until the Giant free newbus changes are committed.
541 xenbusb_probe_children(dev);
546 * \brief XenStore watch callback for the root node of the XenStore
547 * subtree representing a XenBus.
549 * This callback performs, or delegates to the xbs_probe_children task,
550 * all processing necessary to handle dynmaic device arrival and departure
551 * events from a XenBus.
553 * \param watch The XenStore watch object associated with this callback.
554 * \param vec The XenStore watch event data.
555 * \param len The number of fields in the event data stream.
558 xenbusb_devices_changed(struct xs_watch *watch, const char **vec,
561 struct xenbusb_softc *xbs;
569 xbs = (struct xenbusb_softc *)watch->callback_data;
572 if (len <= XS_WATCH_PATH) {
573 device_printf(dev, "xenbusb_devices_changed: "
574 "Short Event Data.\n");
578 node = strdup(vec[XS_WATCH_PATH], M_XENBUS);
579 p = strchr(node, '/');
585 p = strchr(type, '/');
591 * Extract the device ID. A device ID has one or more path
592 * components separated by the '/' character.
594 * e.g. "<frontend vm id>/<frontend dev id>" for backend devices.
597 for (component = 0; component < xbs->xbs_id_components; component++) {
606 if (*id != 0 && component >= xbs->xbs_id_components - 1) {
607 xenbusb_add_device(xbs->xbs_dev, type, id);
608 taskqueue_enqueue(taskqueue_thread, &xbs->xbs_probe_children);
611 free(node, M_XENBUS);
615 * \brief Interrupt configuration hook callback associated with xbs_attch_ch.
617 * Since interrupts are always functional at the time of XenBus configuration,
618 * there is nothing to be done when the callback occurs. This hook is only
619 * registered to hold up boot processing while XenBus devices come online.
621 * \param arg Unused configuration hook callback argument.
624 xenbusb_nop_confighook_cb(void *arg __unused)
628 /*--------------------------- Public Functions -------------------------------*/
629 /*--------- API comments for these methods can be found in xenbusb.h ---------*/
631 xenbusb_identify(driver_t *driver __unused, device_t parent)
634 * A single instance of each bus type for which we have a driver
635 * is always present in a system operating under Xen.
637 BUS_ADD_CHILD(parent, 0, driver->name, 0);
641 xenbusb_add_device(device_t dev, const char *type, const char *id)
643 struct xenbusb_softc *xbs;
644 struct sbuf *devpath_sbuf;
646 struct xenbus_device_ivars *ivars;
649 xbs = device_get_softc(dev);
650 devpath_sbuf = sbuf_new_auto();
651 sbuf_printf(devpath_sbuf, "%s/%s/%s", xbs->xbs_node, type, id);
652 sbuf_finish(devpath_sbuf);
653 devpath = sbuf_data(devpath_sbuf);
655 ivars = malloc(sizeof(*ivars), M_XENBUS, M_ZERO|M_WAITOK);
658 if (xs_exists(XST_NIL, devpath, "") != 0) {
660 enum xenbus_state state;
663 child = xenbusb_device_exists(dev, devpath);
666 * We are already tracking this node
672 state = xenbus_read_driver_state(devpath);
673 if (state != XenbusStateInitialising) {
675 * Device is not new, so ignore it. This can
676 * happen if a device is going away after
677 * switching to Closed.
679 printf("xenbusb_add_device: Device %s ignored. "
680 "State %d\n", devpath, state);
685 sx_init(&ivars->xd_lock, "xdlock");
686 ivars->xd_flags = XDF_CONNECTING;
687 ivars->xd_node = strdup(devpath, M_XENBUS);
688 ivars->xd_node_len = strlen(devpath);
689 ivars->xd_type = strdup(type, M_XENBUS);
690 ivars->xd_state = XenbusStateInitialising;
692 error = XENBUSB_GET_OTHEREND_NODE(dev, ivars);
694 printf("xenbus_update_device: %s no otherend id\n",
699 statepath = malloc(ivars->xd_otherend_path_len
700 + strlen("/state") + 1, M_XENBUS, M_WAITOK);
701 sprintf(statepath, "%s/state", ivars->xd_otherend_path);
702 ivars->xd_otherend_watch.node = statepath;
703 ivars->xd_otherend_watch.callback = xenbusb_otherend_watch_cb;
704 ivars->xd_otherend_watch.callback_data = (uintptr_t)ivars;
706 ivars->xd_local_watch.node = ivars->xd_node;
707 ivars->xd_local_watch.callback = xenbusb_local_watch_cb;
708 ivars->xd_local_watch.callback_data = (uintptr_t)ivars;
710 mtx_lock(&xbs->xbs_lock);
711 xbs->xbs_connecting_children++;
712 mtx_unlock(&xbs->xbs_lock);
714 child = device_add_child(dev, NULL, -1);
715 ivars->xd_dev = child;
716 device_set_ivars(child, ivars);
720 sbuf_delete(devpath_sbuf);
722 xenbusb_free_child_ivars(ivars);
728 xenbusb_attach(device_t dev, char *bus_node, u_int id_components)
730 struct xenbusb_softc *xbs;
732 xbs = device_get_softc(dev);
733 mtx_init(&xbs->xbs_lock, "xenbusb softc lock", NULL, MTX_DEF);
734 xbs->xbs_node = bus_node;
735 xbs->xbs_id_components = id_components;
739 * Since XenBus buses are attached to the XenStore, and
740 * the XenStore does not probe children until after interrupt
741 * services are available, this config hook is used solely
742 * to ensure that the remainder of the boot process (e.g.
743 * mount root) is deferred until child devices are adequately
744 * probed. We unblock the boot process as soon as the
745 * connecting child count in our softc goes to 0.
747 xbs->xbs_attach_ch.ich_func = xenbusb_nop_confighook_cb;
748 xbs->xbs_attach_ch.ich_arg = dev;
749 config_intrhook_establish(&xbs->xbs_attach_ch);
750 xbs->xbs_flags |= XBS_ATTACH_CH_ACTIVE;
751 xbs->xbs_connecting_children = 1;
754 * The subtree for this bus type may not yet exist
755 * causing initial enumeration to fail. We still
756 * want to return success from our attach though
757 * so that we are ready to handle devices for this
758 * bus when they are dynamically attached to us
759 * by a Xen management action.
761 (void)xenbusb_enumerate_bus(xbs);
762 xenbusb_probe_children(dev);
764 xbs->xbs_device_watch.node = bus_node;
765 xbs->xbs_device_watch.callback = xenbusb_devices_changed;
766 xbs->xbs_device_watch.callback_data = (uintptr_t)xbs;
768 TASK_INIT(&xbs->xbs_probe_children, 0, xenbusb_probe_children_cb, dev);
770 xs_register_watch(&xbs->xbs_device_watch);
772 xenbusb_release_confighook(xbs);
778 xenbusb_resume(device_t dev)
781 struct xenbus_device_ivars *ivars;
786 * We must re-examine each device and find the new path for
789 if (device_get_children(dev, &kids, &count) == 0) {
790 for (i = 0; i < count; i++) {
791 if (device_get_state(kids[i]) == DS_NOTPRESENT)
794 if (xen_suspend_cancelled) {
795 DEVICE_RESUME(kids[i]);
799 ivars = device_get_ivars(kids[i]);
801 xs_unregister_watch(&ivars->xd_otherend_watch);
802 xenbus_set_state(kids[i], XenbusStateInitialising);
805 * Find the new backend details and
806 * re-register our watch.
808 error = XENBUSB_GET_OTHEREND_NODE(dev, ivars);
812 statepath = malloc(ivars->xd_otherend_path_len
813 + strlen("/state") + 1, M_XENBUS, M_WAITOK);
814 sprintf(statepath, "%s/state", ivars->xd_otherend_path);
816 free(ivars->xd_otherend_watch.node, M_XENBUS);
817 ivars->xd_otherend_watch.node = statepath;
819 DEVICE_RESUME(kids[i]);
821 xs_register_watch(&ivars->xd_otherend_watch);
824 * Can't do this yet since we are running in
825 * the xenwatch thread and if we sleep here,
826 * we will stop delivering watch notifications
827 * and the device will never come back online.
829 sx_xlock(&ivars->xd_lock);
830 while (ivars->xd_state != XenbusStateClosed
831 && ivars->xd_state != XenbusStateConnected)
832 sx_sleep(&ivars->xd_state, &ivars->xd_lock,
834 sx_xunlock(&ivars->xd_lock);
844 xenbusb_print_child(device_t dev, device_t child)
846 struct xenbus_device_ivars *ivars = device_get_ivars(child);
849 retval += bus_print_child_header(dev, child);
850 retval += printf(" at %s", ivars->xd_node);
851 retval += bus_print_child_footer(dev, child);
857 xenbusb_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
859 struct xenbus_device_ivars *ivars = device_get_ivars(child);
862 case XENBUS_IVAR_NODE:
863 *result = (uintptr_t) ivars->xd_node;
866 case XENBUS_IVAR_TYPE:
867 *result = (uintptr_t) ivars->xd_type;
870 case XENBUS_IVAR_STATE:
871 *result = (uintptr_t) ivars->xd_state;
874 case XENBUS_IVAR_OTHEREND_ID:
875 *result = (uintptr_t) ivars->xd_otherend_id;
878 case XENBUS_IVAR_OTHEREND_PATH:
879 *result = (uintptr_t) ivars->xd_otherend_path;
887 xenbusb_write_ivar(device_t dev, device_t child, int index, uintptr_t value)
889 struct xenbus_device_ivars *ivars = device_get_ivars(child);
890 enum xenbus_state newstate;
894 case XENBUS_IVAR_STATE:
898 newstate = (enum xenbus_state)value;
899 sx_xlock(&ivars->xd_lock);
900 if (ivars->xd_state == newstate) {
905 error = xs_scanf(XST_NIL, ivars->xd_node, "state",
906 NULL, "%d", &currstate);
911 error = xs_printf(XST_NIL, ivars->xd_node, "state",
913 } while (error == EAGAIN);
916 * Avoid looping through xenbus_dev_fatal()
917 * which calls xenbus_write_ivar to set the
920 if (newstate != XenbusStateClosing)
921 xenbus_dev_fatal(dev, error,
922 "writing new state");
925 ivars->xd_state = newstate;
927 if ((ivars->xd_flags & XDF_CONNECTING) != 0
928 && (newstate == XenbusStateClosed
929 || newstate == XenbusStateConnected)) {
930 struct xenbusb_softc *xbs;
932 ivars->xd_flags &= ~XDF_CONNECTING;
933 xbs = device_get_softc(dev);
934 xenbusb_release_confighook(xbs);
937 wakeup(&ivars->xd_state);
939 sx_xunlock(&ivars->xd_lock);
943 case XENBUS_IVAR_NODE:
944 case XENBUS_IVAR_TYPE:
945 case XENBUS_IVAR_OTHEREND_ID:
946 case XENBUS_IVAR_OTHEREND_PATH:
948 * These variables are read-only.
957 xenbusb_otherend_changed(device_t bus, device_t child, enum xenbus_state state)
959 XENBUS_OTHEREND_CHANGED(child, state);
963 xenbusb_localend_changed(device_t bus, device_t child, const char *path)
966 if (strcmp(path, "/state") != 0) {
967 struct xenbus_device_ivars *ivars;
969 ivars = device_get_ivars(child);
970 sx_xlock(&ivars->xd_lock);
971 ivars->xd_state = xenbus_read_driver_state(ivars->xd_node);
972 sx_xunlock(&ivars->xd_lock);
974 XENBUS_LOCALEND_CHANGED(child, path);