@@ -71,6 +71,9 @@ _abs_start:
7171 "csrw stvec, t0" ,
7272 #[ cfg( not( feature = "s-mode" ) ) ]
7373 "csrw mtvec, t0" ,
74+ // Make sure that a0 contains the hart ID also in M-mode
75+ #[ cfg( not( feature = "s-mode" ) ) ]
76+ "csrr a0, mhartid" ,
7477) ;
7578
7679// ZERO OUT GENERAL-PURPOSE REGISTERS
@@ -89,11 +92,8 @@ cfg_global_asm!(
8992) ;
9093#[ cfg( not( feature = "single-hart" ) ) ]
9194cfg_global_asm ! (
92- #[ cfg( feature = "s-mode" ) ]
93- "mv t2, a0 // the hartid is passed as parameter by SMODE" ,
94- #[ cfg( not( feature = "s-mode" ) ) ]
95- "csrr t2, mhartid" ,
96- "lui t0, %hi(_max_hart_id)
95+ "mv t2, a0
96+ lui t0, %hi(_max_hart_id)
9797 add t0, t0, %lo(_max_hart_id)
9898 bgtu t2, t0, abort
9999 lui t0, %hi(_hart_stack_size)
@@ -131,18 +131,12 @@ cfg_global_asm!(
131131 sd a2, 8 * 2(sp)" ,
132132) ;
133133
134- // SKIP RAM INITIALIZATION IF CURRENT HART IS NOT THE BOOT HART
135- #[ cfg( not( feature = "single-hart" ) ) ]
134+ // CALL __pre_init (IF ENABLED) AND INITIALIZE RAM
136135cfg_global_asm ! (
137- #[ cfg( not( feature = "s-mode " ) ) ]
138- "csrr a0, mhartid" ,
136+ #[ cfg( not( feature = "single-hart " ) ) ]
137+ // Skip RAM initialization if current hart is not the boot hart
139138 "call _mp_hook
140- mv t0, a0
141-
142139 beqz a0, 4f" ,
143- ) ;
144- // IF CURRENT HART IS THE BOOT HART CALL __pre_init (IF ENABLED) AND INITIALIZE RAM
145- cfg_global_asm ! (
146140 #[ cfg( feature = "pre-init" ) ]
147141 "call __pre_init" ,
148142 "// Copy .data from flash to RAM
0 commit comments