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 | |
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>
-rw-r--r-- | extras/mini-os/arch/ia64/mm.c | 4 | ||||
-rw-r--r-- | extras/mini-os/arch/x86/mm.c | 43 | ||||
-rw-r--r-- | extras/mini-os/include/mm.h | 1 | ||||
-rw-r--r-- | extras/mini-os/mm.c | 2 |
4 files changed, 50 insertions, 0 deletions
diff --git a/extras/mini-os/arch/ia64/mm.c b/extras/mini-os/arch/ia64/mm.c index ad5acccc7e..dd1fb9dc78 100644 --- a/extras/mini-os/arch/ia64/mm.c +++ b/extras/mini-os/arch/ia64/mm.c @@ -130,3 +130,7 @@ map_frames(unsigned long* frames, unsigned long n) return (void*) __va(frames[0] << PAGE_SHIFT); } +void arch_init_p2m(unsigned long max_pfn) +{ + printk("Warn: p2m map not implemented.\n"); +} 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) { diff --git a/extras/mini-os/include/mm.h b/extras/mini-os/include/mm.h index cd53a4bf25..a9c0f2c181 100644 --- a/extras/mini-os/include/mm.h +++ b/extras/mini-os/include/mm.h @@ -55,6 +55,7 @@ static __inline__ int get_order(unsigned long size) void arch_init_demand_mapping_area(unsigned long max_pfn); void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p); +void arch_init_p2m(unsigned long max_pfn_p); void *map_frames(unsigned long *f, unsigned long n); diff --git a/extras/mini-os/mm.c b/extras/mini-os/mm.c index a24a521cf6..11e249d421 100644 --- a/extras/mini-os/mm.c +++ b/extras/mini-os/mm.c @@ -379,6 +379,8 @@ void init_mm(void) init_page_allocator(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn)); printk("MM: done\n"); + arch_init_p2m(max_pfn); + arch_init_demand_mapping_area(max_pfn); } |