iPXE
xenbus.h
Go to the documentation of this file.
00001 #ifndef _IPXE_XENBUS_H
00002 #define _IPXE_XENBUS_H
00003 
00004 /** @file
00005  *
00006  * Xen device bus
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <ipxe/device.h>
00013 #include <ipxe/tables.h>
00014 #include <ipxe/xen.h>
00015 #include <xen/io/xenbus.h>
00016 
00017 /** A Xen device */
00018 struct xen_device {
00019         /** Generic iPXE device */
00020         struct device dev;
00021         /** Xen hypervisor */
00022         struct xen_hypervisor *xen;
00023         /** XenStore key */
00024         char *key;
00025         /** Backend XenStore key */
00026         char *backend;
00027         /** Backend domain ID */
00028         unsigned long backend_id;
00029         /** Driver */
00030         struct xen_driver *driver;
00031         /** Driver-private data */
00032         void *priv;
00033 };
00034 
00035 /** A Xen device driver */
00036 struct xen_driver {
00037         /** Name */
00038         const char *name;
00039         /** Device type */
00040         const char *type;
00041         /** Probe device
00042          *
00043          * @v xendev            Xen device
00044          * @ret rc              Return status code
00045          */
00046         int ( * probe ) ( struct xen_device *xendev );
00047         /** Remove device
00048          *
00049          * @v xendev            Xen device
00050          */
00051         void ( * remove ) ( struct xen_device *xendev );
00052 };
00053 
00054 /** Xen device driver table */
00055 #define XEN_DRIVERS __table ( struct xen_driver, "xen_drivers" )
00056 
00057 /** Declare a Xen device driver */
00058 #define __xen_driver __table_entry ( XEN_DRIVERS, 01 )
00059 
00060 /**
00061  * Set Xen device driver-private data
00062  *
00063  * @v xendev            Xen device
00064  * @v priv              Private data
00065  */
00066 static inline void xen_set_drvdata ( struct xen_device *xendev, void *priv ) {
00067         xendev->priv = priv;
00068 }
00069 
00070 /**
00071  * Get Xen device driver-private data
00072  *
00073  * @v xendev            Xen device
00074  * @ret priv            Private data
00075  */
00076 static inline void * xen_get_drvdata ( struct xen_device *xendev ) {
00077         return xendev->priv;
00078 }
00079 
00080 extern int xenbus_set_state ( struct xen_device *xendev, int state );
00081 extern int xenbus_backend_state ( struct xen_device *xendev );
00082 extern int xenbus_backend_wait ( struct xen_device *xendev, int state );
00083 extern int xenbus_probe ( struct xen_hypervisor *xen, struct device *parent );
00084 extern void xenbus_remove ( struct xen_hypervisor *xen, struct device *parent );
00085 
00086 #endif /* _IPXE_XENBUS_H */