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