elf loading and userland

This commit is contained in:
Matheus
2022-08-14 20:19:38 -03:00
parent 33a516a611
commit 261d7d3743
13 changed files with 243 additions and 31 deletions
+20 -4
View File
@@ -114,11 +114,13 @@ static uint64_t getmapping(arch_mmu_tableptr context, void* vaddr){
size_t pd = (addr >> 30) & 0b111111111;
size_t pt = (addr >> 21) & 0b111111111;
size_t page = (addr >> 12) & 0b111111111;
uint64_t* table = next(context, pdpt);
if(!table) return 0;
table = next(table, pd);
if(!context[pdpt]) return 0;
uint64_t* table = next(context, pd);
if(!table) return 0;
table = next(table, pt);
@@ -142,6 +144,20 @@ bool arch_mmu_isaccessed(arch_mmu_tableptr context, void* addr){
return (getmapping(context, addr) & ARCH_MMU_MAP_ACCESSED) != 0;
}
void arch_mmu_changeflags(arch_mmu_tableptr context, void* addr, size_t flags, size_t count){
for(size_t i = 0; i < count; ++i){
uint64_t mapping = getmapping(context, addr);
if(!mapping)
continue;
mapping &= ~(0xFFF); // get addr
mapping &= ~ARCH_MMU_MAP_NOEXEC;
mapping |= flags;
setpage(context, addr, mapping);
addr += PAGE_SIZE;
}
}
int arch_mmu_map(arch_mmu_tableptr context, void* paddr, void* vaddr, size_t flags){
uint64_t entry;
changeentry(&entry, paddr, flags);