Files
xen/tools/libxc/xc_evtchn.c
T
kaf24@firebug.cl.cam.ac.uk d8263e8dba Fix Xen public interfaces and the tools to consistently
use stdint-format bitsize types (uint32_t and friends).

Signed-off-by: Keir Fraser <keir@xensource.com>
2005-10-12 11:07:37 +01:00

68 lines
1.6 KiB
C

/******************************************************************************
* 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("do_evtchn_op: op mlock failed");
goto out;
}
if ((ret = do_xen_hypercall(xc_handle, &hypercall)) < 0)
ERROR("do_evtchn_op: HYPERVISOR_event_channel_op failed: %d", ret);
safe_munlock(op, sizeof(*op));
out:
return ret;
}
int xc_evtchn_alloc_unbound(int xc_handle,
uint32_t dom,
uint32_t remote_dom)
{
int rc;
evtchn_op_t op = {
.cmd = EVTCHNOP_alloc_unbound,
.u.alloc_unbound.dom = (domid_t)dom,
.u.alloc_unbound.remote_dom = (domid_t)remote_dom };
if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
rc = op.u.alloc_unbound.port;
return rc;
}
int xc_evtchn_status(int xc_handle,
uint32_t dom,
int port,
xc_evtchn_status_t *status)
{
int rc;
evtchn_op_t op = {
.cmd = EVTCHNOP_status,
.u.status.dom = (domid_t)dom,
.u.status.port = port };
if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
memcpy(status, &op.u.status, sizeof(*status));
return rc;
}