Skip to content

Commit 98e2a21

Browse files
committed
[Fix] pass x16 register as parameter for SBI call
The previous approach "li x16,0" may prevent the compiler from recognizing x16 as a function parameter, resulting in the caller saved register saving mechanism not being triggered in release mode.
1 parent 2f5cb65 commit 98e2a21

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

os/src/main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ pub fn rust_main() -> ! {
103103
clear_bss();
104104
kernel_log_info();
105105
mm::init();
106-
println!("after mm::init!");
107106
mm::remap_test();
108107
task::add_initproc();
109108
println!("after initproc!");

os/src/sbi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ fn sbi_call(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize {
1515
let mut ret;
1616
unsafe {
1717
asm!(
18-
"li x16, 0",
1918
"ecall",
2019
inlateout("x10") arg0 => ret,
2120
in("x11") arg1,
2221
in("x12") arg2,
22+
in("x16") 0,
2323
in("x17") which,
2424
);
2525
}

0 commit comments

Comments
 (0)