Skip to content

Commit

Permalink
testing: update to naked_asm! in naked functions to build under rustc…
Browse files Browse the repository at this point in the history
… 2024-10-07

Ref: rust-lang/rust#128651
Signed-off-by: Zhouqi Jiang <luojia@hust.edu.cn>
  • Loading branch information
luojia65 committed Oct 18, 2024
1 parent 3370a9b commit fcd0726
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 2 additions & 3 deletions sbi-testing/src/hsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,18 @@ fn test_batch(batch: &[usize], mut f: impl FnMut(Case)) -> bool {
/// 测试用启动入口
#[naked]
unsafe extern "C" fn test_entry(hartid: usize, opaque: *mut ItemPerHart) -> ! {
core::arch::asm!(
core::arch::naked_asm!(
"csrw sie, zero", // 关中断
"call {set_stack}", // 设置栈
"j {rust_main}", // 进入 rust
set_stack = sym set_stack,
rust_main = sym rust_main,
options(noreturn),
)
}

#[naked]
unsafe extern "C" fn set_stack(hart_id: usize, ptr: *const ItemPerHart) {
core::arch::asm!("addi sp, a1, 512", "ret", options(noreturn));
core::arch::naked_asm!("addi sp, a1, 512", "ret");
}

#[inline(never)]
Expand Down
3 changes: 1 addition & 2 deletions sbi-testing/src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Thread {
/// 裸函数。
#[naked]
unsafe extern "C" fn execute_naked() {
core::arch::asm!(
core::arch::naked_asm!(
r" .altmacro
.macro SAVE n
sd x\n, \n*8(sp)
Expand Down Expand Up @@ -176,6 +176,5 @@ unsafe extern "C" fn execute_naked() {
// 返回调度
" ret",
" .option pop",
options(noreturn)
)
}

0 comments on commit fcd0726

Please sign in to comment.