fix: find_next_block
This commit is contained in:
parent
5fc90ea240
commit
886f912f36
@ -6,23 +6,22 @@
|
||||
#include "memory.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define PT_SIZE 1024
|
||||
#define PT_SIZE 0x300
|
||||
#define MAX_TLB_ENTRIES 32
|
||||
|
||||
extern uint32_t page_table_entries[PT_SIZE] __attribute__((aligned(4096)));
|
||||
|
||||
static int16_t find_next_block(size_t nb_pages)
|
||||
{
|
||||
for (size_t i = 0; i < PT_SIZE; i++) {
|
||||
if (page_table_entries[i] >> 12 == i) {
|
||||
size_t j = i + 1;
|
||||
for (; j - i < nb_pages && j < PT_SIZE; j++)
|
||||
if (page_table_entries[j] >> 12 != j)
|
||||
break;
|
||||
if (j - i == nb_pages)
|
||||
for (uint16_t i = 0; i < PT_SIZE; i++) {
|
||||
uint16_t j;
|
||||
for (j = 0;
|
||||
page_table_entries[i + j] >> 12 == i + j && j < nb_pages;
|
||||
j++)
|
||||
;
|
||||
if (j == nb_pages)
|
||||
return i;
|
||||
i = j - 1;
|
||||
}
|
||||
i += j;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user