fix: bzero page tables before use it, alloc return the right index
This commit is contained in:
@ -14,13 +14,13 @@ static uint32_t *find_next_block(size_t nb_pages)
|
||||
uint32_t count = 0;
|
||||
for (uint32_t *pte = PTE2VA(1023, KERNEL_PT_START);
|
||||
pte < PTE2VA(1023, KERNEL_PT_END); pte++) {
|
||||
if (!*pte) {
|
||||
if (*pte) {
|
||||
count = 0;
|
||||
continue;
|
||||
}
|
||||
count++;
|
||||
if (count == nb_pages)
|
||||
return pte - count;
|
||||
return pte - (count - 1);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -124,6 +124,7 @@ void init_memory()
|
||||
if (!frame)
|
||||
kpanic("Couldn't initialize kernel PTs\n");
|
||||
PD[i] = frame | INIT_FLAGS;
|
||||
bzero(PTE2VA(1023, i), PAGE_SIZE);
|
||||
}
|
||||
// kalash kalash kalash sur la mélodie chez nous pas de félonie ça vient
|
||||
// de Sevran les R
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user