mm: fix pagetable calculation in get_physaddr & map_page

This commit is contained in:
2025-05-31 17:52:36 +03:00
parent 681f509099
commit d5f41b1ef9
+2 -2
View File
@@ -78,7 +78,7 @@ void *get_physaddr(void *virtualaddr) {
unsigned long *pd = (unsigned long *)0xFFFFF000;
// Here you need to check whether the PD entry is present.
unsigned long *pt = ((unsigned long *)0xFFC00000) + (0x400 * pdindex);
uint32_t *pt = (uint32_t*)(0xFFC00000 + (pdindex << 12));
// Here you need to check whether the PT entry is present.
return (void *)((pt[ptindex] & ~0xFFF) + ((unsigned long)virtualaddr & 0xFFF));
@@ -109,7 +109,7 @@ void map_page(void *physaddr, void *virtualaddr, unsigned int flags) {
pd[pdindex] = (uint32_t)new_pt | (flags & 0x7); // Add User bit if needed
}
unsigned long *pt = ((unsigned long *)0xFFC00000) + (0x400 * pdindex);
uint32_t *pt = (uint32_t*)(0xFFC00000 + (pdindex << 12));
// Here you need to check whether the PT entry is present.
// When it is, then there is already a mapping present. What do you do now?