vmm: vmm_tophyical()

This commit is contained in:
Matheus
2022-10-24 15:37:18 -03:00
parent 6db1cfe81d
commit 72504f3598
2 changed files with 23 additions and 4 deletions
+3 -3
View File
@@ -54,9 +54,9 @@ typedef struct {
int lock;
} vmm_context;
void vmm_init();
void vmm_destroy(vmm_context* ctx);
void vmm_init();
void vmm_destroy(vmm_context* ctx);
void* vmm_tophysical(void* addr);
bool vmm_dealwithrequest(void* addr, long error, bool user);
bool vmm_setused(void* addr, size_t pagec, size_t mmuflags);
bool vmm_unmap(void* addr, size_t pagec);
+20 -1
View File
@@ -701,7 +701,7 @@ bool vmm_dealwithrequest(void* addr, long error, bool user){
if(map->type == VMM_TYPE_FILE){ // TODO check for errors?
int err;
size_t offset = addr - map->start;
vfs_read(&err, map->data, addr, PAGE_SIZE, map->offset + offset);
vfs_read(&err, map->data, addr, PAGE_SIZE, map->offset + offset, NULL);
}
status = true;
@@ -714,6 +714,25 @@ bool vmm_dealwithrequest(void* addr, long error, bool user){
}
void* vmm_tophysical(void* addr){
int* lock;
vmm_mapping** start = NULL;
getcontextinfo(addr, &lock, &start);
spinlock_acquire(lock);
int pageoffset = (uintptr_t)addr % PAGE_SIZE;
void* virtpage = addr - pageoffset;
void* phypage = arch_mmu_getphysicaladdr(arch_getcls()->context->context, virtpage);
spinlock_release(lock);
return phypage + pageoffset;
}
void vmm_switchcontext(vmm_context* context){
if(arch_getcls()->thread)
arch_getcls()->thread->ctx = context;