aboutsummaryrefslogtreecommitdiff
path: root/src/include/ipxe/xen.h
blob: eac1145ad8b011b5ff3dea6626175714bca6a353 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef _IPXE_XEN_H
#define _IPXE_XEN_H

/** @file
 *
 * Xen interface
 *
 */

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );

/* Define Xen interface version before including any Xen header files */
#define __XEN_INTERFACE_VERSION__ 0x00040400

#include <stdint.h>
#include <ipxe/uaccess.h>
#include <xen/xen.h>
#include <xen/event_channel.h>

/* Memory barrier macros used by ring.h */
#define xen_mb() mb()
#define xen_rmb() rmb()
#define xen_wmb() wmb()

struct xen_hypercall;

/** A Xen grant table */
struct xen_grant {
	/** Grant table entries */
	struct grant_entry_v1 *table;
	/** Total grant table length */
	size_t len;
	/** Entry size shift (for later version tables) */
	unsigned int shift;
	/** Number of grant table entries in use */
	unsigned int used;
	/** Most recently used grant reference */
	unsigned int ref;
};

/** A XenStore */
struct xen_store {
	/** XenStore domain interface */
	struct xenstore_domain_interface *intf;
	/** Event channel */
	evtchn_port_t port;
};

/** A Xen hypervisor */
struct xen_hypervisor {
	/** Hypercall table */
	struct xen_hypercall *hypercall;
	/** Shared info page */
	struct shared_info *shared;
	/** Grant table */
	struct xen_grant grant;
	/** XenStore */
	struct xen_store store;
};

#include <bits/xen.h>

/**
 * Convert a Xen status code to an iPXE status code
 *
 * @v xenrc		Xen status code (negated)
 * @ret rc		iPXE status code (before negation)
 *
 * Xen status codes are defined in the file include/xen/errno.h in the
 * Xen repository.  They happen to match the Linux error codes, some
 * of which can be found in our include/ipxe/errno/linux.h.
 */
#define EXEN( xenrc ) EPLATFORM ( EINFO_EPLATFORM, -(xenrc) )

#endif /* _IPXE_XEN_H */