Fix A1 allocator to map the correct pages

This commit is contained in:
Josh Holtrop 2023-06-10 11:06:41 -04:00
parent 63fbbc9051
commit dd07a08388

View File

@ -35,17 +35,17 @@ struct A1
ulong address = Hurl.A1_BASE + allocated; ulong address = Hurl.A1_BASE + allocated;
ulong mapped_limit = round_up_power_2(address, PAGE_SIZE); ulong current_limit = round_up_power_2(address, PAGE_SIZE);
allocated += size; allocated += size;
ulong desired_limit = round_up_power_2(Hurl.A1_BASE + allocated, PAGE_SIZE); ulong desired_limit = round_up_power_2(Hurl.A1_BASE + allocated, PAGE_SIZE);
while (desired_limit > mapped_limit) while (desired_limit > current_limit)
{ {
void * page = Hippo.allocate_page(); void * page = Hippo.allocate_page();
Hurl.map(Hurl.A1_BASE + mapped_limit, page, PT_WRITABLE); Hurl.map(current_limit, page, PT_WRITABLE);
mapped_limit += PAGE_SIZE; current_limit += PAGE_SIZE;
} }
return cast(void *)address; return cast(void *)address;