mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
vmm: vmm_tophyical()
This commit is contained in:
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user