Mercurial > hg > Members > menikon > CbC_xv6
changeset 214:2ecf1e09e981
allocuvm_loop and return
author | tobaru |
---|---|
date | Fri, 24 Jan 2020 14:45:38 +0900 |
parents | f4effd36aefc |
children | 291d4e9304a1 |
files | src/impl/vm_impl.cbc src/impl/vm_impl.h src/impl/vm_impl_private.cbc |
diffstat | 3 files changed, 34 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/impl/vm_impl.cbc Thu Jan 23 21:24:30 2020 +0900 +++ b/src/impl/vm_impl.cbc Fri Jan 24 14:45:38 2020 +0900 @@ -26,6 +26,8 @@ vm_impl->sz = 0; vm_impl->loaduvm_ptesize_check = C_loaduvm_ptesize_checkvm_impl; vm_impl->loaduvm_loop = C_loaduvm_loopvm_impl; + vm_impl->allocuvm_check_newsz = C_allocuvm_check_newszvm_impl; + vm_impl->allocuvm_loop = C_allocuvm_loopvm_impl; vm->init_vmm = C_init_vmmvm_impl; vm->kpt_freerange = C_kpt_freerangevm_impl; vm->kpt_alloc = C_kpt_allocvm_impl; @@ -84,7 +86,7 @@ } typedef struct proc proc; -__code switchuvmvm_impl(struct vm_impl* vm ,struct proc* p, __code next(...)) { //:skip +__code switchuvmvm_impl(struct vm_impl* vm , struct proc* p, __code next(...)) { //:skip goto next(...); } @@ -106,7 +108,7 @@ __code allocuvmvm_impl(struct vm_impl* vm, pde_t* pgdir, uint oldsz, uint newsz, __code next(...)) { - goto next(...); + goto allocuvm_check_newszvm_impl(vm, pgdir, oldsz, newsz, next(...)); } __code clearpteuvm_impl(struct vm_impl* vm, pde_t* pgdir, char* uva, __code next(...)) {
--- a/src/impl/vm_impl.h Thu Jan 23 21:24:30 2020 +0900 +++ b/src/impl/vm_impl.h Fri Jan 24 14:45:38 2020 +0900 @@ -9,10 +9,16 @@ uint offset; uint pa; uint n; + uint oldsz; + uint newsz; + uint a; + int ret; __code kpt_alloc_check_impl(Type* vm_impl, __code next(...)); __code loaduvm_ptesize_check(Type* vm_impl, __code next(...)); __code loaduvm_loop(Type* vm_impl, uint i, pte_t* pte, uint sz, __code next(...)); + __code allocuvm_check_newsz(Type* vm_impl, pde_t* pgdir, uint oldsz, uint newsz, __code next(...)); + __code allocuvm_loop(Type* vm_impl, pde_t* pgdir, uint oldsz, uint newsz, uint a, __code next(...)); __code next(...);
--- a/src/impl/vm_impl_private.cbc Thu Jan 23 21:24:30 2020 +0900 +++ b/src/impl/vm_impl_private.cbc Fri Jan 24 14:45:38 2020 +0900 @@ -131,3 +131,27 @@ memset(r, 0, PT_SZ); goto next((char*)r); } + +__code allocuvm_check_newszvm_impl(struct vm_impl* vm_impl, pde_t* pgdir, uint oldsz, uint newsz, __code next(int ret, ...)){ + if (newsz >= UADDR_SZ) { + goto next(0, ...); + } + + if (newsz < oldsz) { + ret = newsz; + goto next(ret); + } + + uint a = align_up(oldsz, PTE_SZ); + + goto allocuvm_loopvm_impl(vm_impl, pgdir, oldsz, newsz, a, next(...)); +} + +__code allocuvm_loopvm_impl(struct vm_impl* vm_impl, pde_t* pgdir, uint oldsz, uint newsz, uint a, __code next(...)) { + + if (a < newsz) { + goto allocuvm_loopvm_impl(vm_impl, pgdir, oldsz, newsz, a + PTE_SZ, next(...)); + } + + goto next(newsz); +}