From 5e0b8d508ed51004bd836384293be00950ee62c9 Mon Sep 17 00:00:00 2001 From: Pasha Date: Tue, 20 Feb 2024 18:49:50 +0000 Subject: init gnumach copy --- xen/evt.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 xen/evt.c (limited to 'xen/evt.c') diff --git a/xen/evt.c b/xen/evt.c new file mode 100644 index 0000000..7296ae4 --- /dev/null +++ b/xen/evt.c @@ -0,0 +1,119 @@ +/* + * 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[NCPUS]; +int spl_init = 0; + +interrupt_handler_fn 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, (int) NEVNT); + intpri[port] = spl; + iunit[port] = unit; + form_int_mask(); + wmb(); + ivect[port] = handler; +} -- cgit v1.2.1