debuggers.hg

view tools/libxc/xc_evtchn.c @ 16715:c5deb251b9dc

Update version to 3.2.0-rc4
author Keir Fraser <keir.fraser@citrix.com>
date Sat Dec 29 17:57:37 2007 +0000 (2007-12-29)
parents fdffab15499d
children 64f81cd158d4
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, size_t arg_size)
13 {
14 int ret = -1;
15 DECLARE_HYPERCALL;
17 hypercall.op = __HYPERVISOR_event_channel_op;
18 hypercall.arg[0] = cmd;
19 hypercall.arg[1] = (unsigned long)arg;
21 if ( lock_pages(arg, arg_size) != 0 )
22 {
23 PERROR("do_evtchn_op: arg lock failed");
24 goto out;
25 }
27 if ((ret = do_xen_hypercall(xc_handle, &hypercall)) < 0)
28 ERROR("do_evtchn_op: HYPERVISOR_event_channel_op failed: %d", ret);
30 unlock_pages(arg, arg_size);
31 out:
32 return ret;
33 }
36 evtchn_port_or_error_t
37 xc_evtchn_alloc_unbound(int xc_handle,
38 uint32_t dom,
39 uint32_t remote_dom)
40 {
41 int rc;
42 struct evtchn_alloc_unbound arg = {
43 .dom = (domid_t)dom,
44 .remote_dom = (domid_t)remote_dom
45 };
47 rc = do_evtchn_op(xc_handle, EVTCHNOP_alloc_unbound, &arg, sizeof(arg));
48 if ( rc == 0 )
49 rc = arg.port;
51 return rc;
52 }
54 int xc_evtchn_reset(int xc_handle,
55 uint32_t dom)
56 {
57 struct evtchn_reset arg = { .dom = (domid_t)dom };
58 return do_evtchn_op(xc_handle, EVTCHNOP_reset, &arg, sizeof(arg));
59 }