return xce->ops->u.evtchn.unbind(xce, xce->ops_handle, port);
}
+evtchn_port_or_error_t
+xc_evtchn_pending(xc_evtchn *xce)
+{
+ return xce->ops->u.evtchn.pending(xce, xce->ops_handle);
+}
+
+int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
+{
+ return xce->ops->u.evtchn.unmask(xce, xce->ops_handle, port);
+}
+
/*
* Local variables:
* mode: C
return ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind);
}
-evtchn_port_or_error_t
-xc_evtchn_pending(xc_evtchn *xce)
+static evtchn_port_or_error_t linux_evtchn_pending(xc_evtchn *xce, xc_osdep_handle h)
{
+ int fd = (int)h;
evtchn_port_t port;
- if ( read_exact(xce->fd, (char *)&port, sizeof(port)) == -1 )
+ if ( read(fd, &port, sizeof(port)) != sizeof(port) )
return -1;
return port;
}
-int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
+static int linux_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port)
{
- return write_exact(xce->fd, (char *)&port, sizeof(port));
+ int fd = (int)h;
+
+ if ( write(fd, &port, sizeof(port)) != sizeof(port) )
+ return -1;
+ return 0;
}
static struct xc_osdep_ops linux_evtchn_ops = {
.bind_interdomain = &linux_evtchn_bind_interdomain,
.bind_virq = &linux_evtchn_bind_virq,
.unbind = &linux_evtchn_unbind,
+ .pending = &linux_evtchn_pending,
+ .unmask = &linux_evtchn_unmask,
},
};
return port;
}
-evtchn_port_or_error_t xc_evtchn_pending(xc_evtchn *xce)
+static evtchn_port_or_error_t minios_evtchn_pending(xc_evtchn *xce, xc_osdep_handle h)
{
+ int fd = (int)h;
int i;
unsigned long flags;
evtchn_port_t ret = -1;
local_irq_save(flags);
- files[xce->fd].read = 0;
+ files[fd].read = 0;
for (i = 0; i < MAX_EVTCHN_PORTS; i++) {
- evtchn_port_t port = files[xce->fd].evtchn.ports[i].port;
- if (port != -1 && files[xce->fd].evtchn.ports[i].pending) {
+ evtchn_port_t port = files[fd].evtchn.ports[i].port;
+ if (port != -1 && files[fd].evtchn.ports[i].pending) {
if (ret == -1) {
ret = port;
- files[xce->fd].evtchn.ports[i].pending = 0;
+ files[fd].evtchn.ports[i].pending = 0;
} else {
- files[xce->fd].read = 1;
+ files[fd].read = 1;
break;
}
}
return ret;
}
-int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
+static int minios_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port)
{
unmask_evtchn(port);
return 0;
.bind_interdomain = &minios_evtchn_bind_interdomain,
.bind_virq = &minios_evtchn_bind_virq,
.unbind = &minios_evtchn_unbind,
- },
+ .pending = &minios_evtchn_pending,
+ .unmask = &minios_evtchn_unmask,
+ },
};
/* Optionally flush file to disk and discard page cache */
return bind.port;
}
-evtchn_port_or_error_t
-xc_evtchn_pending(xc_evtchn *xce)
+static evtchn_port_or_error_t
+netbsd_evtchn_pending(xc_evtchn *xce, xc_osdep_handle h)
{
+ int fd = (int)h;
evtchn_port_t port;
- if ( read_exact(xce->fd, (char *)&port, sizeof(port)) == -1 )
+ if ( read_exact(fd, (char *)&port, sizeof(port)) == -1 )
return -1;
return port;
}
-int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
+static int netbsd_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port)
{
- return write_exact(xce->fd, (char *)&port, sizeof(port));
+ int fd = (int)h;
+ return write_exact(fd, (char *)&port, sizeof(port));
}
static struct xc_osdep_ops netbsd_evtchn_ops = {
.bind_interdomain = &netbsd_evtchn_bind_interdomain,
.bind_virq = &netbsd_evtchn_bind_virq,
.unbind = &netbsd_evtchn_unbind,
+ .pending = &netbsd_evtchn_pending,
+ .unmask = &netbsd_evtchn_unmask,
},
};
return ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind);
}
-evtchn_port_or_error_t
-xc_evtchn_pending(xc_evtchn *xce)
+static evtchn_port_or_error_t
+solaris_evtchn_pending(xc_evtchn *xce, xc_osdep_handle h)
{
+ int fd = (int)h;
evtchn_port_t port;
- if ( read_exact(xce->fd, (char *)&port, sizeof(port)) == -1 )
+ if ( read_exact(fd, (char *)&port, sizeof(port)) == -1 )
return -1;
return port;
}
-int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
+static int solaris_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h,evtchn_port_t port)
{
- return write_exact(xce->fd, (char *)&port, sizeof(port));
+ int fd = (int)h;
+ return write_exact(fd, (char *)&port, sizeof(port));
}
static struct xc_osdep_ops solaris_evtchn_ops = {
.bind_interdomain = &solaris_evtchn_bind_interdomain,
.bind_virq = &solaris_evtchn_bind_virq,
.unbind = &solaris_evtchn_unbind,
+ .pending = &solaris_evtchn_pending,
+ .unmask = &solaris_evtchn_unmask,
},
};
evtchn_port_or_error_t (*bind_virq)(xc_evtchn *xce, xc_osdep_handle h, unsigned int virq);
int (*unbind)(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port);
+
+ evtchn_port_or_error_t (*pending)(xc_evtchn *xce, xc_osdep_handle h);
+ int (*unmask)(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port);
} evtchn;
} u;
};