Replace llvm_asm! with asm

This commit is contained in:
Yifan Wu 2021-07-18 19:21:16 +08:00
parent 4388e6ddec
commit 258516a3ca
6 changed files with 23 additions and 16 deletions

View file

@ -1,7 +1,7 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
#![feature(global_asm)] #![feature(global_asm)]
#![feature(llvm_asm)] #![feature(asm)]
#![feature(panic_info_message)] #![feature(panic_info_message)]
#![feature(alloc_error_handler)] #![feature(alloc_error_handler)]

View file

@ -182,7 +182,7 @@ impl MemorySet {
let satp = self.page_table.token(); let satp = self.page_table.token();
unsafe { unsafe {
satp::write(satp); satp::write(satp);
llvm_asm!("sfence.vma" :::: "volatile"); asm!("sfence.vma");
} }
} }
pub fn translate(&self, vpn: VirtPageNum) -> Option<PageTableEntry> { pub fn translate(&self, vpn: VirtPageNum) -> Option<PageTableEntry> {

View file

@ -14,11 +14,12 @@ const SBI_SHUTDOWN: usize = 8;
fn sbi_call(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize { fn sbi_call(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize {
let mut ret; let mut ret;
unsafe { unsafe {
llvm_asm!("ecall" asm!(
: "={x10}" (ret) "ecall",
: "{x10}" (arg0), "{x11}" (arg1), "{x12}" (arg2), "{x17}" (which) inlateout("x10") arg0 => ret,
: "memory" in("x11") arg1,
: "volatile" in("x12") arg2,
in("x17") which,
); );
} }
ret ret

View file

@ -86,10 +86,15 @@ pub fn trap_return() -> ! {
} }
let restore_va = __restore as usize - __alltraps as usize + TRAMPOLINE; let restore_va = __restore as usize - __alltraps as usize + TRAMPOLINE;
unsafe { unsafe {
llvm_asm!("fence.i" :::: "volatile"); asm!(
llvm_asm!("jr $0" :: "r"(restore_va), "{a0}"(trap_cx_ptr), "{a1}"(user_satp) :: "volatile"); "fence.i",
"jr {restore_va}",
restore_va = in(reg) restore_va,
in("a0") trap_cx_ptr,
in("a1") user_satp,
options(noreturn)
);
} }
panic!("Unreachable in back_to_user!");
} }
#[no_mangle] #[no_mangle]

View file

@ -1,5 +1,5 @@
#![no_std] #![no_std]
#![feature(llvm_asm)] #![feature(asm)]
#![feature(linkage)] #![feature(linkage)]
#![feature(panic_info_message)] #![feature(panic_info_message)]

View file

@ -6,11 +6,12 @@ const SYSCALL_GET_TIME: usize = 169;
fn syscall(id: usize, args: [usize; 3]) -> isize { fn syscall(id: usize, args: [usize; 3]) -> isize {
let mut ret: isize; let mut ret: isize;
unsafe { unsafe {
llvm_asm!("ecall" asm!(
: "={x10}" (ret) "ecall",
: "{x10}" (args[0]), "{x11}" (args[1]), "{x12}" (args[2]), "{x17}" (id) inlateout("x10") args[0] => ret,
: "memory" in("x11") args[1],
: "volatile" in("x12") args[2],
in("x17") id
); );
} }
ret ret