debuggers.hg

view tools/libxc/xc_evtchn.c @ 21067:b4a1832a916f

Update Xen version to 4.0.0-rc6
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 09 18:18:05 2010 +0000 (2010-03-09)
parents be573a356c90
children 3ffdb094c2c0
line source
1 /******************************************************************************
2 * xc_evtchn.c
3 *
4 * API for manipulating and accessing inter-domain event channels.
5 *
6 * Copyright (c) 2004, K A Fraser.
7 */
9 #include "xc_private.h"
12 static int do_evtchn_op(int xc_handle, int cmd, void *arg,
13 size_t arg_size, int silently_fail)
14 {
15 int ret = -1;
16 DECLARE_HYPERCALL;
18 hypercall.op = __HYPERVISOR_event_channel_op;
19 hypercall.arg[0] = cmd;
20 hypercall.arg[1] = (unsigned long)arg;
22 if ( lock_pages(arg, arg_size) != 0 )
23 {
24 PERROR("do_evtchn_op: arg lock failed");
25 goto out;
26 }
28 if ((ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 && !silently_fail)
29 ERROR("do_evtchn_op: HYPERVISOR_event_channel_op failed: %d", ret);
31 unlock_pages(arg, arg_size);
32 out:
33 return ret;
34 }
37 evtchn_port_or_error_t
38 xc_evtchn_alloc_unbound(int xc_handle,
39 uint32_t dom,
40 uint32_t remote_dom)
41 {
42 int rc;
43 struct evtchn_alloc_unbound arg = {
44 .dom = (domid_t)dom,
45 .remote_dom = (domid_t)remote_dom
46 };
48 rc = do_evtchn_op(xc_handle, EVTCHNOP_alloc_unbound, &arg, sizeof(arg), 0);
49 if ( rc == 0 )
50 rc = arg.port;
52 return rc;
53 }
55 int xc_evtchn_reset(int xc_handle,
56 uint32_t dom)
57 {
58 struct evtchn_reset arg = { .dom = (domid_t)dom };
59 return do_evtchn_op(xc_handle, EVTCHNOP_reset, &arg, sizeof(arg), 0);
60 }
62 int xc_evtchn_status(int xc_handle, xc_evtchn_status_t *status)
63 {
64 return do_evtchn_op(xc_handle, EVTCHNOP_status, status,
65 sizeof(*status), 1);
66 }