^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * xenbus.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Talks to Xen Store to figure out what devices we have.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2005 Rusty Russell, IBM Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 2005 XenSource Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This program is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * modify it under the terms of the GNU General Public License version 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * as published by the Free Software Foundation; or, when distributed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * separately from the Linux kernel or incorporated into other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * software packages, subject to the following license:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Permission is hereby granted, free of charge, to any person obtaining a copy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * of this source file (the "Software"), to deal in the Software without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * restriction, including without limitation the rights to use, copy, modify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * merge, publish, distribute, sublicense, and/or sell copies of the Software,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * and to permit persons to whom the Software is furnished to do so, subject to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * the following conditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * The above copyright notice and this permission notice shall be included in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * all copies or substantial portions of the Software.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * IN THE SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #ifndef _XEN_XENBUS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define _XEN_XENBUS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <linux/notifier.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include <linux/completion.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #include <linux/semaphore.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include <xen/interface/xen.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include <xen/interface/grant_table.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #include <xen/interface/io/xenbus.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #include <xen/interface/io/xs_wire.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #include <xen/interface/event_channel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define XENBUS_MAX_RING_GRANT_ORDER 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define XENBUS_MAX_RING_GRANTS (1U << XENBUS_MAX_RING_GRANT_ORDER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define INVALID_GRANT_HANDLE (~0U)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /* Register callback to watch this node. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct xenbus_watch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /* Path being watched. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) const char *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) unsigned int nr_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * Called just before enqueing new event while a spinlock is held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * The event will be discarded if this callback returns false.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) bool (*will_handle)(struct xenbus_watch *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) const char *path, const char *token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* Callback (executed in a process context with no locks held). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) void (*callback)(struct xenbus_watch *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) const char *path, const char *token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /* A xenbus device. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct xenbus_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) const char *devicetype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) const char *nodename;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) const char *otherend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) int otherend_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct xenbus_watch otherend_watch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct device dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) enum xenbus_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct completion down;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct work_struct work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) struct semaphore reclaim_sem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static inline struct xenbus_device *to_xenbus_device(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) return container_of(dev, struct xenbus_device, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct xenbus_device_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /* .../device/<device_type>/<identifier> */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) char devicetype[32]; /* General class of device. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /* A xenbus driver. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) struct xenbus_driver {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) const char *name; /* defaults to ids[0].devicetype */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) const struct xenbus_device_id *ids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) bool allow_rebind; /* avoid setting xenstore closed during remove */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int (*probe)(struct xenbus_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) const struct xenbus_device_id *id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) void (*otherend_changed)(struct xenbus_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) enum xenbus_state backend_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int (*remove)(struct xenbus_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int (*suspend)(struct xenbus_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) int (*resume)(struct xenbus_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int (*uevent)(struct xenbus_device *, struct kobj_uevent_env *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct device_driver driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) int (*read_otherend_details)(struct xenbus_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) int (*is_ready)(struct xenbus_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) void (*reclaim_memory)(struct xenbus_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) return container_of(drv, struct xenbus_driver, driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int __must_check __xenbus_register_frontend(struct xenbus_driver *drv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct module *owner,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) const char *mod_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int __must_check __xenbus_register_backend(struct xenbus_driver *drv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct module *owner,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) const char *mod_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #define xenbus_register_frontend(drv) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) __xenbus_register_frontend(drv, THIS_MODULE, KBUILD_MODNAME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #define xenbus_register_backend(drv) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) __xenbus_register_backend(drv, THIS_MODULE, KBUILD_MODNAME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) void xenbus_unregister_driver(struct xenbus_driver *drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct xenbus_transaction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) u32 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /* Nil transaction ID. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define XBT_NIL ((struct xenbus_transaction) { 0 })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) char **xenbus_directory(struct xenbus_transaction t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) const char *dir, const char *node, unsigned int *num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) void *xenbus_read(struct xenbus_transaction t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) const char *dir, const char *node, unsigned int *len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) int xenbus_write(struct xenbus_transaction t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) const char *dir, const char *node, const char *string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) int xenbus_mkdir(struct xenbus_transaction t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) const char *dir, const char *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) int xenbus_exists(struct xenbus_transaction t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) const char *dir, const char *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) int xenbus_rm(struct xenbus_transaction t, const char *dir, const char *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) int xenbus_transaction_start(struct xenbus_transaction *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) int xenbus_transaction_end(struct xenbus_transaction t, int abort);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /* Single read and scanf: returns -errno or num scanned if > 0. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) __scanf(4, 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int xenbus_scanf(struct xenbus_transaction t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) const char *dir, const char *node, const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /* Read an (optional) unsigned value. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) unsigned int xenbus_read_unsigned(const char *dir, const char *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) unsigned int default_val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /* Single printf and write: returns -errno or 0. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) __printf(4, 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) int xenbus_printf(struct xenbus_transaction t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) const char *dir, const char *node, const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /* Generic read function: NULL-terminated triples of name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * sprintf-style type string, and pointer. Returns 0 or errno.*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) int xenbus_gather(struct xenbus_transaction t, const char *dir, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) /* notifer routines for when the xenstore comes up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) extern int xenstored_ready;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) int register_xenstore_notifier(struct notifier_block *nb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) void unregister_xenstore_notifier(struct notifier_block *nb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) int register_xenbus_watch(struct xenbus_watch *watch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) void unregister_xenbus_watch(struct xenbus_watch *watch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) void xs_suspend(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) void xs_resume(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) void xs_suspend_cancel(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct work_struct;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #define XENBUS_IS_ERR_READ(str) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) if (!IS_ERR(str) && strlen(str) == 0) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) kfree(str); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) str = ERR_PTR(-ERANGE); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) IS_ERR(str); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) #define XENBUS_EXIST_ERR(err) ((err) == -ENOENT || (err) == -ERANGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) int xenbus_watch_path(struct xenbus_device *dev, const char *path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct xenbus_watch *watch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) bool (*will_handle)(struct xenbus_watch *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) const char *, const char *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) void (*callback)(struct xenbus_watch *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) const char *, const char *));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) __printf(5, 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) bool (*will_handle)(struct xenbus_watch *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) const char *, const char *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) void (*callback)(struct xenbus_watch *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) const char *, const char *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) const char *pathfmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) unsigned int nr_pages, grant_ref_t *grefs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) int xenbus_map_ring_valloc(struct xenbus_device *dev, grant_ref_t *gnt_refs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) unsigned int nr_grefs, void **vaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) int xenbus_alloc_evtchn(struct xenbus_device *dev, evtchn_port_t *port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) int xenbus_free_evtchn(struct xenbus_device *dev, evtchn_port_t port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) enum xenbus_state xenbus_read_driver_state(const char *path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) __printf(3, 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) __printf(3, 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) void xenbus_dev_fatal(struct xenbus_device *dev, int err, const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) const char *xenbus_strstate(enum xenbus_state state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) int xenbus_dev_is_online(struct xenbus_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) int xenbus_frontend_closed(struct xenbus_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) extern const struct file_operations xen_xenbus_fops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) extern struct xenstore_domain_interface *xen_store_interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) extern int xen_store_evtchn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) #endif /* _XEN_XENBUS_H */