debuggers.hg

diff xen/arch/x86/x86_32/mm.c @ 3632:fec8b1778268

bitkeeper revision 1.1159.212.60 (41febc4bKKSkh9u-Zes9v2CmBuLZxA)

More bootstrap fixes for x86/64. Next thing to do is sort out the IDT and
get traps.c working; then we can get rid of a bunch of dummy labels from
end of boot/x86_64.S. We're also going to need some kind of entry.S before
we can safely enable interrupts. Also bear in mind that not all of physical
RAM may be mapped (only first 1GB) and no m2p table is yet allocated or
mapped. Plenty to be done!
author kaf24@viper.(none)
date Mon Jan 31 23:16:27 2005 +0000 (2005-01-31)
parents 2c56c6b39a48
children d55d523078f7
line diff
     1.1 --- a/xen/arch/x86/x86_32/mm.c	Sat Jan 29 22:42:20 2005 +0000
     1.2 +++ b/xen/arch/x86/x86_32/mm.c	Mon Jan 31 23:16:27 2005 +0000
     1.3 @@ -29,30 +29,62 @@
     1.4  
     1.5  unsigned long m2p_start_mfn;
     1.6  
     1.7 -static inline void set_pte_phys(unsigned long vaddr,
     1.8 -                                l1_pgentry_t entry)
     1.9 +/* Map physical byte range (@p, @p+@s) at virt address @v in pagetable @pt. */
    1.10 +int map_pages(
    1.11 +    pagetable_t *pt,
    1.12 +    unsigned long v,
    1.13 +    unsigned long p,
    1.14 +    unsigned long s,
    1.15 +    unsigned long flags)
    1.16  {
    1.17 -    l2_pgentry_t *l2ent;
    1.18 -    l1_pgentry_t *l1ent;
    1.19 +    l2_pgentry_t *pl2e;
    1.20 +    l1_pgentry_t *pl1e;
    1.21 +    void         *newpg;
    1.22 +
    1.23 +    while ( s != 0 )
    1.24 +    {
    1.25 +        pl2e = &pt[l2_table_offset(v)];
    1.26 +
    1.27 +        if ( ((s|v|p) & ((1<<L2_PAGETABLE_SHIFT)-1)) == 0 )
    1.28 +        {
    1.29 +            /* Super-page mapping. */
    1.30 +            if ( (l2_pgentry_val(*pl2e) & _PAGE_PRESENT) )
    1.31 +                __flush_tlb_pge();
    1.32 +            *pl2e = mk_l2_pgentry(p|flags|_PAGE_PSE);
    1.33  
    1.34 -    l2ent = &idle_pg_table[l2_table_offset(vaddr)];
    1.35 -    l1ent = l2_pgentry_to_l1(*l2ent) + l1_table_offset(vaddr);
    1.36 -    *l1ent = entry;
    1.37 +            v += 1 << L2_PAGETABLE_SHIFT;
    1.38 +            p += 1 << L2_PAGETABLE_SHIFT;
    1.39 +            s -= 1 << L2_PAGETABLE_SHIFT;
    1.40 +        }
    1.41 +        else
    1.42 +        {
    1.43 +            /* Normal page mapping. */
    1.44 +            if ( !(l2_pgentry_val(*pl2e) & _PAGE_PRESENT) )
    1.45 +            {
    1.46 +                newpg = (void *)alloc_xenheap_page();
    1.47 +                clear_page(newpg);
    1.48 +                *pl2e = mk_l2_pgentry(__pa(newpg) | __PAGE_HYPERVISOR);
    1.49 +            }
    1.50 +            pl1e = l2_pgentry_to_l1(*pl2e) + l1_table_offset(v);
    1.51 +            if ( (l1_pgentry_val(*pl1e) & _PAGE_PRESENT) )
    1.52 +                __flush_tlb_one(v);
    1.53 +            *pl1e = mk_l1_pgentry(p|flags);
    1.54  
    1.55 -    /* It's enough to flush this one mapping. */
    1.56 -    __flush_tlb_one(vaddr);
    1.57 +            v += 1 << L1_PAGETABLE_SHIFT;
    1.58 +            p += 1 << L1_PAGETABLE_SHIFT;
    1.59 +            s -= 1 << L1_PAGETABLE_SHIFT;            
    1.60 +        }
    1.61 +    }
    1.62 +
    1.63 +    return 0;
    1.64  }
    1.65  
    1.66 -
    1.67 -void __set_fixmap(enum fixed_addresses idx, 
    1.68 -                  l1_pgentry_t entry)
    1.69 +void __set_fixmap(
    1.70 +    enum fixed_addresses idx, unsigned long p, unsigned long flags)
    1.71  {
    1.72 -    unsigned long address = fix_to_virt(idx);
    1.73 -
    1.74 -    if ( likely(idx < __end_of_fixed_addresses) )
    1.75 -        set_pte_phys(address, entry);
    1.76 -    else
    1.77 -        printk("Invalid __set_fixmap\n");
    1.78 +    if ( unlikely(idx >= __end_of_fixed_addresses) )
    1.79 +        BUG();
    1.80 +    map_pages(idle_pg_table, fix_to_virt(idx), p, PAGE_SIZE, flags);
    1.81  }
    1.82  
    1.83