43 #define ETIMEDOUT_UNKNOWN \ 44 __einfo_error ( EINFO_ETIMEDOUT_UNKNOWN ) 45 #define EINFO_ETIMEDOUT_UNKNOWN \ 46 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateUnknown, \ 48 #define ETIMEDOUT_INITIALISING \ 49 __einfo_error ( EINFO_ETIMEDOUT_INITIALISING ) 50 #define EINFO_ETIMEDOUT_INITIALISING \ 51 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateInitialising, \ 53 #define ETIMEDOUT_INITWAIT \ 54 __einfo_error ( EINFO_ETIMEDOUT_INITWAIT ) 55 #define EINFO_ETIMEDOUT_INITWAIT \ 56 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateInitWait, \ 58 #define ETIMEDOUT_INITIALISED \ 59 __einfo_error ( EINFO_ETIMEDOUT_INITIALISED ) 60 #define EINFO_ETIMEDOUT_INITIALISED \ 61 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateInitialised, \ 63 #define ETIMEDOUT_CONNECTED \ 64 __einfo_error ( EINFO_ETIMEDOUT_CONNECTED ) 65 #define EINFO_ETIMEDOUT_CONNECTED \ 66 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateConnected, \ 68 #define ETIMEDOUT_CLOSING \ 69 __einfo_error ( EINFO_ETIMEDOUT_CLOSING ) 70 #define EINFO_ETIMEDOUT_CLOSING \ 71 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateClosing, \ 73 #define ETIMEDOUT_CLOSED \ 74 __einfo_error ( EINFO_ETIMEDOUT_CLOSED ) 75 #define EINFO_ETIMEDOUT_CLOSED \ 76 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateClosed, \ 78 #define ETIMEDOUT_RECONFIGURING \ 79 __einfo_error ( EINFO_ETIMEDOUT_RECONFIGURING ) 80 #define EINFO_ETIMEDOUT_RECONFIGURING \ 81 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateReconfiguring, \ 83 #define ETIMEDOUT_RECONFIGURED \ 84 __einfo_error ( EINFO_ETIMEDOUT_RECONFIGURED ) 85 #define EINFO_ETIMEDOUT_RECONFIGURED \ 86 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateReconfigured, \ 88 #define ETIMEDOUT_STATE( state ) \ 89 EUNIQ ( EINFO_ETIMEDOUT, (state), ETIMEDOUT_UNKNOWN, \ 90 ETIMEDOUT_INITIALISING, ETIMEDOUT_INITWAIT, \ 91 ETIMEDOUT_INITIALISED, ETIMEDOUT_CONNECTED, \ 92 ETIMEDOUT_CLOSING, ETIMEDOUT_CLOSED, \ 93 ETIMEDOUT_RECONFIGURING, ETIMEDOUT_RECONFIGURED ) 96 #define XENBUS_BACKEND_TIMEOUT ( 5 * TICKS_PER_SEC ) 110 "state",
NULL ) ) != 0 ) {
111 DBGC ( xendev,
"XENBUS %s could not set state=\"%d\": %s\n",
131 "state",
NULL ) ) != 0 ) {
132 DBGC ( xendev,
"XENBUS %s could not read %s/state: %s\n",
149 unsigned long elapsed;
150 unsigned int attempts = 0;
159 if ( current_state < 0 ) {
163 if ( current_state ==
state )
181 DBGC ( xendev,
"XENBUS %s timed out after %d attempts waiting for " 182 "%s/state=\"%d\": %s\n", xendev->
key, attempts, xendev->
backend,
214 struct device *parent,
const char *instance,
223 strlen ( instance ) + 1 );
224 xendev =
zalloc (
sizeof ( *xendev ) + key_len );
236 xendev->
key = ( (
void * ) ( xendev + 1 ) );
240 DBGC ( xendev,
"XENBUS %s has driver \"%s\"\n", xendev->
key,
245 "backend",
NULL ) ) != 0 ) {
246 DBGC ( xendev,
"XENBUS %s could not read backend: %s\n",
248 goto err_read_backend;
253 "backend-id",
NULL ) ) != 0 ) {
254 DBGC ( xendev,
"XENBUS %s could not read backend-id: %s\n",
256 goto err_read_backend_id;
258 DBGC ( xendev,
"XENBUS %s backend=\"%s\" in domain %ld\n",
263 DBGC ( xendev,
"XENBUS could not probe %s: %s\n",
314 DBGC ( xen,
"XENBUS has no driver for \"%s\" devices\n",
type );
323 DBGC ( xen,
"XENBUS could not list \"%s\" devices: %s\n",
330 child += (
strlen ( child ) + 1 ) ) {
333 goto err_probe_device;
362 DBGC ( xen,
"XENBUS could not list device types: %s\n",
char * backend
Backend XenStore key.
struct arbelprm_rc_send_wqe rc
#define XEN_DRIVERS
Xen device driver table.
int xenbus_backend_wait(struct xen_device *xendev, int state)
Wait for backend to reach a given state.
uint32_t type
Operating system type.
const char * type
Device type.
int xenstore_read(struct xen_hypervisor *xen, char **value,...)
Read XenStore value.
static int xenbus_probe_type(struct xen_hypervisor *xen, struct device *parent, const char *type)
Probe Xen devices of a given type.
int xenstore_write_num(struct xen_hypervisor *xen, unsigned long num,...)
Write XenStore numeric value.
struct device * parent
Bus device.
Dynamic memory allocation.
int xenbus_probe(struct xen_hypervisor *xen, struct device *parent)
Probe Xen bus.
#define list_del(list)
Delete an entry from a list.
#define ENOMEM
Not enough space.
char unsigned long const char unsigned long char ** children
static int started
"startup() has been called" flag
#define __unused
Declare a variable or data structure as unused.
struct xen_driver * driver
Driver.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
const char * driver_name
Driver name.
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
static struct xen_driver * xenbus_find_driver(const char *type)
Find driver for Xen device.
void * zalloc(size_t size)
Allocate cleared memory.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
int xenstore_directory(struct xen_hypervisor *xen, char **children, size_t *len,...)
Read XenStore directory.
struct list_head siblings
Devices on the same bus.
unsigned long backend_id
Backend domain ID.
int xenstore_read_num(struct xen_hypervisor *xen, unsigned long *num,...)
Read XenStore numeric value.
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
size_t strlen(const char *src)
Get length of string.
#define ETIMEDOUT_STATE(state)
#define INIT_LIST_HEAD(list)
Initialise a list head.
int(* probe)(struct xen_device *xendev)
Probe device.
unsigned int bus_type
Bus type.
void cpu_nap(void)
Sleep until next CPU interrupt.
int strcmp(const char *first, const char *second)
Compare strings.
#define XENBUS_BACKEND_TIMEOUT
Maximum time to wait for backend to reach a given state, in ticks.
void(* remove)(struct xen_device *xendev)
Remove device.
struct list_head children
Devices attached to this device.
struct device_description desc
Device description.
static int xenbus_probe_device(struct xen_hypervisor *xen, struct device *parent, const char *instance, struct xen_driver *driver)
Probe Xen device.
void xenbus_remove(struct xen_hypervisor *xen __unused, struct device *parent)
Remove Xen bus.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
struct device dev
Generic iPXE device.
#define BUS_TYPE_XEN
Xen bus type.
unsigned long currticks(void)
Get current system time in ticks.
int xenbus_backend_state(struct xen_device *xendev)
Get backend state.
int xenbus_set_state(struct xen_device *xendev, int state)
Set device state.
#define NULL
NULL pointer (VOID *)
struct xen_hypervisor * xen
Xen hypervisor.
static void xenbus_remove_device(struct xen_device *xendev)
Remove Xen device.