mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +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);
|
bool vmm_pagefault(void *addr, bool user, int actions);
|
||||||
vmmcontext_t *vmm_newcontext();
|
vmmcontext_t *vmm_newcontext();
|
||||||
void vmm_switchcontext(vmmcontext_t *ctx);
|
void vmm_switchcontext(vmmcontext_t *ctx);
|
||||||
|
void *vmm_getphysical(void *addr);
|
||||||
void vmm_apinit();
|
void vmm_apinit();
|
||||||
void vmm_init();
|
void vmm_init();
|
||||||
|
|
||||||
|
|||||||
@@ -373,6 +373,22 @@ bool vmm_pagefault(void *addr, bool user, int actions) {
|
|||||||
return status;
|
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) {
|
void *vmm_map(void *addr, volatile size_t size, int flags, mmuflags_t mmuflags, void *private) {
|
||||||
if (addr == NULL)
|
if (addr == NULL)
|
||||||
addr = KERNELSPACE_START;
|
addr = KERNELSPACE_START;
|
||||||
|
|||||||
Reference in New Issue
Block a user