diff options
Diffstat (limited to 'bbl')
-rw-r--r-- | bbl/bbl.ac | 11 | ||||
-rw-r--r-- | bbl/bbl.c | 18 | ||||
-rw-r--r-- | bbl/bbl.lds | 2 | ||||
-rw-r--r-- | bbl/bbl.mk.in | 2 | ||||
-rw-r--r-- | bbl/logo.c | 2 | ||||
-rw-r--r-- | bbl/payload.S | 10 | ||||
-rw-r--r-- | bbl/raw_logo.S | 2 |
7 files changed, 41 insertions, 6 deletions
@@ -1,11 +1,18 @@ +# See LICENSE for license details. + 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]) ]) AC_ARG_WITH([payload], AS_HELP_STRING([--with-payload], [Set ELF payload for bbl]), - [AC_SUBST([BBL_PAYLOAD], $with_payload, [Kernel payload for bbl])], - [AC_SUBST([BBL_PAYLOAD], [dummy_payload], [Kernel payload for bbl])]) + [ + AC_SUBST([BBL_PAYLOAD], $with_payload, [Kernel payload for bbl]) + AC_DEFINE(RELAXED_ALIGNMENT,[0],[Use relaxed payload alignment]) + ], [ + AC_SUBST([BBL_PAYLOAD], [dummy_payload], [Kernel payload for bbl]) + AC_DEFINE(RELAXED_ALIGNMENT,[1],[Use relaxed payload alignment]) + ]) AC_ARG_WITH([logo], AS_HELP_STRING([--with-logo], [Specify a better logo]), [AC_SUBST([BBL_LOGO_FILE], $with_logo, [Logo for bbl])], @@ -1,3 +1,5 @@ +// See LICENSE for license details. + #include "bbl.h" #include "mtrap.h" #include "atomic.h" @@ -7,13 +9,21 @@ #include "fdt.h" #include <string.h> +extern char _payload_start, _payload_end; /* internal payload */ static const void* entry_point; long disabled_hart_mask; static uintptr_t dtb_output() { - extern char _payload_end; - uintptr_t end = (uintptr_t) &_payload_end; + /* + * Place DTB after the payload, either the internal payload or a + * preloaded external payload specified in device-tree, if present. + * + * Note: linux kernel calls __va(dtb) to get the device-tree virtual + * address. The kernel's virtual mapping begins at its load address, + * thus mandating device-tree is in physical memory after the kernel. + */ + uintptr_t end = kernel_end ? (uintptr_t)kernel_end : (uintptr_t)&_payload_end; return (end + MEGAPAGE_SIZE - 1) / MEGAPAGE_SIZE * MEGAPAGE_SIZE; } @@ -53,7 +63,6 @@ void boot_other_hart(uintptr_t unused __attribute__((unused))) void boot_loader(uintptr_t dtb) { - extern char _payload_start; filter_dtb(dtb); #ifdef PK_ENABLE_LOGO print_logo(); @@ -62,6 +71,7 @@ void boot_loader(uintptr_t dtb) fdt_print(dtb_output()); #endif mb(); - entry_point = &_payload_start; + /* Use optional FDT preloaded external payload if present */ + entry_point = kernel_start ? kernel_start : &_payload_start; boot_other_hart(0); } diff --git a/bbl/bbl.lds b/bbl/bbl.lds index 2fd0d7c..26f5816 100644 --- a/bbl/bbl.lds +++ b/bbl/bbl.lds @@ -1,3 +1,5 @@ +/* See LICENSE for license details. */ + OUTPUT_ARCH( "riscv" ) ENTRY( reset_vector ) diff --git a/bbl/bbl.mk.in b/bbl/bbl.mk.in index 3e426d3..01c06c5 100644 --- a/bbl/bbl.mk.in +++ b/bbl/bbl.mk.in @@ -1,3 +1,5 @@ +# See LICENSE for license details. + bbl_subproject_deps = \ util \ softfloat \ @@ -1,3 +1,5 @@ +// See LICENSE for license details. + #include <string.h> #include "mtrap.h" diff --git a/bbl/payload.S b/bbl/payload.S index 6a175aa..9f79430 100644 --- a/bbl/payload.S +++ b/bbl/payload.S @@ -1,7 +1,17 @@ +// See LICENSE for license details. + +#include "config.h" #include "encoding.h" .section ".payload","a",@progbits + +#if RELAXED_ALIGNMENT + /* align payload minimally */ + .align 3 +#else + /* align payload to megapage */ .align RISCV_PGSHIFT + RISCV_PGLEVEL_BITS +#endif .globl _payload_start, _payload_end _payload_start: diff --git a/bbl/raw_logo.S b/bbl/raw_logo.S index bddf8f4..0eaf6cc 100644 --- a/bbl/raw_logo.S +++ b/bbl/raw_logo.S @@ -1,3 +1,5 @@ +// See LICENSE for license details. + #include "encoding.h" .section .rodata |