44 #define ETIMEDOUT_UNKNOWN \ 45 __einfo_error ( EINFO_ETIMEDOUT_UNKNOWN ) 46 #define EINFO_ETIMEDOUT_UNKNOWN \ 47 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateUnknown, \ 49 #define ETIMEDOUT_INITIALISING \ 50 __einfo_error ( EINFO_ETIMEDOUT_INITIALISING ) 51 #define EINFO_ETIMEDOUT_INITIALISING \ 52 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateInitialising, \ 54 #define ETIMEDOUT_INITWAIT \ 55 __einfo_error ( EINFO_ETIMEDOUT_INITWAIT ) 56 #define EINFO_ETIMEDOUT_INITWAIT \ 57 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateInitWait, \ 59 #define ETIMEDOUT_INITIALISED \ 60 __einfo_error ( EINFO_ETIMEDOUT_INITIALISED ) 61 #define EINFO_ETIMEDOUT_INITIALISED \ 62 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateInitialised, \ 64 #define ETIMEDOUT_CONNECTED \ 65 __einfo_error ( EINFO_ETIMEDOUT_CONNECTED ) 66 #define EINFO_ETIMEDOUT_CONNECTED \ 67 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateConnected, \ 69 #define ETIMEDOUT_CLOSING \ 70 __einfo_error ( EINFO_ETIMEDOUT_CLOSING ) 71 #define EINFO_ETIMEDOUT_CLOSING \ 72 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateClosing, \ 74 #define ETIMEDOUT_CLOSED \ 75 __einfo_error ( EINFO_ETIMEDOUT_CLOSED ) 76 #define EINFO_ETIMEDOUT_CLOSED \ 77 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateClosed, \ 79 #define ETIMEDOUT_RECONFIGURING \ 80 __einfo_error ( EINFO_ETIMEDOUT_RECONFIGURING ) 81 #define EINFO_ETIMEDOUT_RECONFIGURING \ 82 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateReconfiguring, \ 84 #define ETIMEDOUT_RECONFIGURED \ 85 __einfo_error ( EINFO_ETIMEDOUT_RECONFIGURED ) 86 #define EINFO_ETIMEDOUT_RECONFIGURED \ 87 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateReconfigured, \ 89 #define ETIMEDOUT_STATE( state ) \ 90 EUNIQ ( EINFO_ETIMEDOUT, (state), ETIMEDOUT_UNKNOWN, \ 91 ETIMEDOUT_INITIALISING, ETIMEDOUT_INITWAIT, \ 92 ETIMEDOUT_INITIALISED, ETIMEDOUT_CONNECTED, \ 93 ETIMEDOUT_CLOSING, ETIMEDOUT_CLOSED, \ 94 ETIMEDOUT_RECONFIGURING, ETIMEDOUT_RECONFIGURED ) 97 #define XENBUS_BACKEND_TIMEOUT ( 5 * TICKS_PER_SEC ) 111 "state",
NULL ) ) != 0 ) {
112 DBGC ( xendev,
"XENBUS %s could not set state=\"%d\": %s\n",
132 "state",
NULL ) ) != 0 ) {
133 DBGC ( xendev,
"XENBUS %s could not read %s/state: %s\n",
150 unsigned long elapsed;
151 unsigned int attempts = 0;
160 if ( current_state < 0 ) {
164 if ( current_state ==
state )
182 DBGC ( xendev,
"XENBUS %s timed out after %d attempts waiting for " 183 "%s/state=\"%d\": %s\n", xendev->
key, attempts, xendev->
backend,
215 struct device *parent,
const char *instance,
224 strlen ( instance ) + 1 );
225 xendev =
zalloc (
sizeof ( *xendev ) + key_len );
237 xendev->
key = ( (
void * ) ( xendev + 1 ) );
241 DBGC ( xendev,
"XENBUS %s has driver \"%s\"\n", xendev->
key,
246 "backend",
NULL ) ) != 0 ) {
247 DBGC ( xendev,
"XENBUS %s could not read backend: %s\n",
249 goto err_read_backend;
254 "backend-id",
NULL ) ) != 0 ) {
255 DBGC ( xendev,
"XENBUS %s could not read backend-id: %s\n",
257 goto err_read_backend_id;
259 DBGC ( xendev,
"XENBUS %s backend=\"%s\" in domain %ld\n",
264 DBGC ( xendev,
"XENBUS could not probe %s: %s\n",
315 DBGC ( xen,
"XENBUS has no driver for \"%s\" devices\n",
type );
324 DBGC ( xen,
"XENBUS could not list \"%s\" devices: %s\n",
331 child += (
strlen ( child ) + 1 ) ) {
334 goto err_probe_device;
363 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
struct xen_driver * driver
Driver.
#define __unused
Declare a variable or data structure as unused.
#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 with interrupts enabled 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.