Annotation of Gnu-Mach/i386/xen/xen.c, revision 1.1

1.1     ! root        1: /*
        !             2:  *  Copyright (C) 2006-2009 Free Software Foundation
        !             3:  *
        !             4:  * This program is free software ; you can redistribute it and/or modify
        !             5:  * it under the terms of the GNU General Public License as published by
        !             6:  * the Free Software Foundation ; either version 2 of the License, or
        !             7:  * (at your option) any later version.
        !             8:  *
        !             9:  * This program is distributed in the hope that it will be useful,
        !            10:  * but WITHOUT ANY WARRANTY ; without even the implied warranty of
        !            11:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
        !            12:  * GNU General Public License for more details.
        !            13:  *
        !            14:  * You should have received a copy of the GNU General Public License
        !            15:  * along with the program ; if not, write to the Free Software
        !            16:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
        !            17:  */
        !            18: 
        !            19: #include <kern/printf.h>
        !            20: #include <kern/debug.h>
        !            21: #include <kern/mach_clock.h>
        !            22: 
        !            23: #include <mach/machine/eflags.h>
        !            24: #include <machine/thread.h>
        !            25: #include <machine/ipl.h>
        !            26: 
        !            27: #include <machine/model_dep.h>
        !            28: 
        !            29: unsigned long cr3;
        !            30: 
        !            31: struct failsafe_callback_regs {
        !            32:        unsigned int ds;
        !            33:        unsigned int es;
        !            34:        unsigned int fs;
        !            35:        unsigned int gs;
        !            36:        unsigned int ip;
        !            37:        unsigned int cs_and_mask;
        !            38:        unsigned int flags;
        !            39: };
        !            40: 
        !            41: void hyp_failsafe_c_callback(struct failsafe_callback_regs *regs) {
        !            42:        printf("Fail-Safe callback!\n");
        !            43:        printf("IP: %08X CS: %4X DS: %4X ES: %4X FS: %4X GS: %4X FLAGS %08X MASK %04X\n", regs->ip, regs->cs_and_mask & 0xffff, regs->ds, regs->es, regs->fs, regs->gs, regs->flags, regs->cs_and_mask >> 16);
        !            44:        panic("failsafe");
        !            45: }
        !            46: 
        !            47: extern void return_to_iret;
        !            48: 
        !            49: void hypclock_machine_intr(int old_ipl, void *ret_addr, struct i386_interrupt_state *regs, unsigned64_t delta) {
        !            50:        if (ret_addr == &return_to_iret) {
        !            51:                clock_interrupt(delta/1000,             /* usec per tick */
        !            52:                        (regs->efl & EFL_VM) ||         /* user mode */ 
        !            53:                        ((regs->cs & 0x02) != 0),       /* user mode */ 
        !            54:                        old_ipl == SPL0);               /* base priority */
        !            55:        } else
        !            56:                clock_interrupt(delta/1000, FALSE, FALSE);
        !            57: }
        !            58: 
        !            59: void hyp_p2m_init(void) {
        !            60:        unsigned long nb_pfns = atop(phys_last_addr);
        !            61: #ifdef MACH_PSEUDO_PHYS
        !            62: #define P2M_PAGE_ENTRIES (PAGE_SIZE / sizeof(unsigned long))
        !            63:        unsigned long *l3 = (unsigned long *)phystokv(pmap_grab_page()), *l2 = NULL;
        !            64:        unsigned long i;
        !            65: 
        !            66:        for (i = 0; i < (nb_pfns + P2M_PAGE_ENTRIES) / P2M_PAGE_ENTRIES; i++) {
        !            67:                if (!(i % P2M_PAGE_ENTRIES)) {
        !            68:                        l2 = (unsigned long *) phystokv(pmap_grab_page());
        !            69:                        l3[i / P2M_PAGE_ENTRIES] = kv_to_mfn(l2);
        !            70:                }
        !            71:                l2[i % P2M_PAGE_ENTRIES] = kv_to_mfn(&mfn_list[i * P2M_PAGE_ENTRIES]);
        !            72:        }
        !            73: 
        !            74:        hyp_shared_info.arch.pfn_to_mfn_frame_list_list = kv_to_mfn(l3);
        !            75: #endif
        !            76:        hyp_shared_info.arch.max_pfn = nb_pfns;
        !            77: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.