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