diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-03-01 12:23:44 +0000 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-03-01 12:23:44 +0000 |
commit | 5fca0f03a3feecdfb2618c62d6ef5ab547d83e5a (patch) | |
tree | 3eb2ec64d97753fe4ced3e84b3b0442c4abbe014 /extras/mini-os/arch/x86/mm.c | |
parent | 84e23d3ec9d8396dda23452caa84c21e9f0305f8 (diff) | |
download | xen-5fca0f03a3feecdfb2618c62d6ef5ab547d83e5a.tar.gz xen-5fca0f03a3feecdfb2618c62d6ef5ab547d83e5a.tar.bz2 xen-5fca0f03a3feecdfb2618c62d6ef5ab547d83e5a.zip |
Create P2M map during Mini-OS boot (fixes 'xm dump-core').
Signed-off-by: Grzegorz Milos <gm281@cam.ac.uk>
Diffstat (limited to 'extras/mini-os/arch/x86/mm.c')
-rw-r--r-- | extras/mini-os/arch/x86/mm.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/extras/mini-os/arch/x86/mm.c b/extras/mini-os/arch/x86/mm.c index d0fe762792..d1508f8263 100644 --- a/extras/mini-os/arch/x86/mm.c +++ b/extras/mini-os/arch/x86/mm.c @@ -402,6 +402,49 @@ void *map_frames(unsigned long *f, unsigned long n) } } + +void arch_init_p2m(unsigned long max_pfn) +{ +#define L1_P2M_SHIFT 10 +#define L2_P2M_SHIFT 20 +#define L3_P2M_SHIFT 30 +#define L1_P2M_ENTRIES (1 << L1_P2M_SHIFT) +#define L2_P2M_ENTRIES (1 << (L2_P2M_SHIFT - L1_P2M_SHIFT)) +#define L3_P2M_ENTRIES (1 << (L3_P2M_SHIFT - L2_P2M_SHIFT)) +#define L1_P2M_MASK (L1_P2M_ENTRIES - 1) +#define L2_P2M_MASK (L2_P2M_ENTRIES - 1) +#define L3_P2M_MASK (L3_P2M_ENTRIES - 1) + + unsigned long *l1_list, *l2_list, *l3_list; + unsigned long pfn; + + l3_list = (unsigned long *)alloc_page(); + for(pfn=0; pfn<max_pfn; pfn++) + { + if(!(pfn % (L1_P2M_ENTRIES * L2_P2M_ENTRIES))) + { + l2_list = (unsigned long*)alloc_page(); + if((pfn >> L3_P2M_SHIFT) > 0) + { + printk("Error: Too many pfns.\n"); + do_exit(); + } + l3_list[(pfn >> L2_P2M_SHIFT)] = virt_to_mfn(l2_list); + } + if(!(pfn % (L1_P2M_ENTRIES))) + { + l1_list = (unsigned long*)alloc_page(); + l2_list[(pfn >> L1_P2M_SHIFT) & L2_P2M_MASK] = + virt_to_mfn(l1_list); + } + + l1_list[pfn & L1_P2M_MASK] = pfn_to_mfn(pfn); + } + HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list = + virt_to_mfn(l3_list); + HYPERVISOR_shared_info->arch.max_pfn = max_pfn; +} + void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p) { |