Skip to content

Commit 1650569

Browse files
rizlikdanielinux
authored andcommitted
x86/paging: requires explicit physical address on paging requests
we can remove the memory pool reserved for that type of requests.
1 parent 559f07f commit 1650569

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

src/x86/paging.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,12 @@
3939
#define PAGE_ENTRIES_PER_PAGE (512)
4040

4141
#define PAGE_2MB_SHIFT 21
42-
#define MEM_SIZE 256 * 1024 * 1024
4342

4443
#if !defined(WOLFBOOT_LOADER)
4544
#define WOLFBOOT_PTP_NUM 128
4645
static uint8_t page_table_pages[WOLFBOOT_PTP_NUM * PAGE_TABLE_PAGE_SIZE]
4746
__attribute__((aligned(PAGE_TABLE_PAGE_SIZE)));
4847
static int page_table_page_used;
49-
/* TODO: reserve space in the linker? check amount of memory space? */
50-
uint8_t _mem[MEM_SIZE] __attribute__((aligned(PAGE_TABLE_PAGE_SIZE)));
51-
uint8_t *mem = &_mem[0];
5248
#endif /* !BUILD_LOADER_STAGE1 */
5349

5450
static inline void x86_paging_clear_pte(uint64_t *pte)
@@ -194,21 +190,17 @@ static void x86_paging_map_page(uint64_t vaddress, uint64_t paddress)
194190
/* already mapped */
195191
if (*pl1e != 0)
196192
return;
197-
if (paddress == 0) {
198-
paddress = (uint64_t)mem;
199-
mem += PAGE_TABLE_PAGE_SIZE;
200-
if (mem >= _mem + MEM_SIZE) {
201-
wolfBoot_printf("No more pages to satisfy virtual allocation");
202-
panic();
203-
}
204-
}
205193
x86_paging_setup_entry(pl1e, paddress);
206194
}
207195

208196
int x86_paging_map_memory(uint64_t va, uint64_t pa, uint32_t size)
209197
{
210198
uint64_t start, end, page;
211199

200+
if ((pa & PAGE_MASK) == 0) {
201+
wolfBoot_printf("can't satisfy mapping request at pa address 0\r\n");
202+
return -1;
203+
}
212204
end = va + size;
213205
start = va & PAGE_MASK;
214206
pa = pa & PAGE_MASK;

0 commit comments

Comments
 (0)