ia64/xen-unstable

changeset 14199:bdebca505d8e

Create P2M map during Mini-OS boot (fixes 'xm dump-core').
Signed-off-by: Grzegorz Milos <gm281@cam.ac.uk>
author kfraser@localhost.localdomain
date Thu Mar 01 12:23:44 2007 +0000 (2007-03-01)
parents afed0aeff629
children 035d41b6c94c
files extras/mini-os/arch/ia64/mm.c extras/mini-os/arch/x86/mm.c extras/mini-os/include/mm.h extras/mini-os/mm.c
line diff
     1.1 --- a/extras/mini-os/arch/ia64/mm.c	Thu Mar 01 12:23:04 2007 +0000
     1.2 +++ b/extras/mini-os/arch/ia64/mm.c	Thu Mar 01 12:23:44 2007 +0000
     1.3 @@ -130,3 +130,7 @@ map_frames(unsigned long* frames, unsign
     1.4  	return (void*) __va(frames[0] << PAGE_SHIFT);
     1.5  }
     1.6  
     1.7 +void arch_init_p2m(unsigned long max_pfn)
     1.8 +{
     1.9 +    printk("Warn: p2m map not implemented.\n");
    1.10 +}
     2.1 --- a/extras/mini-os/arch/x86/mm.c	Thu Mar 01 12:23:04 2007 +0000
     2.2 +++ b/extras/mini-os/arch/x86/mm.c	Thu Mar 01 12:23:44 2007 +0000
     2.3 @@ -402,6 +402,49 @@ void *map_frames(unsigned long *f, unsig
     2.4      }
     2.5  }
     2.6  
     2.7 +
     2.8 +void arch_init_p2m(unsigned long max_pfn)
     2.9 +{
    2.10 +#define L1_P2M_SHIFT    10
    2.11 +#define L2_P2M_SHIFT    20    
    2.12 +#define L3_P2M_SHIFT    30    
    2.13 +#define L1_P2M_ENTRIES  (1 << L1_P2M_SHIFT)    
    2.14 +#define L2_P2M_ENTRIES  (1 << (L2_P2M_SHIFT - L1_P2M_SHIFT))    
    2.15 +#define L3_P2M_ENTRIES  (1 << (L3_P2M_SHIFT - L2_P2M_SHIFT))    
    2.16 +#define L1_P2M_MASK     (L1_P2M_ENTRIES - 1)    
    2.17 +#define L2_P2M_MASK     (L2_P2M_ENTRIES - 1)    
    2.18 +#define L3_P2M_MASK     (L3_P2M_ENTRIES - 1)    
    2.19 +    
    2.20 +    unsigned long *l1_list, *l2_list, *l3_list;
    2.21 +    unsigned long pfn;
    2.22 +    
    2.23 +    l3_list = (unsigned long *)alloc_page(); 
    2.24 +    for(pfn=0; pfn<max_pfn; pfn++)
    2.25 +    {
    2.26 +        if(!(pfn % (L1_P2M_ENTRIES * L2_P2M_ENTRIES)))
    2.27 +        {
    2.28 +            l2_list = (unsigned long*)alloc_page();
    2.29 +            if((pfn >> L3_P2M_SHIFT) > 0)
    2.30 +            {
    2.31 +                printk("Error: Too many pfns.\n");
    2.32 +                do_exit();
    2.33 +            }
    2.34 +            l3_list[(pfn >> L2_P2M_SHIFT)] = virt_to_mfn(l2_list);  
    2.35 +        }
    2.36 +        if(!(pfn % (L1_P2M_ENTRIES)))
    2.37 +        {
    2.38 +            l1_list = (unsigned long*)alloc_page();
    2.39 +            l2_list[(pfn >> L1_P2M_SHIFT) & L2_P2M_MASK] = 
    2.40 +                virt_to_mfn(l1_list); 
    2.41 +        }
    2.42 +
    2.43 +        l1_list[pfn & L1_P2M_MASK] = pfn_to_mfn(pfn); 
    2.44 +    }
    2.45 +    HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list = 
    2.46 +        virt_to_mfn(l3_list);
    2.47 +    HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
    2.48 +}
    2.49 +
    2.50  void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p)
    2.51  {
    2.52  
     3.1 --- a/extras/mini-os/include/mm.h	Thu Mar 01 12:23:04 2007 +0000
     3.2 +++ b/extras/mini-os/include/mm.h	Thu Mar 01 12:23:44 2007 +0000
     3.3 @@ -55,6 +55,7 @@ static __inline__ int get_order(unsigned
     3.4  
     3.5  void arch_init_demand_mapping_area(unsigned long max_pfn);
     3.6  void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p);
     3.7 +void arch_init_p2m(unsigned long max_pfn_p);
     3.8  
     3.9  void *map_frames(unsigned long *f, unsigned long n);
    3.10  
     4.1 --- a/extras/mini-os/mm.c	Thu Mar 01 12:23:04 2007 +0000
     4.2 +++ b/extras/mini-os/mm.c	Thu Mar 01 12:23:44 2007 +0000
     4.3 @@ -379,6 +379,8 @@ void init_mm(void)
     4.4      init_page_allocator(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn));
     4.5      printk("MM: done\n");
     4.6  
     4.7 +    arch_init_p2m(max_pfn);
     4.8 +    
     4.9      arch_init_demand_mapping_area(max_pfn);
    4.10  }
    4.11