aboutsummaryrefslogtreecommitdiff
path: root/bbl
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2017-02-20 21:43:09 -0800
committerAndrew Waterman <andrew@sifive.com>2017-02-20 21:43:09 -0800
commitf6bca6e35b66632afad68f6b7fb2b3203c8502fb (patch)
tree3f8d691713d96ef4e7f57b8504691e68cdcda6f7 /bbl
parent59484c94e161b0f1870096cfb183533b20569669 (diff)
downloadriscv-pk-f6bca6e35b66632afad68f6b7fb2b3203c8502fb.zip
riscv-pk-f6bca6e35b66632afad68f6b7fb2b3203c8502fb.tar.gz
riscv-pk-f6bca6e35b66632afad68f6b7fb2b3203c8502fb.tar.bz2
Don't block for acks on console writes
Diffstat (limited to 'bbl')
-rw-r--r--bbl/bbl.ac4
-rw-r--r--bbl/bbl.c17
-rw-r--r--bbl/bbl.h1
-rw-r--r--bbl/bbl.lds4
-rw-r--r--bbl/bbl.mk.in6
-rw-r--r--bbl/kernel_elf.c50
-rw-r--r--bbl/payload.S10
7 files changed, 23 insertions, 69 deletions
diff --git a/bbl/bbl.ac b/bbl/bbl.ac
index 51dcf01..4b6a9f3 100644
--- a/bbl/bbl.ac
+++ b/bbl/bbl.ac
@@ -1,5 +1,5 @@
-AC_ARG_ENABLE([logo], AS_HELP_STRING([--disable-logo], [Disable boot logo]))
-AS_IF([test "x$enable_logo" != "xno"], [
+AC_ARG_ENABLE([logo], AS_HELP_STRING([--enable-logo], [Enable boot logo]))
+AS_IF([test "x$enable_logo" == "xyes"], [
AC_DEFINE([PK_ENABLE_LOGO],,[Define if the RISC-V logo is to be displayed])
])
diff --git a/bbl/bbl.c b/bbl/bbl.c
index bdd56ad..9553ddb 100644
--- a/bbl/bbl.c
+++ b/bbl/bbl.c
@@ -6,24 +6,25 @@
#include "config.h"
#include <string.h>
-static volatile uintptr_t entry_point;
+static const void* entry_point;
void boot_other_hart()
{
- while (!entry_point)
- ;
- mb();
- enter_supervisor_mode((void *)entry_point, read_csr(mhartid), 0);
+ const void* entry;
+ do {
+ entry = entry_point;
+ mb();
+ } while (!entry);
+ enter_supervisor_mode(entry, read_csr(mhartid), 0);
}
void boot_loader()
{
- extern char _payload_start, _payload_end;
- uintptr_t entry = load_kernel_elf(&_payload_start, &_payload_end - &_payload_start);
+ extern char _payload_start;
#ifdef PK_ENABLE_LOGO
print_logo();
#endif
mb();
- entry_point = entry;
+ entry_point = &_payload_start;
boot_other_hart();
}
diff --git a/bbl/bbl.h b/bbl/bbl.h
index 67997b9..c9a02e1 100644
--- a/bbl/bbl.h
+++ b/bbl/bbl.h
@@ -8,7 +8,6 @@
#include <stdint.h>
#include <stddef.h>
-uintptr_t load_kernel_elf(void* blob, size_t size);
void print_logo();
#endif // !__ASSEMBLER__
diff --git a/bbl/bbl.lds b/bbl/bbl.lds
index 6833e47..b90e99f 100644
--- a/bbl/bbl.lds
+++ b/bbl/bbl.lds
@@ -44,9 +44,9 @@ SECTIONS
/* HTIF, isolated onto separate page */
/*--------------------------------------------------------------------*/
. = ALIGN(0x1000);
- htif :
+ .htif :
{
- *(htif)
+ *(.htif)
}
. = ALIGN(0x1000);
diff --git a/bbl/bbl.mk.in b/bbl/bbl.mk.in
index 1bb4cd1..5abe2cd 100644
--- a/bbl/bbl.mk.in
+++ b/bbl/bbl.mk.in
@@ -8,13 +8,15 @@ bbl_hdrs = \
bbl.h \
bbl_c_srcs = \
- kernel_elf.c \
logo.c \
bbl_asm_srcs = \
payload.S \
-payload.o: $(bbl_payload)
+payload.o: bbl_payload
+
+bbl_payload: $(BBL_PAYLOAD)
+ if $(READELF) -h $< 2> /dev/null > /dev/null; then $(OBJCOPY) -O binary $< $@; else cp $< $@; fi
bbl_test_srcs =
diff --git a/bbl/kernel_elf.c b/bbl/kernel_elf.c
deleted file mode 100644
index 096a690..0000000
--- a/bbl/kernel_elf.c
+++ /dev/null
@@ -1,50 +0,0 @@
-// See LICENSE for license details.
-
-#include "mtrap.h"
-#include "bbl.h"
-#include "bits.h"
-#include "vm.h"
-#include <elf.h>
-#include <string.h>
-
-uintptr_t load_kernel_elf(void* blob, size_t size)
-{
- Elf_Ehdr* eh = blob;
- if (sizeof(*eh) > size ||
- !(eh->e_ident[0] == '\177' && eh->e_ident[1] == 'E' &&
- eh->e_ident[2] == 'L' && eh->e_ident[3] == 'F'))
- goto fail;
-
- if (IS_ELF64(*eh) != (sizeof(uintptr_t) == 8))
- goto fail;
-
- uintptr_t min_vaddr = -1, max_vaddr = 0;
- size_t phdr_size = eh->e_phnum * sizeof(Elf_Ehdr);
- Elf_Phdr* ph = blob + eh->e_phoff;
- if (eh->e_phoff + phdr_size > size)
- goto fail;
- first_free_paddr = ROUNDUP(first_free_paddr, MEGAPAGE_SIZE);
- for (int i = 0; i < eh->e_phnum; i++)
- if (ph[i].p_type == PT_LOAD && ph[i].p_memsz && ph[i].p_vaddr < min_vaddr)
- min_vaddr = ph[i].p_vaddr;
- min_vaddr = ROUNDDOWN(min_vaddr, MEGAPAGE_SIZE);
- uintptr_t bias = first_free_paddr - min_vaddr;
- for (int i = eh->e_phnum - 1; i >= 0; i--) {
- if(ph[i].p_type == PT_LOAD && ph[i].p_memsz) {
- uintptr_t prepad = ph[i].p_vaddr % RISCV_PGSIZE;
- uintptr_t vaddr = ph[i].p_vaddr + bias;
- if (vaddr + ph[i].p_memsz > max_vaddr)
- max_vaddr = vaddr + ph[i].p_memsz;
- if (ph[i].p_offset + ph[i].p_filesz > size)
- goto fail;
- memcpy((void*)vaddr, blob + ph[i].p_offset, ph[i].p_filesz);
- memset((void*)vaddr - prepad, 0, prepad);
- memset((void*)vaddr + ph[i].p_filesz, 0, ph[i].p_memsz - ph[i].p_filesz);
- }
- }
-
- return eh->e_entry + bias;
-
-fail:
- die("failed to load payload");
-}
diff --git a/bbl/payload.S b/bbl/payload.S
index 7ff1e58..6a175aa 100644
--- a/bbl/payload.S
+++ b/bbl/payload.S
@@ -1,7 +1,9 @@
-.section ".payload","a",@progbits
-.align 3
+#include "encoding.h"
-.globl _payload_start, _payload_end
+ .section ".payload","a",@progbits
+ .align RISCV_PGSHIFT + RISCV_PGLEVEL_BITS
+
+ .globl _payload_start, _payload_end
_payload_start:
-.incbin BBL_PAYLOAD
+ .incbin BBL_PAYLOAD
_payload_end: