diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-11-28 16:59:00 -0800 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-11-28 17:00:06 -0800 |
commit | 529a6a3a0c42468bf815255697279e0e059a22db (patch) | |
tree | d1c6786e02820ea4714154cb8cb265d529771f15 /pk/minit.c | |
parent | d37b50edf5faee2fe41a2586479ddab7c8a2ec9b (diff) | |
download | pk-529a6a3a0c42468bf815255697279e0e059a22db.zip pk-529a6a3a0c42468bf815255697279e0e059a22db.tar.gz pk-529a6a3a0c42468bf815255697279e0e059a22db.tar.bz2 |
Change boot procedure to not rely on IPIs
That procedure doesn't work correctly if hart 0 comes out of reset while
hart 1 is still in reset.
Diffstat (limited to 'pk/minit.c')
-rw-r--r-- | pk/minit.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -2,6 +2,7 @@ #include "mtrap.h" #include "devicetree.h" +volatile uint32_t booted_harts_mask; uintptr_t mem_size; uint32_t num_harts; @@ -61,10 +62,13 @@ void hls_init(uint32_t id, uintptr_t* csrs) 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; + if (id != 0) { + while (((booted_harts_mask >> id) & 1) == 0) + ; + mb(); + // wake up the hart by granting it a stack + csrs[CSR_MSCRATCH] = (uintptr_t)(OTHER_STACK_TOP(id) - MENTRY_FRAME_SIZE); + } } static void init_hart() @@ -94,10 +98,9 @@ void init_other_hart() init_hart(); // wait until virtual memory is enabled - do { - mb(); - } while (root_page_table == NULL); - + while (*(pte_t* volatile*)&root_page_table == NULL) + ; + mb(); write_csr(sptbr, root_page_table); boot_other_hart(); |