diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libxc/xc_evtchn.c | 11 | ||||
-rw-r--r-- | tools/libxc/xc_linux.c | 16 | ||||
-rw-r--r-- | tools/libxc/xc_minios.c | 19 | ||||
-rw-r--r-- | tools/libxc/xc_netbsd.c | 14 | ||||
-rw-r--r-- | tools/libxc/xc_solaris.c | 14 | ||||
-rw-r--r-- | tools/libxc/xenctrlosdep.h | 3 |
6 files changed, 54 insertions, 23 deletions
diff --git a/tools/libxc/xc_evtchn.c b/tools/libxc/xc_evtchn.c index 81fc15b29a..d8c203f2c2 100644 --- a/tools/libxc/xc_evtchn.c +++ b/tools/libxc/xc_evtchn.c @@ -112,6 +112,17 @@ int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port) 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 diff --git a/tools/libxc/xc_linux.c b/tools/libxc/xc_linux.c index 9044020fe8..188741f3df 100644 --- a/tools/libxc/xc_linux.c +++ b/tools/libxc/xc_linux.c @@ -420,20 +420,24 @@ static int linux_evtchn_unbind(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t 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 = { @@ -447,6 +451,8 @@ 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, }, }; diff --git a/tools/libxc/xc_minios.c b/tools/libxc/xc_minios.c index e01b4b4992..af3791f4fa 100644 --- a/tools/libxc/xc_minios.c +++ b/tools/libxc/xc_minios.c @@ -371,22 +371,23 @@ static evtchn_port_or_error_t minios_evtchn_bind_virq(xc_evtchn *xce, xc_osdep_h 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; } } @@ -395,7 +396,7 @@ evtchn_port_or_error_t xc_evtchn_pending(xc_evtchn *xce) 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; @@ -412,7 +413,9 @@ static struct xc_osdep_ops minios_evtchn_ops = { .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 */ diff --git a/tools/libxc/xc_netbsd.c b/tools/libxc/xc_netbsd.c index 9d708fce57..47169ee5b4 100644 --- a/tools/libxc/xc_netbsd.c +++ b/tools/libxc/xc_netbsd.c @@ -285,20 +285,22 @@ netbsd_evtchn_bind_virq(xc_evtchn *xce, xc_osdep_handle h, unsigned int virq) 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 = { @@ -312,6 +314,8 @@ 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, }, }; diff --git a/tools/libxc/xc_solaris.c b/tools/libxc/xc_solaris.c index ea786e79ee..beec2872d4 100644 --- a/tools/libxc/xc_solaris.c +++ b/tools/libxc/xc_solaris.c @@ -262,20 +262,22 @@ static int solaris_evtchn_unbind(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_ 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 = { @@ -289,6 +291,8 @@ 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, }, }; diff --git a/tools/libxc/xenctrlosdep.h b/tools/libxc/xenctrlosdep.h index 9091d0be8f..24d4bc27ef 100644 --- a/tools/libxc/xenctrlosdep.h +++ b/tools/libxc/xenctrlosdep.h @@ -85,6 +85,9 @@ struct xc_osdep_ops 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; }; |