aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWesley W. Terpstra <wesley@sifive.com>2017-03-22 14:35:13 -0700
committerWesley W. Terpstra <wesley@sifive.com>2017-03-22 14:35:13 -0700
commit23ab37ad78673166a8300584d177ace77fca5101 (patch)
tree1e6b9b16a5cc5768d1c91f6661a2ebfff61b2891
parent316f85e9ae2f5d9dd0b33d3649a8256db0dfd29b (diff)
downloadpk-fdt.zip
pk-fdt.tar.gz
pk-fdt.tar.bz2
SBI: a0+a1 hold hartid+dtb pointer between boot loader stagesfdt
-rw-r--r--bbl/bbl.c8
-rw-r--r--machine/mentry.S27
-rw-r--r--machine/minit.c16
-rw-r--r--machine/mtrap.h4
-rw-r--r--pk/pk.c6
5 files changed, 30 insertions, 31 deletions
diff --git a/bbl/bbl.c b/bbl/bbl.c
index 9553ddb..3550c9a 100644
--- a/bbl/bbl.c
+++ b/bbl/bbl.c
@@ -8,17 +8,17 @@
static const void* entry_point;
-void boot_other_hart()
+void boot_other_hart(uintptr_t dtb)
{
const void* entry;
do {
entry = entry_point;
mb();
} while (!entry);
- enter_supervisor_mode(entry, read_csr(mhartid), 0);
+ enter_supervisor_mode(entry, read_csr(mhartid), dtb);
}
-void boot_loader()
+void boot_loader(uintptr_t dtb)
{
extern char _payload_start;
#ifdef PK_ENABLE_LOGO
@@ -26,5 +26,5 @@ void boot_loader()
#endif
mb();
entry_point = &_payload_start;
- boot_other_hart();
+ boot_other_hart(dtb);
}
diff --git a/machine/mentry.S b/machine/mentry.S
index 01db536..9ce3257 100644
--- a/machine/mentry.S
+++ b/machine/mentry.S
@@ -217,8 +217,9 @@ do_reset:
li x7, 0
li x8, 0
li x9, 0
- li x10, 0
- li x11, 0
+// save a0 and a1; arguments from previous boot loader stage:
+// li x10, 0
+// li x11, 0
li x12, 0
li x13, 0
li x14, 0
@@ -249,28 +250,28 @@ do_reset:
la sp, stacks + RISCV_PGSIZE - MENTRY_FRAME_SIZE
- csrr a0, mhartid
- slli a1, a0, RISCV_PGSHIFT
- add sp, sp, a1
+ csrr a3, mhartid
+ slli a2, a3, RISCV_PGSHIFT
+ add sp, sp, a2
- beqz a0, init_first_hart
+ beqz a3, init_first_hart
# set MSIE bit to receive IPI
- li a1, MIP_MSIP
- csrw mie, a1
+ li a2, MIP_MSIP
+ csrw mie, a2
.LmultiHart:
#if MAX_HARTS > 1
# wait for an IPI to signal that it's safe to boot
wfi
- csrr a1, mip
- andi a1, a1, MIP_MSIP
- beqz a1, .LmultiHart
+ csrr a2, mip
+ andi a2, a2, MIP_MSIP
+ beqz a2, .LmultiHart
# make sure our hart id is within a valid range
fence
- li a1, MAX_HARTS
- bltu a0, a1, init_other_hart
+ li a2, MAX_HARTS
+ bltu a3, a2, init_other_hart
#endif
wfi
j .LmultiHart
diff --git a/machine/minit.c b/machine/minit.c
index 2616f19..f02f205 100644
--- a/machine/minit.c
+++ b/machine/minit.c
@@ -72,8 +72,6 @@ hls_t* hls_init(uintptr_t id)
return hls;
}
-#define DTB 0x1014
-
static void memory_init()
{
mem_size = mem_size / MEGAPAGE_SIZE * MEGAPAGE_SIZE;
@@ -122,27 +120,27 @@ static void hart_plic_init()
*HLS()->plic_s_thresh = 0;
}
-void init_first_hart()
+void init_first_hart(uintptr_t hartid, uintptr_t dtb)
{
hart_init();
hls_init(0); // this might get called again from parse_config_string
- query_mem(DTB);
- query_harts(DTB);
- query_clint(DTB);
+ query_mem(dtb);
+ query_harts(dtb);
+ query_clint(dtb);
plic_init();
hart_plic_init();
//prci_test();
memory_init();
- boot_loader();
+ boot_loader(dtb);
}
-void init_other_hart()
+void init_other_hart(uintptr_t hartid, uintptr_t dtb)
{
hart_init();
hart_plic_init();
- boot_other_hart();
+ boot_other_hart(dtb);
}
void enter_supervisor_mode(void (*fn)(uintptr_t), uintptr_t arg0, uintptr_t arg1)
diff --git a/machine/mtrap.h b/machine/mtrap.h
index 2f0fc69..e8dfc49 100644
--- a/machine/mtrap.h
+++ b/machine/mtrap.h
@@ -64,8 +64,8 @@ void putstring(const char* s);
void enter_supervisor_mode(void (*fn)(uintptr_t), uintptr_t arg0, uintptr_t arg1)
__attribute__((noreturn));
-void boot_loader();
-void boot_other_hart();
+void boot_loader(uintptr_t dtb);
+void boot_other_hart(uintptr_t dtb);
static inline void wfi()
{
diff --git a/pk/pk.c b/pk/pk.c
index c0b6407..1a2e540 100644
--- a/pk/pk.c
+++ b/pk/pk.c
@@ -154,7 +154,7 @@ static void rest_of_boot_loader(uintptr_t kstack_top)
run_loaded_program(argc, args.argv, kstack_top);
}
-void boot_loader()
+void boot_loader(uintptr_t dtb)
{
extern char trap_entry;
write_csr(stvec, &trap_entry);
@@ -163,10 +163,10 @@ void boot_loader()
set_csr(sstatus, SSTATUS_SUM);
file_init();
- enter_supervisor_mode(rest_of_boot_loader, pk_vm_init(), 0);
+ enter_supervisor_mode(rest_of_boot_loader, pk_vm_init(), dtb);
}
-void boot_other_hart()
+void boot_other_hart(uintptr_t dtb)
{
// stall all harts besides hart 0
while (1)