debuggers.hg

view tools/libxc/xc_evtchn.c @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children f875aaa791f0
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,
63 uint32_t dom,
64 uint32_t port)
65 {
66 int rc;
67 struct evtchn_status arg = { .dom = (domid_t)dom,
68 .port = (evtchn_port_t)port };
70 rc = do_evtchn_op(xc_handle, EVTCHNOP_status, &arg, sizeof(arg), 1);
71 if ( rc == 0 )
72 rc = arg.status;
74 return rc;
75 }