1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-21 23:56:18 +04:00

Run cargo fmt.

This commit is contained in:
gjz010 2021-03-03 14:55:28 +08:00
parent f68cd2486e
commit 95f0cd5b6c
2 changed files with 46 additions and 24 deletions

View File

@ -22,15 +22,15 @@ pub mod syscall;
pub mod timer;
use crate::memory::phys_to_virt;
use core::sync::atomic::{AtomicBool, Ordering, AtomicUsize};
use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use riscv::register::sie;
fn start_all_harts(){
fn start_all_harts() {
// simply wake up the first 64 harts.
use sbi::sbi_hart_start;
for i in 0..64{
let ret=sbi_hart_start(i, 0x80200000usize , i);
info!("Start {}: {:?}",i,ret);
for i in 0..64 {
let ret = sbi_hart_start(i, 0x80200000usize, i);
info!("Start {}: {:?}", i, ret);
}
}
@ -42,7 +42,10 @@ pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! {
cpu::set_cpu_id(hartid);
}
if FIRST_HART.compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst).is_ok(){
if FIRST_HART
.compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
.is_ok()
{
LOTTERY_HART_ID.store(hartid, Ordering::SeqCst);
start_all_harts();
}
@ -56,9 +59,7 @@ pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! {
memory::clear_bss();
}
crate::logging::init();
unsafe {
trapframe::init();
}
@ -76,7 +77,7 @@ pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! {
hartid, device_tree_vaddr
);
AP_CAN_INIT.store(true, Ordering::Relaxed);
crate::kmain();
}

View File

@ -2,14 +2,14 @@
#![allow(dead_code)]
#[derive(Clone, Copy, Debug)]
pub struct SBIRet{
pub struct SBIRet {
error: isize,
value: usize
value: usize,
}
#[derive(Clone, Copy, Debug)]
pub struct SBICall{
pub struct SBICall {
eid: usize,
fid: usize
fid: usize,
}
#[inline(always)]
fn sbi_call(which: SBICall, arg0: usize, arg1: usize, arg2: usize) -> SBIRet {
@ -22,25 +22,47 @@ fn sbi_call(which: SBICall, arg0: usize, arg1: usize, arg2: usize) -> SBIRet {
: "memory"
: "volatile");
}
SBIRet{
SBIRet {
error: ret1,
value: ret2
value: ret2,
}
}
pub fn sbi_hart_start(hartid: usize, start_addr: usize, opaque: usize)->SBIRet{
sbi_call(SBICall{eid: SBI_EID_HSM, fid: SBI_FID_HSM_START}, hartid, start_addr as usize, opaque)
pub fn sbi_hart_start(hartid: usize, start_addr: usize, opaque: usize) -> SBIRet {
sbi_call(
SBICall {
eid: SBI_EID_HSM,
fid: SBI_FID_HSM_START,
},
hartid,
start_addr as usize,
opaque,
)
}
pub fn sbi_hart_stop()->!{
sbi_call(SBICall{eid: SBI_EID_HSM, fid: SBI_FID_HSM_STOP}, 0, 0, 0);
pub fn sbi_hart_stop() -> ! {
sbi_call(
SBICall {
eid: SBI_EID_HSM,
fid: SBI_FID_HSM_STOP,
},
0,
0,
0,
);
unreachable!();
}
pub fn sbi_hart_get_status(hartid: usize)->SBIRet{
sbi_call(SBICall{eid: SBI_EID_HSM, fid: SBI_FID_HSM_START}, hartid, 0, 0)
pub fn sbi_hart_get_status(hartid: usize) -> SBIRet {
sbi_call(
SBICall {
eid: SBI_EID_HSM,
fid: SBI_FID_HSM_START,
},
hartid,
0,
0,
)
}
const SBI_SUCCESS: isize = 0;
const SBI_ERR_FAILED: isize = -1;
const SBI_ERR_NOT_SUPPORTED: isize = -2;
@ -56,7 +78,6 @@ const SBI_FID_HSM_STATUS: usize = 2;
/// Legacy calls.
#[inline(always)]
fn sbi_call_legacy(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize {
let ret;