vmm: vmm_getphysical()

This commit is contained in:
Matheus
2024-04-14 19:11:15 -03:00
parent c16e9517c4
commit 06629f3088
2 changed files with 17 additions and 0 deletions
+1
View File
@@ -99,6 +99,7 @@ void vmm_unmap(void *addr, size_t size, int flags);
bool vmm_pagefault(void *addr, bool user, int actions);
vmmcontext_t *vmm_newcontext();
void vmm_switchcontext(vmmcontext_t *ctx);
void *vmm_getphysical(void *addr);
void vmm_apinit();
void vmm_init();
+16
View File
@@ -373,6 +373,22 @@ bool vmm_pagefault(void *addr, bool user, int actions) {
return status;
}
void *vmm_getphysical(void *addr) {
addr = (void *)ROUND_DOWN((uintptr_t)addr, PAGE_SIZE);
vmmspace_t *space = getspace(addr);
if (space == NULL)
return NULL;
MUTEX_ACQUIRE(&space->lock, false);
void *physical = arch_mmu_getphysical(_cpu()->vmmctx->pagetable, addr);
MUTEX_RELEASE(&space->lock);
return physical;
}
void *vmm_map(void *addr, volatile size_t size, int flags, mmuflags_t mmuflags, void *private) {
if (addr == NULL)
addr = KERNELSPACE_START;