iPXE
xen.h
Go to the documentation of this file.
1 #ifndef _IPXE_XEN_H
2 #define _IPXE_XEN_H
3 
4 /** @file
5  *
6  * Xen interface
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 /* Define Xen interface version before including any Xen header files */
13 #define __XEN_INTERFACE_VERSION__ 0x00040400
14 
15 #include <stdint.h>
16 #include <ipxe/bitops.h>
17 #include <xen/xen.h>
18 #include <xen/event_channel.h>
19 
20 /* Memory barrier macros used by ring.h */
21 #define xen_mb() mb()
22 #define xen_rmb() rmb()
23 #define xen_wmb() wmb()
24 
25 struct xen_hypercall;
26 
27 /** A Xen grant table */
28 struct xen_grant {
29  /** Grant table entries */
31  /** Total grant table length */
32  size_t len;
33  /** Entry size shift (for later version tables) */
34  unsigned int shift;
35  /** Number of grant table entries in use */
36  unsigned int used;
37  /** Most recently used grant reference */
38  unsigned int ref;
39 };
40 
41 /** A XenStore */
42 struct xen_store {
43  /** XenStore domain interface */
45  /** Event channel */
47 };
48 
49 /** A Xen hypervisor */
51  /** Hypercall table */
53  /** Shared info page */
55  /** Grant table */
56  struct xen_grant grant;
57  /** XenStore */
58  struct xen_store store;
59 };
60 
61 /**
62  * Test and clear pending event
63  *
64  * @v xen Xen hypervisor
65  * @v port Event channel port
66  * @ret pending Event was pending
67  */
68 static inline __attribute__ (( always_inline )) int
69 xenevent_pending ( struct xen_hypervisor *xen, evtchn_port_t port ) {
70 
71  return test_and_clear_bit ( port, xen->shared->evtchn_pending );
72 }
73 
74 #include <bits/xen.h>
75 
76 /**
77  * Convert a Xen status code to an iPXE status code
78  *
79  * @v xenrc Xen status code (negated)
80  * @ret rc iPXE status code (before negation)
81  *
82  * Xen status codes are defined in the file include/xen/errno.h in the
83  * Xen repository. They happen to match the Linux error codes, some
84  * of which can be found in our include/ipxe/errno/linux.h.
85  */
86 #define EXEN( xenrc ) EPLATFORM ( EINFO_EPLATFORM, -(xenrc) )
87 
88 #endif /* _IPXE_XEN_H */
uint32_t evtchn_port_t
Definition: event_channel.h:67
Bit operations.
A hypercall entry point.
Definition: xen.h:28
A Xen hypervisor.
Definition: xen.h:50
struct shared_info * shared
Shared info page.
Definition: xen.h:54
xen_ulong_t evtchn_pending[sizeof(xen_ulong_t) *8]
Definition: xen.h:763
struct grant_entry_v1 * table
Grant table entries.
Definition: xen.h:30
struct xen_hypercall * hypercall
Hypercall table.
Definition: xen.h:52
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
evtchn_port_t port
Event channel.
Definition: xen.h:46
A XenStore.
Definition: xen.h:42
Definition: grant_table.h:117
unsigned int ref
Most recently used grant reference.
Definition: xen.h:38
struct xen_hypercall __attribute__((packed))
struct xenstore_domain_interface * intf
XenStore domain interface.
Definition: xen.h:44
static evtchn_port_t port
Definition: xen.h:69
unsigned int shift
Entry size shift (for later version tables)
Definition: xen.h:34
struct xen_grant grant
Grant table.
Definition: xen.h:56
A Xen grant table.
Definition: xen.h:28
struct xen_store store
XenStore.
Definition: xen.h:58
size_t len
Total grant table length.
Definition: xen.h:32
int test_and_clear_bit(unsigned int bit, volatile void *bits)
unsigned int used
Number of grant table entries in use.
Definition: xen.h:36