mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 08:06:17 +04:00
Run cargo fmt.
This commit is contained in:
parent
f68cd2486e
commit
95f0cd5b6c
@ -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();
|
||||
}
|
||||
@ -57,8 +60,6 @@ pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! {
|
||||
}
|
||||
crate::logging::init();
|
||||
|
||||
|
||||
|
||||
unsafe {
|
||||
trapframe::init();
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user