Changeset e12ccc5 in mainline for kernel/arch/xen32/src/xen32.c


Ignore:
Timestamp:
2006-08-01T17:27:11Z (18 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0fbfa0d
Parents:
e386cbf
Message:

xen32: use writable page tables, cleanup mm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/xen32/src/xen32.c

    re386cbf re12ccc5  
    3737#include <arch/types.h>
    3838#include <typedefs.h>
     39#include <align.h>
    3940
    4041#include <arch/pm.h>
    4142
    4243#include <arch/drivers/xconsole.h>
     44#include <arch/mm/page.h>
    4345
    4446#include <arch/context.h>
     
    6163
    6264start_info_t start_info;
     65memzone_t meminfo;
     66
     67void arch_pre_main(void)
     68{
     69        xen_vm_assist(VMASST_CMD_ENABLE, VMASST_TYPE_WRITABLE_PAGETABLES);
     70       
     71        pte_t pte;
     72        memsetb((uintptr_t) &pte, sizeof(pte), 0);
     73       
     74        pte.present = 1;
     75        pte.writeable = 1;
     76        pte.frame_address = ADDR2PFN((uintptr_t) start_info.shared_info);
     77        xen_update_va_mapping(&shared_info, pte, UVMF_INVLPG);
     78       
     79        /* Create identity mapping */
     80       
     81        meminfo.start = ADDR2PFN(ALIGN_UP(KA2PA(start_info.ptl0), PAGE_SIZE)) + start_info.pt_frames;
     82        meminfo.size = start_info.frames - meminfo.start;
     83        meminfo.reserved = 0;
     84       
     85        uintptr_t pa;
     86        index_t last_ptl0 = 0;
     87        for (pa = PFN2ADDR(meminfo.start); pa < PFN2ADDR(meminfo.start + meminfo.size); pa += FRAME_SIZE) {
     88                uintptr_t va = PA2KA(pa);
     89               
     90                if ((PTL0_INDEX(va) != last_ptl0) && (GET_PTL1_FLAGS(start_info.ptl0, PTL0_INDEX(va)) & PAGE_NOT_PRESENT)) {
     91                        /* New page directory entry needed */
     92                        uintptr_t tpa = PFN2ADDR(meminfo.start + meminfo.reserved);
     93                        uintptr_t tva = PA2KA(tpa);
     94                       
     95                        memsetb(tva, PAGE_SIZE, 0);
     96                       
     97                        pte_t *tptl3 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(start_info.ptl0, PTL0_INDEX(tva)));
     98                        SET_FRAME_FLAGS(tptl3, PTL3_INDEX(tva), PAGE_PRESENT);
     99                        SET_PTL1_ADDRESS(start_info.ptl0, PTL0_INDEX(va), tpa);
     100                       
     101                        last_ptl0 = PTL0_INDEX(va);
     102                        meminfo.reserved++;
     103                }
     104               
     105                pte_t *ptl3 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(start_info.ptl0, PTL0_INDEX(va)));
     106               
     107                SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(va), pa);
     108                SET_FRAME_FLAGS(ptl3, PTL3_INDEX(va), PAGE_PRESENT | PAGE_WRITE);
     109        }
     110}
    63111
    64112void arch_pre_mm_init(void)
Note: See TracChangeset for help on using the changeset viewer.