diff options
author | Andrew Waterman <andrew@sifive.com> | 2017-02-17 01:54:52 -0800 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2017-02-17 01:55:00 -0800 |
commit | b14d4187fe1a328b9e87f61a984fd70e17211954 (patch) | |
tree | f8e8e8ec17b3092edbaf4c79e404bcac1e86be3e | |
parent | 926b360655fd7a22413c7732faceeea21a224aa1 (diff) | |
download | riscv-pk-b14d4187fe1a328b9e87f61a984fd70e17211954.zip riscv-pk-b14d4187fe1a328b9e87f61a984fd70e17211954.tar.gz riscv-pk-b14d4187fe1a328b9e87f61a984fd70e17211954.tar.bz2 |
Clean up boot loader for physical address loading
-rw-r--r-- | bbl/bbl.c | 11 | ||||
-rw-r--r-- | bbl/bbl.h | 9 | ||||
-rw-r--r-- | bbl/kernel_elf.c | 8 |
3 files changed, 8 insertions, 20 deletions
@@ -6,25 +6,24 @@ #include "config.h" #include <string.h> -static kernel_elf_info info; -static volatile int elf_loaded; +static volatile uintptr_t entry_point; void boot_other_hart() { - while (!elf_loaded) + while (!entry_point) ; mb(); - enter_supervisor_mode((void *)info.entry + info.load_offset, read_csr(mhartid), 0); + enter_supervisor_mode((void *)entry_point, read_csr(mhartid), 0); } void boot_loader() { extern char _payload_start, _payload_end; - load_kernel_elf(&_payload_start, &_payload_end - &_payload_start, &info); + uintptr_t entry = load_kernel_elf(&_payload_start, &_payload_end - &_payload_start); #ifdef PK_ENABLE_LOGO print_logo(); #endif mb(); - elf_loaded = 1; + entry_point = entry; boot_other_hart(); } @@ -8,14 +8,7 @@ #include <stdint.h> #include <stddef.h> -typedef struct { - uintptr_t entry; - uintptr_t first_user_vaddr; - uintptr_t first_vaddr_after_user; - uintptr_t load_offset; -} kernel_elf_info; - -void load_kernel_elf(void* blob, size_t size, kernel_elf_info* info); +uintptr_t load_kernel_elf(void* blob, size_t size); void print_logo(); #endif // !__ASSEMBLER__ diff --git a/bbl/kernel_elf.c b/bbl/kernel_elf.c index e22c35c..096a690 100644 --- a/bbl/kernel_elf.c +++ b/bbl/kernel_elf.c @@ -7,7 +7,7 @@ #include <elf.h> #include <string.h> -void load_kernel_elf(void* blob, size_t size, kernel_elf_info* info) +uintptr_t load_kernel_elf(void* blob, size_t size) { Elf_Ehdr* eh = blob; if (sizeof(*eh) > size || @@ -43,11 +43,7 @@ void load_kernel_elf(void* blob, size_t size, kernel_elf_info* info) } } - info->entry = eh->e_entry; - info->load_offset = bias; - info->first_user_vaddr = min_vaddr; - info->first_vaddr_after_user = ROUNDUP(max_vaddr - bias, RISCV_PGSIZE); - return; + return eh->e_entry + bias; fail: die("failed to load payload"); |