diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-11-16 14:02:07 -0800 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-11-16 14:02:07 -0800 |
commit | 197a8b81e4bbf61c497c93c0ac4630a33ab11b1c (patch) | |
tree | 27b984cf55295258d9ab31294402c66f328b53a4 /pk/minit.c | |
parent | 47f9e06fc2c696dfb1054d730cde888f1ac75d07 (diff) | |
download | pk-197a8b81e4bbf61c497c93c0ac4630a33ab11b1c.zip pk-197a8b81e4bbf61c497c93c0ac4630a33ab11b1c.tar.gz pk-197a8b81e4bbf61c497c93c0ac4630a33ab11b1c.tar.bz2 |
Use IPIs to wake up harts
This has the side effect of testing the IPI mechanism. Still not sure
this is the best approach to booting, but it works...
Diffstat (limited to 'pk/minit.c')
-rw-r--r-- | pk/minit.c | 43 |
1 files changed, 20 insertions, 23 deletions
@@ -4,7 +4,6 @@ uintptr_t mem_size; uint32_t num_harts; -uint32_t num_harts_booted = 1; static void mstatus_init() { @@ -55,16 +54,29 @@ static void fp_init() #endif } -void hls_init(uint32_t hart_id, uintptr_t* csrs) +void hls_init(uint32_t id, uintptr_t* csrs) { - hls_t* hls = OTHER_HLS(hart_id); + hls_t* hls = OTHER_HLS(id); memset(hls, 0, sizeof(*hls)); - hls->hart_id = hart_id; + hls->hart_id = id; hls->csrs = csrs; + + // tell the hart where its stack is, then wake it up + csrs[CSR_MSCRATCH] = (uintptr_t)(OTHER_STACK_TOP(id) - MENTRY_FRAME_SIZE); + mb(); + csrs[CSR_MIPI] = 0; +} + +static void init_hart() +{ + mstatus_init(); + fp_init(); } -static void init_first_hart() +void init_first_hart() { + init_hart(); + memset(HLS(), 0, sizeof(*HLS())); file_init(); parse_device_tree(); @@ -77,8 +89,10 @@ static void init_first_hart() boot_loader(args); } -static void init_other_hart(uint32_t hart_id) +void init_other_hart() { + init_hart(); + // wait until virtual memory is enabled do { mb(); @@ -86,22 +100,5 @@ static void init_other_hart(uint32_t hart_id) write_csr(sptbr, root_page_table); - // then make sure we're in bounds - if (hart_id >= num_harts) { - while (1) - wfi(); - } - boot_other_hart(); } - -void machine_init(uint32_t hart_id) -{ - mstatus_init(); - fp_init(); - - if (hart_id == 0) - init_first_hart(); - else - init_other_hart(hart_id); -} |