Mercurial > hg > Members > menikon > CbC_xv6
view src/impl/vm_impl.cbc @ 223:90b65036d9a2
paging_init
author | tobaru |
---|---|
date | Fri, 24 Jan 2020 18:33:52 +0900 |
parents | 7a4d299a35be |
children | 37900976db8e |
line wrap: on
line source
#include "../../context.h" #interface "vm.h" // ---- // typedef struct vm_impl<Impl, Isa> impl vm{ // union Data* vm_impl; // uint i; // pte_t* pte; // uint sz; // // __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 next(...); // // // } vm_impl; // ---- vm* createvm_impl(struct Context* cbc_context) { struct vm* vm = new vm(); struct vm_impl* vm_impl = new vm_impl(); vm->vm = (union Data*)vm_impl; vm_impl->vm_impl = NULL; vm_impl->i = 0; vm_impl->pte = NULL; 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_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_impl->copyout_loopvm_impl = C_copyout_loopvm_impl; vm->init_vmm = C_init_vmmvm_impl; vm->kpt_freerange = C_kpt_freerangevm_impl; vm->kpt_alloc = C_kpt_allocvm_impl; vm->switchuvm = C_switchuvmvm_impl; vm->init_inituvm = C_init_inituvmvm_impl; vm->loaduvm = C_loaduvmvm_impl; vm->allocuvm = C_allocuvmvm_impl; vm->clearpteu = C_clearpteuvm_impl; vm->copyuvm = C_copyuvmvm_impl; vm->uva2ka = C_uva2kavm_impl; vm->copyout = C_copyoutvm_impl; vm->paging_int = C_paging_intvm_impl; return vm; } extern struct { struct spinlock lock; struct run *freelist; } kpt_mem; __code init_vmmvm_impl(struct vm_impl* vm, __code next(...)) { initlock(&kpt_mem.lock, "vm"); kpt_mem.freelist = NULL; goto next(...); } extern struct run { struct run *next; }; static void _kpt_free (char *v) { struct run *r; r = (struct run*) v; r->next = kpt_mem.freelist; kpt_mem.freelist = r; } __code kpt_freerangevm_impl(struct vm_impl* vm, uint low, uint hi, __code next(...)) { if (low < hi) { _kpt_free((char*)low); goto kpt_freerangevm_impl(vm, low + PT_SZ, hi, next(...)); } goto next(...); } __code kpt_allocvm_impl(struct vm_impl* vm, __code next(...)) { acquire(&kpt_mem.lock); goto kpt_alloc_check_impl(vm_impl, next(...)); goto next(...); } typedef struct proc proc; __code switchuvmvm_impl(struct vm_impl* vm , struct proc* p, __code next(...)) { //:skip goto next(...); } __code init_inituvmvm_impl(struct vm_impl* vm, pde_t* pgdir, char* init, uint sz, __code next(...)) { //:skip goto next(...); } __code loaduvmvm_impl(struct vm_impl* vm, pde_t* pgdir, char* addr, struct inode* ip, uint offset, uint sz, __code next(...)) { vm->pgdir = pgdir; vm->addr = addr; vm->ip = ip; vm->offset = offset; vm->sz = sz; goto loaduvm_ptesize_checkvm_impl(vm, next(...)); } __code allocuvmvm_impl(struct vm_impl* vm, pde_t* pgdir, uint oldsz, uint newsz, __code 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(...)) { goto clearpteu_check_ptevm_impl(vm, pgdir, uva, next(...)); } __code copyuvmvm_impl(struct vm_impl* vm, pde_t* pgdir, uint sz, __code next(...)) { goto copyuvm_check_nullvm_impl(vm, pgdir, sz, __code next(...)); } __code uva2kavm_impl(struct vm_impl* vm, pde_t* pgdir, char* uva, __code next(...)) { goto uva2ka_check_pe_types(vm, pgdir, uva, next(...)); } __code copyoutvm_impl(struct vm_impl* vm, pde_t* pgdir, uint va, void* pp, uint len, __code next(...)) { vm->buf = (char*) pp; goto copyout_loopvm_impl(vm, pgdir, va, pp, len, next(...)); } __code paging_intvm_impl(struct vm_impl* vm, uint phy_low, uint phy_hi, __code next(...)) { goto paging_intvmvm_impl(vm, phy_low, phy_hi, next(...)); }