Mercurial > hg > Members > menikon > CbC_xv6
changeset 222:7a4d299a35be
paging_init
author | tobaru |
---|---|
date | Fri, 24 Jan 2020 18:10:26 +0900 |
parents | 098942ff5f44 |
children | 90b65036d9a2 |
files | src/impl/vm_impl.cbc src/impl/vm_impl.h src/impl/vm_impl_private.cbc src/interface/vm.h |
diffstat | 4 files changed, 28 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/impl/vm_impl.cbc Fri Jan 24 17:44:25 2020 +0900 +++ b/src/impl/vm_impl.cbc Fri Jan 24 18:10:26 2020 +0900 @@ -31,6 +31,7 @@ vm_impl->copyuvm_check_null = C_copyuvm_check_nullvm_impl; vm_impl->copyuvm_loop = C_copyuvm_loopvm_impl; vm_impl->uva2ka_check_pe_types = C_uva2ka_check_pe_types; + vm_impl->paging_intvm_impl = C_paging_intvmvm_impl; vm->init_vmm = C_init_vmmvm_impl; vm->kpt_freerange = C_kpt_freerangevm_impl; vm->kpt_alloc = C_kpt_allocvm_impl; @@ -42,7 +43,7 @@ vm->copyuvm = C_copyuvmvm_impl; vm->uva2ka = C_uva2kavm_impl; vm->copyout = C_copyoutvm_impl; - vm->pagind_int = C_pagind_intvm_impl; + vm->paging_int = C_paging_intvm_impl; return vm; } @@ -130,12 +131,12 @@ } __code copyoutvm_impl(struct vm_impl* vm, pde_t* pgdir, uint va, void* pp, uint len, __code next(...)) { - + goto next(...); } -__code pagind_intvm_impl(struct vm_impl* vm, uint phy_low, uint phy_hi, __code next(...)) { +__code paging_intvm_impl(struct vm_impl* vm, uint phy_low, uint phy_hi, __code next(...)) { - goto next(...); + goto paging_intvmvm_impl(vm, phy_low, phy_hi, next(...)); }
--- a/src/impl/vm_impl.h Fri Jan 24 17:44:25 2020 +0900 +++ b/src/impl/vm_impl.h Fri Jan 24 18:10:26 2020 +0900 @@ -17,6 +17,8 @@ char* uva; pde_t* d; uint ap; + uint phy_low; + uint phy_hi; __code kpt_alloc_check_impl(Type* vm_impl, __code next(...)); __code loaduvm_ptesize_check(Type* vm_impl, __code next(int ret, ...)); @@ -27,6 +29,7 @@ __code copyuvm_loop(Type* vm_impl,pde_t* pgdir, uint sz, pde_t* d, pte_t* pte, uint pa, uint i, uint ap, char* mem, __code next(int ret, ...)); __code clearpteu_check_ptevm_impl(Type* vm_impl, pde_t* pgdir, char* uva, __code next(...)); __code uva2ka_check_pe_types(Type* vm_impl, pde_t* pgdir, char* uva, __code next(...)); + __code paging_intvm_impl(Type* vm_impl, uint phy_low, uint phy_hi, __code next(...)); __code next(...); } vm_impl;
--- a/src/impl/vm_impl_private.cbc Fri Jan 24 17:44:25 2020 +0900 +++ b/src/impl/vm_impl_private.cbc Fri Jan 24 18:10:26 2020 +0900 @@ -1,5 +1,6 @@ #include "../../context.h" #include "mmu.h" +#include "defs.h" #include "memlayout.h" #interface "vm_impl.h" @@ -311,3 +312,21 @@ goto next(ret, ...); } +// flush all TLB +static void flush_tlb (void) +{ + uint val = 0; + asm("MCR p15, 0, %[r], c8, c7, 0" : :[r]"r" (val):); + + // invalid entire data and instruction cache + asm ("MCR p15,0,%[r],c7,c10,0": :[r]"r" (val):); + asm ("MCR p15,0,%[r],c7,c11,0": :[r]"r" (val):); +} + +__code paging_intvmvm_impl(struct vm_impl* vm_impl, uint phy_low, uint phy_hi, __code next(...)) { + mappages (P2V(&_kernel_pgtbl), P2V(phy_low), phy_hi - phy_low, phy_low, AP_KU); + flush_tlb (); + + goto next(...)); +} +
--- a/src/interface/vm.h Fri Jan 24 17:44:25 2020 +0900 +++ b/src/interface/vm.h Fri Jan 24 18:10:26 2020 +0900 @@ -28,6 +28,6 @@ __code copyuvm(Impl* vm, pde_t* pgdir, uint sz, __code next(...)); __code uva2ka(Impl* vm, pde_t* pgdir, char* uva, __code next(...)); __code copyout(Impl* vm, pde_t* pgdir, uint va, void* pp, uint len, __code next(...)); - __code pagind_int(Impl* vm, uint phy_low, uint phy_hi, __code next(...)); + __code paging_int(Impl* vm, uint phy_low, uint phy_hi, __code next(...)); __code next(...); } vm;