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