43#include <sys/kernel.h>
45#include <sys/malloc.h>
46#include <sys/module.h>
48#include <sys/sysctl.h>
49#include <sys/syslog.h>
52#include <sys/taskqueue.h>
54#include <machine/stdarg.h>
56#include <xen/xen-os.h>
57#include <xen/gnttab.h>
72 device_set_desc(dev,
"Xen Backend Devices");
91 xbs = device_get_softc(dev);
100 if ((xbs->
xbs_flags & XBS_ATTACH_CH_ACTIVE) != 0) {
140 xbs = device_get_softc(dev);
141 error = xs_directory(XST_NIL, xbs->
xbs_node, type, &vm_count, &vms);
144 for (vm_idx = 0; vm_idx < vm_count; vm_idx++) {
145 struct sbuf *vm_path;
153 vm_path = xs_join(type, vm);
154 error = xs_directory(XST_NIL, xbs->
xbs_node, sbuf_data(vm_path),
156 sbuf_delete(vm_path);
160 for (dev_idx = 0; dev_idx < dev_count; dev_idx++) {
164 dev_num = devs[dev_idx];
165 id = xs_join(vm, dev_num);
169 free(devs, M_XENSTORE);
172 free(vms, M_XENSTORE);
203 error = xs_gather(XST_NIL, ivars->
xd_node,
205 "frontend", NULL, &otherend_path,
211 free(otherend_path, M_XENSTORE);
225 enum xenbus_state peer_state)
238 if (peer_state == XenbusStateInitialising
240 && xenbus_get_state(child) == XenbusStateClosed)
241 xenbus_set_state(child, XenbusStateInitWait);
259 if (strcmp(path,
"/state") != 0
260 && strcmp(path,
"/online") != 0)
263 if (xenbus_get_state(child) != XenbusStateClosed
282 xs_rm(XST_NIL, xenbus_get_node(child),
"hotplug-status");
286static device_method_t xenbusb_back_methods[] = {
291 DEVMETHOD(device_detach, bus_generic_detach),
292 DEVMETHOD(device_shutdown, bus_generic_shutdown),
293 DEVMETHOD(device_suspend, bus_generic_suspend),
300 DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
301 DEVMETHOD(bus_release_resource, bus_generic_release_resource),
302 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
303 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
313DEFINE_CLASS_0(xenbusb_back, xenbusb_back_driver, xenbusb_back_methods,
315devclass_t xenbusb_back_devclass;
317DRIVER_MODULE(xenbusb_back, xenstore, xenbusb_back_driver,
318 xenbusb_back_devclass, 0, 0);
Container for all state needed to manage a Xenbus Bus attachment.
struct intr_config_hook xbs_attach_ch
xenbusb_softc_flag xbs_flags
int xenbus_dev_is_online(device_t dev)
int xenbusb_attach(device_t dev, char *bus_node, u_int id_components)
Perform common XenBus bus attach processing.
int xenbusb_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
Common XenBus child instance variable read access method.
int xenbusb_print_child(device_t dev, device_t child)
Pretty-prints information about a child of a XenBus bus.
void xenbusb_localend_changed(device_t bus, device_t child, const char *path)
Common XenBus method implementing responses to local XenStore changes.
int xenbusb_add_device(device_t dev, const char *type, const char *id)
Attempt to add a XenBus device instance to this XenBus bus.
void xenbusb_identify(driver_t *driver __unused, device_t parent)
Identify instances of this device type in the system.
void xenbusb_otherend_changed(device_t bus, device_t child, enum xenbus_state state)
Common XenBus method implementing responses to peer state changes.
int xenbusb_resume(device_t dev)
Perform common XenBus bus resume handling.
int xenbusb_write_ivar(device_t dev, device_t child, int index, uintptr_t value)
Common XenBus child instance variable write access method.
static int xenbusb_back_get_otherend_node(device_t dev, struct xenbus_device_ivars *ivars)
Determine and store the XenStore path for the other end of a split device whose local end is represen...
static int xenbusb_back_attach(device_t dev)
Attach the XenBus back bus.
static int xenbusb_back_enumerate_type(device_t dev, const char *type)
Enumerate all devices of the given type on this bus.
static void xenbusb_back_localend_changed(device_t bus, device_t child, const char *path)
Backend XenBus method implementing responses to local XenStore changes.
static int xenbusb_back_probe(device_t dev)
Probe for the existence of the XenBus back bus.
static void xenbusb_back_otherend_changed(device_t bus, device_t child, enum xenbus_state peer_state)
Backend XenBus method implementing responses to peer state changes.
Datastructures and function declarations for usedby device drivers operating on the XenBus.