1
0
mirror of https://github.com/sgmarz/osblog.git synced 2024-11-24 02:16:19 +04:00

Run cargo fix

This commit is contained in:
Stephen Marz 2020-04-26 15:53:26 -04:00
parent 3d43bbd93c
commit 7dfe0b8182
3 changed files with 24 additions and 23 deletions

View File

@ -79,62 +79,62 @@ pub const fn build_satp(mode: SatpMode, asid: usize, addr: usize) -> usize {
pub fn mhartid_read() -> usize {
unsafe {
let rval;
asm!("csrr $0, mhartid" :"=r"(rval));
llvm_asm!("csrr $0, mhartid" :"=r"(rval));
rval
}
}
pub fn mie_read() -> usize {
unsafe {
let rval;
asm!("csrr $0, mie" :"=r"(rval));
llvm_asm!("csrr $0, mie" :"=r"(rval));
rval
}
}
pub fn mie_write(val: usize) {
unsafe {
asm!("csrw mie, $0" :: "r"(val));
llvm_asm!("csrw mie, $0" :: "r"(val));
}
}
pub fn mstatus_write(val: usize) {
unsafe {
asm!("csrw mstatus, $0" ::"r"(val));
llvm_asm!("csrw mstatus, $0" ::"r"(val));
}
}
pub fn mstatus_read() -> usize {
unsafe {
let rval;
asm!("csrr $0, mstatus":"=r"(rval));
llvm_asm!("csrr $0, mstatus":"=r"(rval));
rval
}
}
pub fn stvec_write(val: usize) {
unsafe {
asm!("csrw stvec, $0" ::"r"(val));
llvm_asm!("csrw stvec, $0" ::"r"(val));
}
}
pub fn stvec_read() -> usize {
unsafe {
let rval;
asm!("csrr $0, stvec" :"=r"(rval));
llvm_asm!("csrr $0, stvec" :"=r"(rval));
rval
}
}
pub fn mscratch_write(val: usize) {
unsafe {
asm!("csrw mscratch, $0" ::"r"(val));
llvm_asm!("csrw mscratch, $0" ::"r"(val));
}
}
pub fn mscratch_read() -> usize {
unsafe {
let rval;
asm!("csrr $0, mscratch" : "=r"(rval));
llvm_asm!("csrr $0, mscratch" : "=r"(rval));
rval
}
}
@ -142,21 +142,21 @@ pub fn mscratch_read() -> usize {
pub fn mscratch_swap(to: usize) -> usize {
unsafe {
let from;
asm!("csrrw $0, mscratch, $1" : "=r"(from) : "r"(to));
llvm_asm!("csrrw $0, mscratch, $1" : "=r"(from) : "r"(to));
from
}
}
pub fn sscratch_write(val: usize) {
unsafe {
asm!("csrw sscratch, $0" ::"r"(val));
llvm_asm!("csrw sscratch, $0" ::"r"(val));
}
}
pub fn sscratch_read() -> usize {
unsafe {
let rval;
asm!("csrr $0, sscratch" : "=r"(rval));
llvm_asm!("csrr $0, sscratch" : "=r"(rval));
rval
}
}
@ -164,49 +164,49 @@ pub fn sscratch_read() -> usize {
pub fn sscratch_swap(to: usize) -> usize {
unsafe {
let from;
asm!("csrrw $0, sscratch, $1" : "=r"(from) : "r"(to));
llvm_asm!("csrrw $0, sscratch, $1" : "=r"(from) : "r"(to));
from
}
}
pub fn mepc_write(val: usize) {
unsafe {
asm!("csrw mepc, $0" :: "r"(val));
llvm_asm!("csrw mepc, $0" :: "r"(val));
}
}
pub fn mepc_read() -> usize {
unsafe {
let rval;
asm!("csrr $0, mepc" :"=r"(rval));
llvm_asm!("csrr $0, mepc" :"=r"(rval));
rval
}
}
pub fn sepc_write(val: usize) {
unsafe {
asm!("csrw sepc, $0" :: "r"(val));
llvm_asm!("csrw sepc, $0" :: "r"(val));
}
}
pub fn sepc_read() -> usize {
unsafe {
let rval;
asm!("csrr $0, sepc" :"=r"(rval));
llvm_asm!("csrr $0, sepc" :"=r"(rval));
rval
}
}
pub fn satp_write(val: usize) {
unsafe {
asm!("csrw satp, $0" :: "r"(val));
llvm_asm!("csrw satp, $0" :: "r"(val));
}
}
pub fn satp_read() -> usize {
unsafe {
let rval;
asm!("csrr $0, satp" :"=r"(rval));
llvm_asm!("csrr $0, satp" :"=r"(rval));
rval
}
}
@ -216,7 +216,7 @@ pub fn satp_read() -> usize {
/// TLB.
pub fn satp_fence(vaddr: usize, asid: usize) {
unsafe {
asm!("sfence.vma $0, $1" :: "r"(vaddr), "r"(asid));
llvm_asm!("sfence.vma $0, $1" :: "r"(vaddr), "r"(asid));
}
}
@ -229,7 +229,7 @@ pub fn satp_fence(vaddr: usize, asid: usize) {
/// Intel/AMD's invtlb [] instruction.
pub fn satp_fence_asid(asid: usize) {
unsafe {
asm!("sfence.vma zero, $0" :: "r"(asid));
llvm_asm!("sfence.vma zero, $0" :: "r"(asid));
}
}

View File

@ -4,6 +4,7 @@
#![no_main]
#![no_std]
#![feature(panic_info_message,
asm,
llvm_asm,
global_asm,
allocator_api,
@ -68,7 +69,7 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
extern "C" fn abort() -> ! {
loop {
unsafe {
asm!("wfi"::::"volatile");
llvm_asm!("wfi"::::"volatile");
}
}
}

View File

@ -185,7 +185,7 @@ fn init_process() {
// being ran as a kernel process. If we ran this as a
// user process, it'd need a system call to execute a
// privileged instruction.
unsafe { asm!("wfi") };
unsafe { llvm_asm!("wfi") };
}
}
}