-/* $OpenBSD: xen.c,v 1.61 2016/08/05 18:31:21 mikeb Exp $ */
+/* $OpenBSD: xen.c,v 1.62 2016/08/17 17:18:38 mikeb Exp $ */
/*
* Copyright (c) 2015 Mike Belopuhov
SLIST_INSERT_HEAD(&sc->sc_intrs, xi, xi_entry);
/* Mask the event port */
- atomic_setbit_ptr(&sc->sc_ipg->evtchn_mask[0], xi->xi_port);
+ set_bit(xi->xi_port, &sc->sc_ipg->evtchn_mask[0]);
#if defined(XEN_DEBUG) && disabled
memset(&es, 0, sizeof(es));
taskq_destroy(xi->xi_taskq);
- atomic_setbit_ptr(&sc->sc_ipg->evtchn_mask[0], xi->xi_port);
- atomic_clearbit_ptr(&sc->sc_ipg->evtchn_pending[0], xi->xi_port);
+ set_bit(xi->xi_port, &sc->sc_ipg->evtchn_mask[0]);
+ clear_bit(xi->xi_port, &sc->sc_ipg->evtchn_pending[0]);
if (!xi->xi_noclose) {
ec.port = xi->xi_port;
printf("%s: unmasking port %u failed\n",
sc->sc_dev.dv_xname, xi->xi_port);
virtio_membar_sync();
- if (isset((char *)&sc->sc_ipg->evtchn_mask[0],
- xi->xi_port))
+ if (test_bit(xi->xi_port, &sc->sc_ipg->evtchn_mask[0]))
printf("%s: port %u is still masked\n",
sc->sc_dev.dv_xname, xi->xi_port);
}
if ((xi = xen_lookup_intsrc(sc, port)) != NULL) {
xi->xi_masked = 1;
- atomic_setbit_ptr(&sc->sc_ipg->evtchn_mask[0], xi->xi_port);
+ set_bit(xi->xi_port, &sc->sc_ipg->evtchn_mask[0]);
}
}
if ((xi = xen_lookup_intsrc(sc, port)) != NULL) {
xi->xi_masked = 0;
- if (!isset((char *)&sc->sc_ipg->evtchn_mask[0], xi->xi_port))
+ if (!test_bit(xi->xi_port, &sc->sc_ipg->evtchn_mask[0]))
return (0);
eu.port = xi->xi_port;
return (xen_evtchn_hypercall(sc, EVTCHNOP_unmask, &eu,
-/* $OpenBSD: xenvar.h,v 1.35 2016/08/03 17:14:41 mikeb Exp $ */
+/* $OpenBSD: xenvar.h,v 1.36 2016/08/17 17:18:38 mikeb Exp $ */
/*
* Copyright (c) 2015 Mike Belopuhov
struct xs_softc *xst_sc;
};
-static inline int
-atomic_setbit_ptr(volatile void *ptr, int bit)
+static __inline void
+clear_bit(u_int b, volatile void *p)
{
- int obit;
-
- __asm__ __volatile__ ("lock btsl %2,%1; sbbl %0,%0" :
- "=r" (obit), "=m" (*(volatile long *)ptr) : "Ir" (bit) :
- "memory");
-
- return (obit);
+ atomic_clearbits_int(((volatile u_int *)p) + (b >> 5), 1 << (b & 0x1f));
}
-static inline int
-atomic_clearbit_ptr(volatile void *ptr, int bit)
+static __inline void
+set_bit(u_int b, volatile void *p)
{
- int obit;
-
- __asm__ __volatile__ ("lock btrl %2,%1; sbbl %0,%0" :
- "=r" (obit), "=m" (*(volatile long *)ptr) : "Ir" (bit) :
- "memory");
+ atomic_setbits_int(((volatile u_int *)p) + (b >> 5), 1 << (b & 0x1f));
+}
- return (obit);
+static __inline int
+test_bit(u_int b, volatile void *p)
+{
+ return !!(((volatile u_int *)p)[b >> 5] & (1 << (b & 0x1f)));
}
int xs_cmd(struct xs_transaction *, int, const char *, struct iovec **,