iPXE
xenbus.h
Go to the documentation of this file.
1 #ifndef _IPXE_XENBUS_H
2 #define _IPXE_XENBUS_H
3 
4 /** @file
5  *
6  * Xen device bus
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <ipxe/device.h>
13 #include <ipxe/tables.h>
14 #include <ipxe/xen.h>
15 #include <xen/io/xenbus.h>
16 
17 /** A Xen device */
18 struct xen_device {
19  /** Generic iPXE device */
20  struct device dev;
21  /** Xen hypervisor */
23  /** XenStore key */
24  char *key;
25  /** Backend XenStore key */
26  char *backend;
27  /** Backend domain ID */
28  unsigned long backend_id;
29  /** Driver */
30  struct xen_driver *driver;
31  /** Driver-private data */
32  void *priv;
33 };
34 
35 /** A Xen device driver */
36 struct xen_driver {
37  /** Name */
38  const char *name;
39  /** Device type */
40  const char *type;
41  /** Probe device
42  *
43  * @v xendev Xen device
44  * @ret rc Return status code
45  */
46  int ( * probe ) ( struct xen_device *xendev );
47  /** Remove device
48  *
49  * @v xendev Xen device
50  */
51  void ( * remove ) ( struct xen_device *xendev );
52 };
53 
54 /** Xen device driver table */
55 #define XEN_DRIVERS __table ( struct xen_driver, "xen_drivers" )
56 
57 /** Declare a Xen device driver */
58 #define __xen_driver __table_entry ( XEN_DRIVERS, 01 )
59 
60 /**
61  * Set Xen device driver-private data
62  *
63  * @v xendev Xen device
64  * @v priv Private data
65  */
66 static inline void xen_set_drvdata ( struct xen_device *xendev, void *priv ) {
67  xendev->priv = priv;
68 }
69 
70 /**
71  * Get Xen device driver-private data
72  *
73  * @v xendev Xen device
74  * @ret priv Private data
75  */
76 static inline void * xen_get_drvdata ( struct xen_device *xendev ) {
77  return xendev->priv;
78 }
79 
80 extern int xenbus_set_state ( struct xen_device *xendev, int state );
81 extern int xenbus_backend_state ( struct xen_device *xendev );
82 extern int xenbus_backend_wait ( struct xen_device *xendev, int state );
83 extern int xenbus_probe ( struct xen_hypervisor *xen, struct device *parent );
84 extern void xenbus_remove ( struct xen_hypervisor *xen, struct device *parent );
85 
86 #endif /* _IPXE_XENBUS_H */
int xenbus_backend_wait(struct xen_device *xendev, int state)
Wait for backend to reach a given state.
Definition: xenbus.c:147
char * backend
Backend XenStore key.
Definition: xenbus.h:26
uint8_t state
State.
Definition: eth_slow.h:47
const char * type
Device type.
Definition: xenbus.h:40
int xenbus_set_state(struct xen_device *xendev, int state)
Set device state.
Definition: xenbus.c:105
A Xen hypervisor.
Definition: xen.h:51
Xen interface.
A Xen device.
Definition: xenbus.h:18
A hardware device.
Definition: device.h:73
void * priv
Driver-private data.
Definition: xenbus.h:32
struct xen_driver * driver
Driver.
Definition: xenbus.h:30
static void xen_set_drvdata(struct xen_device *xendev, void *priv)
Set Xen device driver-private data.
Definition: xenbus.h:66
const char * name
Name.
Definition: xenbus.h:38
unsigned long backend_id
Backend domain ID.
Definition: xenbus.h:28
int xenbus_probe(struct xen_hypervisor *xen, struct device *parent)
Probe Xen bus.
Definition: xenbus.c:353
int(* probe)(struct xen_device *xendev)
Probe device.
Definition: xenbus.h:46
static struct tlan_private * priv
Definition: tlan.c:224
void(* remove)(struct xen_device *xendev)
Remove device.
Definition: xenbus.h:51
char * key
XenStore key.
Definition: xenbus.h:24
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
Linker tables.
Device model.
struct device dev
Generic iPXE device.
Definition: xenbus.h:20
A Xen device driver.
Definition: xenbus.h:36
int xenbus_backend_state(struct xen_device *xendev)
Get backend state.
Definition: xenbus.c:125
void xenbus_remove(struct xen_hypervisor *xen, struct device *parent)
static void * xen_get_drvdata(struct xen_device *xendev)
Get Xen device driver-private data.
Definition: xenbus.h:76
struct xen_hypervisor * xen
Xen hypervisor.
Definition: xenbus.h:22