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
|
/******************************************************************************
* xc_evtchn.c
*
* API for manipulating and accessing inter-domain event channels.
*
* Copyright (c) 2004, K A Fraser.
*/
#include "xc_private.h"
static int do_evtchn_op(int xc_handle, int cmd, void *arg,
size_t arg_size, int silently_fail)
{
int ret = -1;
DECLARE_HYPERCALL;
hypercall.op = __HYPERVISOR_event_channel_op;
hypercall.arg[0] = cmd;
hypercall.arg[1] = (unsigned long)arg;
if ( lock_pages(arg, arg_size) != 0 )
{
PERROR("do_evtchn_op: arg lock failed");
goto out;
}
if ((ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 && !silently_fail)
ERROR("do_evtchn_op: HYPERVISOR_event_channel_op failed: %d", ret);
unlock_pages(arg, arg_size);
out:
return ret;
}
evtchn_port_or_error_t
xc_evtchn_alloc_unbound(int xc_handle,
uint32_t dom,
uint32_t remote_dom)
{
int rc;
struct evtchn_alloc_unbound arg = {
.dom = (domid_t)dom,
.remote_dom = (domid_t)remote_dom
};
rc = do_evtchn_op(xc_handle, EVTCHNOP_alloc_unbound, &arg, sizeof(arg), 0);
if ( rc == 0 )
rc = arg.port;
return rc;
}
int xc_evtchn_reset(int xc_handle,
uint32_t dom)
{
struct evtchn_reset arg = { .dom = (domid_t)dom };
return do_evtchn_op(xc_handle, EVTCHNOP_reset, &arg, sizeof(arg), 0);
}
int xc_evtchn_status(int xc_handle,
uint32_t dom,
uint32_t port)
{
int rc;
struct evtchn_status arg = { .dom = (domid_t)dom,
.port = (evtchn_port_t)port };
rc = do_evtchn_op(xc_handle, EVTCHNOP_status, &arg, sizeof(arg), 1);
if ( rc == 0 )
rc = arg.status;
return rc;
}
|