File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed
Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -15,4 +15,4 @@ riscv-semihosting = { path = "../riscv-semihosting" }
1515default = [" single-hart" ]
1616s-mode = [" riscv-rt/s-mode" , " single-hart" ]
1717single-hart = [" riscv-rt/single-hart" , " riscv/critical-section-single-hart" ]
18- multi-hart = []
18+ multi-hart = [" riscv-rt/post-init " ]
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ extern crate panic_halt;
1010
1111use core:: arch:: global_asm;
1212use core:: sync:: atomic:: { AtomicBool , Ordering } ;
13- use riscv_rt:: entry;
13+ use riscv_rt:: { entry, post_init } ;
1414use riscv_semihosting:: debug:: { self , EXIT_SUCCESS } ;
1515
1616const UART_BASE : usize = 0x1000_0000 ;
@@ -104,21 +104,24 @@ _mp_hook:
104104"#
105105) ;
106106
107- #[ entry ]
108- fn main ( hartid : usize ) -> ! {
107+ #[ post_init ]
108+ fn post_init ( hartid : usize ) {
109109 if hartid == 0 {
110110 uart_init ( ) ;
111111 uart_print ( "Hart 0: Initializing\n " ) ;
112112
113113 // Send IPI to Hart 1 (write to CLINT msip register for hart 1)
114- unsafe {
115- ( 0x02000004usize as * mut u32 ) . write_volatile ( 1 ) ;
116- }
114+ unsafe { ( 0x02000004usize as * mut u32 ) . write_volatile ( 1 ) } ;
115+ }
116+ }
117117
118+ #[ entry]
119+ fn main ( hartid : usize ) -> ! {
120+ if hartid == 0 {
121+ // Hart 0 reaches here after initializing UART and sending IPI
118122 while !HART1_DONE . load ( Ordering :: Acquire ) {
119123 core:: hint:: spin_loop ( ) ;
120124 }
121-
122125 uart_print ( "Hart 0: Both harts done\n " ) ;
123126 debug:: exit ( EXIT_SUCCESS ) ;
124127 } else {
You can’t perform that action at this time.
0 commit comments