Xen Test Framework
grant_table.c
Go to the documentation of this file.
1
6#include <xtf/grant_table.h>
7#include <xtf/lib.h>
8
10extern grant_entry_v1_t gnttab_v1[] __alias("gnttab_raw");
11extern grant_entry_v2_t gnttab_v2[] __alias("gnttab_raw");
12
13const char *gntst_strerror(int err)
14{
15 static const char *const errstr[] = GNTTABOP_error_msgs;
16 unsigned int idx = -err;
17
18 return idx < ARRAY_SIZE(errstr) ? errstr[idx] : "unknown";
19}
20
21int xtf_init_grant_table(unsigned int version)
22{
23 int rc = 0;
24
25 static bool set_version_unavailable;
26 if ( !set_version_unavailable )
27 {
28 struct gnttab_set_version ver = { version };
29
31
32 if ( rc == -ENOSYS )
33 /* Hypercall unavailable on older versions of Xen. */
34 set_version_unavailable = true;
35
36 else if ( rc )
37 {
38 printk("%s() GNTTABOP_set_version failed: rc %d\n", __func__, rc);
39 return -EIO;
40 }
41 }
42
43 if ( set_version_unavailable && version != 1 )
44 /* Sufficiently old Xen which only knows about gnttab v1. */
45 return -ENODEV;
46
47 static bool gnttab_mapped;
48 if ( !gnttab_mapped )
49 {
50 rc = arch_map_gnttab();
51
52 if ( !rc )
53 gnttab_mapped = true;
54 }
55
56 return rc;
57}
58
59/*
60 * Local variables:
61 * mode: C
62 * c-file-style: "BSD"
63 * c-basic-offset: 4
64 * tab-width: 4
65 * indent-tabs-mode: nil
66 * End:
67 */
int arch_map_gnttab(void)
Map the domains grant table under gnttab_raw[].
Definition: grant_table.c:13
grant_entry_v1_t gnttab_v1[]
const char * gntst_strerror(int err)
Convert a grant status error value to a string.
Definition: grant_table.c:13
grant_entry_v2_t gnttab_v2[]
uint8_t gnttab_raw[]
Raw grant table mapping from Xen.
Definition: grant_table.c:9
int xtf_init_grant_table(unsigned int version)
Initialise XTF's grant infrastructure.
Definition: grant_table.c:21
#define __alias(x)
Definition: compiler.h:8
#define __page_aligned_bss
Definition: compiler.h:37
void printk(const char *fmt,...)
Definition: console.c:134
#define ENOSYS
Definition: errno.h:43
#define EIO
Definition: errno.h:19
#define ENODEV
Definition: errno.h:32
static long hypercall_grant_table_op(unsigned int cmd, void *args, unsigned int count)
Definition: hypercall.h:131
#define ARRAY_SIZE(a)
Definition: lib.h:8
__UINT8_TYPE__ uint8_t
Definition: stdint.h:14
Definition: grant_table.h:106
Definition: grant_table.h:125
#define GNTTABOP_error_msgs
Definition: grant_table.h:24
#define GNTTABOP_set_version
Definition: grant_table.h:304
A driver for the Xen Grant Table interface.