From 94387ed9dd430b834d0947ce19972afc65b7dd67 Mon Sep 17 00:00:00 2001 From: Yifan Wu Date: Sun, 18 Jul 2021 17:28:03 +0800 Subject: [PATCH] Replace llvm_asm! with asm --- os/src/batch.rs | 2 +- os/src/main.rs | 2 +- os/src/sbi.rs | 11 ++++++----- user/src/lib.rs | 2 +- user/src/syscall.rs | 11 ++++++----- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/os/src/batch.rs b/os/src/batch.rs index 7a29c9a1..fbe94cd5 100644 --- a/os/src/batch.rs +++ b/os/src/batch.rs @@ -58,7 +58,7 @@ impl AppManager { } println!("[kernel] Loading app_{}", app_id); // clear icache - llvm_asm!("fence.i" :::: "volatile"); + asm!("fence.i"); // clear app area core::slice::from_raw_parts_mut( APP_BASE_ADDRESS as *mut u8, diff --git a/os/src/main.rs b/os/src/main.rs index 936986f3..a01c22f0 100644 --- a/os/src/main.rs +++ b/os/src/main.rs @@ -1,7 +1,7 @@ #![no_std] #![no_main] #![feature(global_asm)] -#![feature(llvm_asm)] +#![feature(asm)] #![feature(panic_info_message)] #[macro_use] diff --git a/os/src/sbi.rs b/os/src/sbi.rs index 9fc74a97..935fe24e 100644 --- a/os/src/sbi.rs +++ b/os/src/sbi.rs @@ -14,11 +14,12 @@ const SBI_SHUTDOWN: usize = 8; fn sbi_call(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize { let mut ret; unsafe { - llvm_asm!("ecall" - : "={x10}" (ret) - : "{x10}" (arg0), "{x11}" (arg1), "{x12}" (arg2), "{x17}" (which) - : "memory" - : "volatile" + asm!( + "ecall", + inlateout("x10") arg0 => ret, + in("x11") arg1, + in("x12") arg2, + in("x17") which, ); } ret diff --git a/user/src/lib.rs b/user/src/lib.rs index bc68c734..c06f9245 100644 --- a/user/src/lib.rs +++ b/user/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -#![feature(llvm_asm)] +#![feature(asm)] #![feature(linkage)] #![feature(panic_info_message)] diff --git a/user/src/syscall.rs b/user/src/syscall.rs index b10cacf7..bb7582f2 100644 --- a/user/src/syscall.rs +++ b/user/src/syscall.rs @@ -4,11 +4,12 @@ const SYSCALL_EXIT: usize = 93; fn syscall(id: usize, args: [usize; 3]) -> isize { let mut ret: isize; unsafe { - llvm_asm!("ecall" - : "={x10}" (ret) - : "{x10}" (args[0]), "{x11}" (args[1]), "{x12}" (args[2]), "{x17}" (id) - : "memory" - : "volatile" + asm!( + "ecall", + inlateout("x10") args[0] => ret, + in("x11") args[1], + in("x12") args[2], + in("x17") id ); } ret