diff --git a/include/x86/hob.h b/include/x86/hob.h index 6725551a..bf7ef416 100644 --- a/include/x86/hob.h +++ b/include/x86/hob.h @@ -204,4 +204,7 @@ struct efi_hob_resource_descriptor * hob_find_fsp_reserved(struct efi_hob *hoblist); int hob_iterate_memory_map(struct efi_hob *hobList, hob_mem_map_cb cb, void* ctx); +#ifdef DEBUG +void hob_dump_memory_map(struct efi_hob *hobList); +#endif /* DEBUG */ #endif diff --git a/include/x86/paging.h b/include/x86/paging.h index e5103841..3d9cef45 100644 --- a/include/x86/paging.h +++ b/include/x86/paging.h @@ -33,6 +33,7 @@ int x86_paging_set_page_table(); #if !defined(BUILD_LOADER_STAGE1) int x86_paging_map_memory(uint64_t va, uint64_t pa, uint32_t size); +int x86_paging_dump_info(); #endif /* !BUILD_LOADER_STAGE1 */ #endif /* WOLFBOOT_64BIT */ diff --git a/src/boot_x86_fsp.c b/src/boot_x86_fsp.c index a5713b10..c362cfc3 100644 --- a/src/boot_x86_fsp.c +++ b/src/boot_x86_fsp.c @@ -528,6 +528,10 @@ void start(uint32_t stack_base, uint32_t stack_top, uint64_t timestamp, panic(); } +#ifdef DEBUG + hob_dump_memory_map(hobList); +#endif /* DEBUG */ + if (top_address > MEMORY_4GB) { panic(); } diff --git a/src/boot_x86_fsp_payload.c b/src/boot_x86_fsp_payload.c index 22b715ee..545b847f 100644 --- a/src/boot_x86_fsp_payload.c +++ b/src/boot_x86_fsp_payload.c @@ -111,10 +111,12 @@ void do_boot(const uint32_t *app) /* TODO: to remove */ mptable_setup(); + x86_paging_dump_info(); r = elf_load_image_mmu((uint8_t *)app, &e, mmu_cb); wolfBoot_printf("Elf loaded (ret %d), entry 0x%x_%x\r\n", 0, (uint32_t)(e >> 32), (uint32_t)(e)); + x86_paging_dump_info(); if (r != 0) panic(); diff --git a/src/x86/hob.c b/src/x86/hob.c index 96f33e7c..dd7c7f2f 100644 --- a/src/x86/hob.c +++ b/src/x86/hob.c @@ -176,4 +176,29 @@ int hob_iterate_memory_map(struct efi_hob *hobList, hob_mem_map_cb cb, return 0; } + +#ifdef DEBUG_HOB_LIST +typedef int (*hob_mem_map_cb)(uint64_t start, uint64_t length, uint32_t type, + void *ctx); +int hob_print_entry(uint64_t start, uint64_t length, uint32_t type, void *ctx) +{ + (void)ctx; + wolfBoot_printf("entry type: %x\r\n", type); + wolfBoot_printf("start: %x_%x\r\n", (uint32_t)(start >> 32), + (uint32_t)start); + wolfBoot_printf("end: %x_%x\r\n", (uint32_t)((start+length) >> 32), + (uint32_t)(start+length)); + return 0; +} + +void hob_dump_memory_map(struct efi_hob *hobList) +{ + hob_iterate_memory_map(hobList, hob_print_entry, NULL); +} +#else +void hob_dump_memory_map(struct efi_hob *hb) {} +#endif /* DEBUG_HOB_LIST */ + + + #endif /* HOB_C */ diff --git a/src/x86/paging.c b/src/x86/paging.c index 87e1f516..bd1563ad 100644 --- a/src/x86/paging.c +++ b/src/x86/paging.c @@ -219,4 +219,22 @@ int x86_paging_map_memory(uint64_t va, uint64_t pa, uint32_t size) return 0; } + +#ifdef DEBUG_PAGING +void x86_paging_dump_info() +{ + wolfBoot_printf("page_table_pages @ %x %xh\r\n", + (uint32_t)((uintptr_t)page_table_pages >> 32), + (uint32_t)(uintptr_t)page_table_pages); + wolfBoot_printf("page_table_pages used: %d\r\n", page_table_page_used); + wolfBoot_printf("mem start @ %x %xh\r\n", + (uint32_t)((uintptr_t)_mem >> 32), + (uint32_t)(uintptr_t)_mem); + wolfBoot_printf("mem curr @ %x %xh\r\n", + (uint32_t)((uintptr_t)mem >> 32), + (uint32_t)(uintptr_t)mem); +} +#else +void x86_paging_dump_info() {} +#endif /* DEBUG_PAGING */ #endif /* !BUILD_LOADER_STAGE1 */