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

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: 
1.1.1.2   root       49: void hypclock_machine_intr(int old_ipl, void *ret_addr, struct i386_interrupt_state *regs, uint64_t delta) {
1.1       root       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 */ 
1.1.1.2   root       54:                        old_ipl == SPL0,                /* base priority */
                     55:                        regs->eip);                     /* interrupted eip */
1.1       root       56:        } else
1.1.1.2   root       57:                clock_interrupt(delta/1000, FALSE, FALSE, 0);
1.1       root       58: }
                     59: 
                     60: void hyp_p2m_init(void) {
1.1.1.3 ! root       61:        unsigned long nb_pfns = vm_page_table_size();
1.1       root       62: #ifdef MACH_PSEUDO_PHYS
                     63: #define P2M_PAGE_ENTRIES (PAGE_SIZE / sizeof(unsigned long))
                     64:        unsigned long *l3 = (unsigned long *)phystokv(pmap_grab_page()), *l2 = NULL;
                     65:        unsigned long i;
                     66: 
                     67:        for (i = 0; i < (nb_pfns + P2M_PAGE_ENTRIES) / P2M_PAGE_ENTRIES; i++) {
                     68:                if (!(i % P2M_PAGE_ENTRIES)) {
                     69:                        l2 = (unsigned long *) phystokv(pmap_grab_page());
                     70:                        l3[i / P2M_PAGE_ENTRIES] = kv_to_mfn(l2);
                     71:                }
                     72:                l2[i % P2M_PAGE_ENTRIES] = kv_to_mfn(&mfn_list[i * P2M_PAGE_ENTRIES]);
                     73:        }
                     74: 
                     75:        hyp_shared_info.arch.pfn_to_mfn_frame_list_list = kv_to_mfn(l3);
                     76: #endif
                     77:        hyp_shared_info.arch.max_pfn = nb_pfns;
                     78: }

unix.superglobalmegacorp.com

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