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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/******************************************************************************
* 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, evtchn_op_t *op)
{
int ret = -1;
privcmd_hypercall_t hypercall;
hypercall.op = __HYPERVISOR_event_channel_op;
hypercall.arg[0] = (unsigned long)op;
if ( mlock(op, sizeof(*op)) != 0 )
{
PERROR("Could not lock memory for Xen hypercall");
goto out1;
}
if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
goto out2;
out2: (void)munlock(op, sizeof(*op));
out1: return ret;
}
int xc_evtchn_bind_interdomain(int xc_handle,
u64 dom1,
u64 dom2,
int *port1,
int *port2)
{
evtchn_op_t op;
int rc;
op.cmd = EVTCHNOP_bind_interdomain;
op.u.bind_interdomain.dom1 = (domid_t)dom1;
op.u.bind_interdomain.dom2 = (domid_t)dom2;
if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
{
if ( port1 != NULL )
*port1 = op.u.bind_interdomain.port1;
if ( port2 != NULL )
*port2 = op.u.bind_interdomain.port2;
}
return rc;
}
int xc_evtchn_close(int xc_handle,
u64 dom,
int port)
{
evtchn_op_t op;
op.cmd = EVTCHNOP_close;
op.u.close.dom = (domid_t)dom;
op.u.close.port = port;
return do_evtchn_op(xc_handle, &op);
}
int xc_evtchn_send(int xc_handle,
int local_port)
{
evtchn_op_t op;
op.cmd = EVTCHNOP_send;
op.u.send.local_port = local_port;
return do_evtchn_op(xc_handle, &op);
}
int xc_evtchn_status(int xc_handle,
u64 dom,
int port,
xc_evtchn_status_t *status)
{
evtchn_op_t op;
int rc;
op.cmd = EVTCHNOP_status;
op.u.status.dom = (domid_t)dom;
op.u.status.port = port;
if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
{
switch ( status->status = op.u.status.status )
{
case EVTCHNSTAT_interdomain:
status->u.interdomain.dom = (u64)op.u.status.u.interdomain.dom;
status->u.interdomain.port = op.u.status.u.interdomain.port;
break;
case EVTCHNSTAT_pirq:
status->u.pirq = op.u.status.u.pirq;
break;
case EVTCHNSTAT_virq:
status->u.virq = op.u.status.u.virq;
break;
}
}
return rc;
}
|