mmu: fix a lower half strcpy and add ismapped()

This commit is contained in:
Matheus
2022-09-19 18:33:52 -03:00
parent 6d9672158f
commit 16753bf16d
2 changed files with 11 additions and 2 deletions
+1
View File
@@ -24,6 +24,7 @@ typedef uint64_t* arch_mmu_tableptr;
int arch_mmu_map(arch_mmu_tableptr, void*, void*, size_t);
bool arch_mmu_isaccessed(arch_mmu_tableptr, void*);
void* arch_mmu_getphysicaladdr(arch_mmu_tableptr, void*);
bool arch_mmu_ismapped(arch_mmu_tableptr, void*);
void arch_mmu_unmap(arch_mmu_tableptr, void*);
void arch_mmu_init();
void arch_mmu_apinit();
+10 -2
View File
@@ -133,6 +133,14 @@ static uint64_t getmapping(arch_mmu_tableptr context, void* vaddr){
}
bool arch_mmu_ismapped(arch_mmu_tableptr context, void* vaddr){
uint64_t mapping = getmapping(context, vaddr);
return mapping != 0;
}
void* arch_mmu_getphysicaladdr(arch_mmu_tableptr context, void* addr){
uint64_t paddr = getmapping(context, addr);
paddr &= ~((uint64_t)0xFFF);
@@ -189,10 +197,10 @@ arch_mmu_tableptr arch_mmu_newcontext(){
if(!newcontext)
return NULL;
memcpy((void*)newcontext + (size_t)limine_hhdm_offset, context, PAGE_SIZE);
memcpy((void*)newcontext + (size_t)limine_hhdm_offset, (void*)context + (uintptr_t)limine_hhdm_offset, PAGE_SIZE);
memset((void*)newcontext + (size_t)limine_hhdm_offset, 0, PAGE_SIZE / 2);
return newcontext;
}