aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWesley W. Terpstra <wesley@sifive.com>2017-03-23 19:16:43 -0700
committerWesley W. Terpstra <wesley@sifive.com>2017-03-23 19:17:22 -0700
commit96e5ed750e7447f2c0316368e5592fd331ee345c (patch)
tree75190a60f2b8595cec16a5fd879d841f519c5182
parent96965a8cc670d10055dbf64d42fedcda5b35beff (diff)
downloadriscv-pk-96e5ed750e7447f2c0316368e5592fd331ee345c.zip
riscv-pk-96e5ed750e7447f2c0316368e5592fd331ee345c.tar.gz
riscv-pk-96e5ed750e7447f2c0316368e5592fd331ee345c.tar.bz2
bbl: copy dtb after the kernel
-rw-r--r--bbl/bbl.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/bbl/bbl.c b/bbl/bbl.c
index 3550c9a..300182c 100644
--- a/bbl/bbl.c
+++ b/bbl/bbl.c
@@ -4,10 +4,25 @@
#include "vm.h"
#include "bits.h"
#include "config.h"
+#include "fdt.h"
#include <string.h>
static const void* entry_point;
+static uintptr_t dtb_output()
+{
+ extern char _payload_end;
+ uintptr_t end = (uintptr_t) &_payload_end;
+ return (end + MEGAPAGE_SIZE - 1) / MEGAPAGE_SIZE * MEGAPAGE_SIZE;
+}
+
+static void filter_dtb(uintptr_t source)
+{
+ uintptr_t dest = dtb_output();
+ uint32_t size = fdt_size(source);
+ memcpy((void*)dest, (void*)source, size);
+}
+
void boot_other_hart(uintptr_t dtb)
{
const void* entry;
@@ -15,12 +30,13 @@ void boot_other_hart(uintptr_t dtb)
entry = entry_point;
mb();
} while (!entry);
- enter_supervisor_mode(entry, read_csr(mhartid), dtb);
+ enter_supervisor_mode(entry, read_csr(mhartid), dtb_output());
}
void boot_loader(uintptr_t dtb)
{
extern char _payload_start;
+ filter_dtb(dtb);
#ifdef PK_ENABLE_LOGO
print_logo();
#endif