aboutsummaryrefslogtreecommitdiff
path: root/machine
diff options
context:
space:
mode:
Diffstat (limited to 'machine')
-rw-r--r--machine/mentry.S27
-rw-r--r--machine/minit.c16
-rw-r--r--machine/mtrap.h4
3 files changed, 23 insertions, 24 deletions
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()
{