/* * Copyright (C) 2007-2009 Free Software Foundation * * This program is free software ; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation ; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY ; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with the program ; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include #include #include "evt.h" #define NEVNT (sizeof(unsigned long) * sizeof(unsigned long) * 8) int int_mask[NSPL]; spl_t curr_ipl; void (*ivect[NEVNT])(); int intpri[NEVNT]; int iunit[NEVNT]; void hyp_c_callback(void *ret_addr, void *regs) { int i, j, n; int cpu = 0; unsigned long pending_sel; hyp_shared_info.vcpu_info[cpu].evtchn_upcall_pending = 0; /* no need for a barrier on x86, xchg is already one */ #if !(defined(__i386__) || defined(__x86_64__)) wmb(); #endif while ((pending_sel = xchgl(&hyp_shared_info.vcpu_info[cpu].evtchn_pending_sel, 0))) { for (i = 0; pending_sel; i++, pending_sel >>= 1) { unsigned long pending; if (!(pending_sel & 1)) continue; while ((pending = (hyp_shared_info.evtchn_pending[i] & ~hyp_shared_info.evtchn_mask[i]))) { n = i * sizeof(unsigned long); for (j = 0; pending; j++, n++, pending >>= 1) { if (!(pending & 1)) continue; if (ivect[n]) { spl_t spl = splx(intpri[n]); asm ("lock; and %1,%0":"=m"(hyp_shared_info.evtchn_pending[i]):"r"(~(1UL< NEVNT) panic("event channel port %d > %d not supported\n", port, NEVNT); intpri[port] = spl; iunit[port] = unit; form_int_mask(); wmb(); ivect[port] = handler; }