45#define ETIMEDOUT_UNKNOWN \
46 __einfo_error ( EINFO_ETIMEDOUT_UNKNOWN )
47#define EINFO_ETIMEDOUT_UNKNOWN \
48 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateUnknown, \
50#define ETIMEDOUT_INITIALISING \
51 __einfo_error ( EINFO_ETIMEDOUT_INITIALISING )
52#define EINFO_ETIMEDOUT_INITIALISING \
53 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateInitialising, \
55#define ETIMEDOUT_INITWAIT \
56 __einfo_error ( EINFO_ETIMEDOUT_INITWAIT )
57#define EINFO_ETIMEDOUT_INITWAIT \
58 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateInitWait, \
60#define ETIMEDOUT_INITIALISED \
61 __einfo_error ( EINFO_ETIMEDOUT_INITIALISED )
62#define EINFO_ETIMEDOUT_INITIALISED \
63 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateInitialised, \
65#define ETIMEDOUT_CONNECTED \
66 __einfo_error ( EINFO_ETIMEDOUT_CONNECTED )
67#define EINFO_ETIMEDOUT_CONNECTED \
68 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateConnected, \
70#define ETIMEDOUT_CLOSING \
71 __einfo_error ( EINFO_ETIMEDOUT_CLOSING )
72#define EINFO_ETIMEDOUT_CLOSING \
73 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateClosing, \
75#define ETIMEDOUT_CLOSED \
76 __einfo_error ( EINFO_ETIMEDOUT_CLOSED )
77#define EINFO_ETIMEDOUT_CLOSED \
78 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateClosed, \
80#define ETIMEDOUT_RECONFIGURING \
81 __einfo_error ( EINFO_ETIMEDOUT_RECONFIGURING )
82#define EINFO_ETIMEDOUT_RECONFIGURING \
83 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateReconfiguring, \
85#define ETIMEDOUT_RECONFIGURED \
86 __einfo_error ( EINFO_ETIMEDOUT_RECONFIGURED )
87#define EINFO_ETIMEDOUT_RECONFIGURED \
88 __einfo_uniqify ( EINFO_ETIMEDOUT, XenbusStateReconfigured, \
90#define ETIMEDOUT_STATE( state ) \
91 EUNIQ ( EINFO_ETIMEDOUT, (state), ETIMEDOUT_UNKNOWN, \
92 ETIMEDOUT_INITIALISING, ETIMEDOUT_INITWAIT, \
93 ETIMEDOUT_INITIALISED, ETIMEDOUT_CONNECTED, \
94 ETIMEDOUT_CLOSING, ETIMEDOUT_CLOSED, \
95 ETIMEDOUT_RECONFIGURING, ETIMEDOUT_RECONFIGURED )
98#define XENBUS_BACKEND_TIMEOUT ( 5 * TICKS_PER_SEC )
112 "state",
NULL ) ) != 0 ) {
113 DBGC ( xendev,
"XENBUS %s could not set state=\"%d\": %s\n",
133 "state",
NULL ) ) != 0 ) {
134 DBGC ( xendev,
"XENBUS %s could not read %s/state: %s\n",
151 unsigned long elapsed;
152 unsigned int attempts = 0;
161 if ( current_state < 0 ) {
165 if ( current_state ==
state )
183 DBGC ( xendev,
"XENBUS %s timed out after %d attempts waiting for "
184 "%s/state=\"%d\": %s\n", xendev->
key, attempts, xendev->
backend,
216 struct device *parent,
const char *instance,
225 strlen ( instance ) + 1 );
226 xendev =
zalloc (
sizeof ( *xendev ) + key_len );
238 xendev->
key = ( (
void * ) ( xendev + 1 ) );
242 DBGC ( xendev,
"XENBUS %s has driver \"%s\"\n", xendev->
key,
247 "backend",
NULL ) ) != 0 ) {
248 DBGC ( xendev,
"XENBUS %s could not read backend: %s\n",
250 goto err_read_backend;
255 "backend-id",
NULL ) ) != 0 ) {
256 DBGC ( xendev,
"XENBUS %s could not read backend-id: %s\n",
258 goto err_read_backend_id;
260 DBGC ( xendev,
"XENBUS %s backend=\"%s\" in domain %ld\n",
265 DBGC ( xendev,
"XENBUS could not probe %s: %s\n",
316 DBGC ( xen,
"XENBUS has no driver for \"%s\" devices\n",
type );
325 DBGC ( xen,
"XENBUS could not list \"%s\" devices: %s\n",
332 child += (
strlen ( child ) + 1 ) ) {
335 goto err_probe_device;
364 DBGC ( xen,
"XENBUS could not list device types: %s\n",
#define NULL
NULL pointer (VOID *)
struct arbelprm_rc_send_wqe rc
#define BUS_TYPE_XEN
Xen bus type.
uint32_t type
Operating system type.
#define __unused
Declare a variable or data structure as unused.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define REQUIRE_OBJECT(object)
Require an object.
#define ENOMEM
Not enough space.
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
#define REQUIRING_SYMBOL(symbol)
Specify the file's requiring symbol.
void cpu_nap(void)
Sleep with interrupts enabled until next CPU interrupt.
static int started
"startup() has been called" flag
#define XEN_DRIVERS
Xen device driver table.
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
#define list_del(list)
Delete an entry from a list.
#define INIT_LIST_HEAD(list)
Initialise a list head.
void * zalloc(size_t size)
Allocate cleared memory.
Dynamic memory allocation.
static void(* free)(struct refcnt *refcnt))
char * strerror(int errno)
Retrieve string representation of error number.
int strcmp(const char *first, const char *second)
Compare strings.
size_t strlen(const char *src)
Get length of string.
unsigned int bus_type
Bus type.
struct device_description desc
Device description.
struct device * parent
Bus device.
struct list_head children
Devices attached to this device.
struct list_head siblings
Devices on the same bus.
const char * driver_name
Driver name.
struct xen_driver * driver
Driver.
unsigned long backend_id
Backend domain ID.
struct device dev
Generic iPXE device.
struct xen_hypervisor * xen
Xen hypervisor.
char * backend
Backend XenStore key.
const char * type
Device type.
void(* remove)(struct xen_device *xendev)
Remove device.
int(* probe)(struct xen_device *xendev)
Probe device.
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
unsigned long currticks(void)
Get current system time in ticks.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
int xenbus_backend_state(struct xen_device *xendev)
Get backend state.
#define XENBUS_BACKEND_TIMEOUT
Maximum time to wait for backend to reach a given state, in ticks.
static void xenbus_remove_device(struct xen_device *xendev)
Remove Xen device.
void xenbus_remove(struct xen_hypervisor *xen __unused, struct device *parent)
Remove Xen bus.
int xenbus_set_state(struct xen_device *xendev, int state)
Set device state.
static int xenbus_probe_type(struct xen_hypervisor *xen, struct device *parent, const char *type)
Probe Xen devices of a given type.
static struct xen_driver * xenbus_find_driver(const char *type)
Find driver for Xen device.
int xenbus_backend_wait(struct xen_device *xendev, int state)
Wait for backend to reach a given state.
#define ETIMEDOUT_STATE(state)
static int xenbus_probe_device(struct xen_hypervisor *xen, struct device *parent, const char *instance, struct xen_driver *driver)
Probe Xen device.
int xenbus_probe(struct xen_hypervisor *xen, struct device *parent)
Probe Xen bus.
int xenstore_directory(struct xen_hypervisor *xen, char **children, size_t *len,...)
Read XenStore directory.
int xenstore_read(struct xen_hypervisor *xen, char **value,...)
Read XenStore value.
int xenstore_read_num(struct xen_hypervisor *xen, unsigned long *num,...)
Read XenStore numeric value.
int xenstore_write_num(struct xen_hypervisor *xen, unsigned long num,...)
Write XenStore numeric value.
char unsigned long const char unsigned long char ** children