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/xen.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 xen/xen.c (limited to 'xen/xen.c') diff --git a/xen/xen.c b/xen/xen.c new file mode 100644 index 0000000..6d42447 --- /dev/null +++ b/xen/xen.c @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2007-2011 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 +#include +#include +#include +#include "xen.h" +#include "evt.h" + +static void hyp_debug(void) +{ + panic("debug"); +} + +void hyp_init(void) +{ + hyp_grant_init(); + hyp_store_init(); + evtchn_port_t port = hyp_event_channel_bind_virq(VIRQ_DEBUG, 0); + hyp_evt_handler(port, (interrupt_handler_fn)hyp_debug, 0, SPL7); +} + +void hyp_dev_init(void) +{ + /* these depend on hyp_init() and working threads */ + hyp_block_init(); + hyp_net_init(); +} + +extern int int_mask[]; +void hyp_idle(void) +{ + int cpu = 0; + hyp_shared_info.vcpu_info[cpu].evtchn_upcall_mask = 0xff; + barrier(); + /* Avoid blocking if there are pending events */ + if (!hyp_shared_info.vcpu_info[cpu].evtchn_upcall_pending && + !hyp_shared_info.evtchn_pending[cpu]) + hyp_block(); + while (1) { + hyp_shared_info.vcpu_info[cpu].evtchn_upcall_mask = 0x00; + barrier(); + if (!hyp_shared_info.vcpu_info[cpu].evtchn_upcall_pending && + !hyp_shared_info.evtchn_pending[cpu]) + /* Didn't miss any event, can return to threads. */ + break; + hyp_shared_info.vcpu_info[cpu].evtchn_upcall_mask = 0xff; + hyp_c_callback(NULL,NULL); + } +} -- cgit v1.2.1