Debian Codegraph @

i386/xen/xen.c

raw symbols SCIP
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 #include <machine/model_dep.h>
27 #include <vm/vm_page.h>
28 #include <vm/pmap.h>
29
30 #include <xen/xen.h>
31
32 unsigned long cr3;
33
34 void hyp_failsafe_c_callback(struct failsafe_callback_regs *regs) {
35 printf("Fail-Safe callback!\n");
36 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);
37 panic("failsafe");
38 }
39
40 extern char return_to_iret[];
41
42 void hypclock_machine_intr(int old_ipl, void *ret_addr, struct i386_interrupt_state *regs, uint64_t delta) {
43 if (ret_addr == &return_to_iret) {
44 clock_interrupt(delta/1000, /* usec per tick */
45 (regs->efl & EFL_VM) || /* user mode */
46 ((regs->cs & 0x02) != 0), /* user mode */
47 old_ipl == SPL0, /* base priority */
48 regs->eip); /* interrupted eip */
49 } else
50 clock_interrupt(delta/1000, FALSE, FALSE, 0);
51 }
52
53 void hyp_p2m_init(void) {
54 unsigned long nb_pfns = vm_page_table_size();
55 #ifdef MACH_PSEUDO_PHYS
56 #define P2M_PAGE_ENTRIES (PAGE_SIZE / sizeof(unsigned long))
57 unsigned long *l3 = (unsigned long *)phystokv(pmap_grab_page()), *l2 = NULL;
58 unsigned long i;
59
60 for (i = 0; i < (nb_pfns + P2M_PAGE_ENTRIES) / P2M_PAGE_ENTRIES; i++) {
61 if (!(i % P2M_PAGE_ENTRIES)) {
62 l2 = (unsigned long *) phystokv(pmap_grab_page());
63 l3[i / P2M_PAGE_ENTRIES] = kv_to_mfn(l2);
64 }
65 l2[i % P2M_PAGE_ENTRIES] = kv_to_mfn(&mfn_list[i * P2M_PAGE_ENTRIES]);
66 }
67
68 hyp_shared_info.arch.pfn_to_mfn_frame_list_list = kv_to_mfn(l3);
69 #endif
70 hyp_shared_info.arch.max_pfn = nb_pfns;
71 }