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