fix: bzero page tables before use it, alloc return the right index

This commit is contained in:
2025-11-28 19:24:40 +01:00
parent 2308ef509c
commit 1992d7f79b
3 changed files with 6 additions and 4 deletions

View File

@ -15,6 +15,7 @@ static int8_t alloc_pagetable(uint16_t pd_index)
if (!pt)
return -1;
PD[pd_index] = (uint32_t)pt | INIT_FLAGS;
bzero(PTE2VA(1023, pd_index), PAGE_SIZE);
return 0;
}
@ -26,13 +27,13 @@ static uint32_t *find_next_block(size_t nb_pages)
if (alloc_pagetable(i) < 0)
return NULL;
for (size_t j = 0; j < 1024; j++) {
if (!*GET_PTE(i, j)) {
if (*GET_PTE(i, j)) {
count = 0;
continue;
}
count++;
if (count == nb_pages) {
return GET_PTE(i, j) - count;
return GET_PTE(i, j) - (count - 1);
}
}
}