mem: fix edge cases in map_mmio_dev
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
16b2e9de0a
commit
5c7d398d71
1 changed files with 7 additions and 3 deletions
10
mem/page.c
10
mem/page.c
|
|
@ -111,10 +111,10 @@ static void map_hhdm_zones(pgd_t *pgd_table)
|
|||
}
|
||||
|
||||
hhdm_end = top_paddr;
|
||||
device_base = hhdm_end;
|
||||
device_base = ALIGN_UP(hhdm_end + hhdm_start, PAGE_SIZE);
|
||||
|
||||
for (paddr_t p = 0; p < top_paddr; p += 0x200000) {
|
||||
vaddr_t v =(vaddr_t) TO_VIRT(p);
|
||||
vaddr_t v = (vaddr_t)TO_VIRT(p);
|
||||
|
||||
pgd_t *pgd_entry = &pgd_table[pgd_index(v)];
|
||||
if (!(pgd_entry->pgd & PAGE_PRESENT)) {
|
||||
|
|
@ -137,16 +137,20 @@ static void map_hhdm_zones(pgd_t *pgd_table)
|
|||
|
||||
void *map_mmio_dev(paddr_t base, size_t len)
|
||||
{
|
||||
len = ALIGN_UP(len, PAGE_SIZE);
|
||||
vaddr_t addr = device_base;
|
||||
|
||||
u64 flags = PAGE_RW | PAGE_CACHE_DISABLE | PAGE_WRITE_THRU;
|
||||
|
||||
size_t offset = base & (PAGE_SIZE - 1);
|
||||
base -= offset;
|
||||
|
||||
page_map(kpgd, base, addr, len, flags, &kmap_tree);
|
||||
tlb_flush();
|
||||
|
||||
device_base += npow2(len);
|
||||
|
||||
return (void *)addr;
|
||||
return (void *)addr + offset;
|
||||
}
|
||||
|
||||
void page_init()
|
||||
|
|
|
|||
Loading…
Reference in a new issue