Mercurial > hg > Members > menikon > CbC_xv6
changeset 208:a0620ca23f19
be functional loaduvm
author | tobaru |
---|---|
date | Thu, 23 Jan 2020 17:52:35 +0900 |
parents | 8a55878f6a25 |
children | 02bb0f8be908 |
files | src/impl/vm_impl_private.cbc |
diffstat | 1 files changed, 35 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/impl/vm_impl_private.cbc Thu Jan 23 17:32:48 2020 +0900 +++ b/src/impl/vm_impl_private.cbc Thu Jan 23 17:52:35 2020 +0900 @@ -8,8 +8,9 @@ */ __code loaduvm_ptesize_checkvm_impl(struct vm_impl* vm_impl, __code next(...)) { + char* addr = vm_impl->addr; - if ((uint) vm_impl->addr %PTE_SZ != 0) { + if ((uint) addr %PTE_SZ != 0) { // goto panic } @@ -17,12 +18,17 @@ } __code loaduvm_loopvm_impl(struct vm_impl* vm_impl, __code next(...)) { + uint i = vm_impl->i; + uint sz = vm_impl->sz; - if (vm_impl->i < vm_impl->sz) { + if (i < sz) { goto loaduvm_check_pgdir(vm_impl, next(...)); } + goto loaduvm_exit(vm_impl, next(...)); } + + static pte_t* walkpgdir (pde_t *pgdir, const void *va, int alloc) { pde_t *pde; @@ -53,26 +59,46 @@ __code loaduvm_check_pgdir(struct vm_impl* vm_impl, __code next(...)) { - if ((vm_impl->pte = walkpgdir(vm_impl->pgdir, vm_impl->addr + vm_impl->i, 0)) == 0) { + pte_t* pte = vm_impl->pte; + pde_t* pgdir = vm_impl->pgdir; + uint i = vm_impl->i; + char* addr = vm_impl->addr; + uint pa = vm_impl->pa; + + if ((pte = walkpgdir(pgdir, addr + i, 0)) == 0) { // goto panic } - vm_impl->pa = PTE_ADDR(*vm_impl->pte); - + pa = PTE_ADDR(*pte); + + vm_impl->pte = pte; + vm_impl->pgdir = pgdir; + vm_impl->addr = addr; + vm_impl->pa = pa; + goto loaduvm_check_PTE_SZ(vm_impl, next(...)); } __code loaduvm_check_PTE_SZ(struct vm_impl* vm_impl, __code next(...)) { - if (vm_impl->sz - vm_impl->i < PTE_SZ) { - vm_impl->n = vm_impl->sz - vm_impl->i; + uint sz = vm_impl->sz; + uint i = vm_impl->i; + uint n = vm_impl->n; + struct inode* ip = vm_impl->ip; + uint pa = vm_impl->pa; + uint offset = vm_impl->offset; + + if (sz - i < PTE_SZ) { + n = sz - i; } else { - vm_impl->n = PTE_SZ; + n = PTE_SZ; } - if (readi(vm_impl->ip, p2v(vm_impl->pa), vm_impl->offset + vm_impl->i, vm_impl->n) != vm_impl->n) { + if (readi(ip, p2v(pa), offset + i, n) != n) { // panic // return -1; } + vm_impl->n = n; + goto loaduvm_exit(vm_impl, next(...)); }