mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-25 17:33:28 +04:00
Run cargo fmt.
This commit is contained in:
parent
f68cd2486e
commit
95f0cd5b6c
@ -22,15 +22,15 @@ pub mod syscall;
|
|||||||
pub mod timer;
|
pub mod timer;
|
||||||
|
|
||||||
use crate::memory::phys_to_virt;
|
use crate::memory::phys_to_virt;
|
||||||
use core::sync::atomic::{AtomicBool, Ordering, AtomicUsize};
|
use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||||
use riscv::register::sie;
|
use riscv::register::sie;
|
||||||
|
|
||||||
fn start_all_harts(){
|
fn start_all_harts() {
|
||||||
// simply wake up the first 64 harts.
|
// simply wake up the first 64 harts.
|
||||||
use sbi::sbi_hart_start;
|
use sbi::sbi_hart_start;
|
||||||
for i in 0..64{
|
for i in 0..64 {
|
||||||
let ret=sbi_hart_start(i, 0x80200000usize , i);
|
let ret = sbi_hart_start(i, 0x80200000usize, i);
|
||||||
info!("Start {}: {:?}",i,ret);
|
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);
|
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);
|
LOTTERY_HART_ID.store(hartid, Ordering::SeqCst);
|
||||||
start_all_harts();
|
start_all_harts();
|
||||||
}
|
}
|
||||||
@ -57,8 +60,6 @@ pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! {
|
|||||||
}
|
}
|
||||||
crate::logging::init();
|
crate::logging::init();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
trapframe::init();
|
trapframe::init();
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct SBIRet{
|
pub struct SBIRet {
|
||||||
error: isize,
|
error: isize,
|
||||||
value: usize
|
value: usize,
|
||||||
}
|
}
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct SBICall{
|
pub struct SBICall {
|
||||||
eid: usize,
|
eid: usize,
|
||||||
fid: usize
|
fid: usize,
|
||||||
}
|
}
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn sbi_call(which: SBICall, arg0: usize, arg1: usize, arg2: usize) -> SBIRet {
|
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"
|
: "memory"
|
||||||
: "volatile");
|
: "volatile");
|
||||||
}
|
}
|
||||||
SBIRet{
|
SBIRet {
|
||||||
error: ret1,
|
error: ret1,
|
||||||
value: ret2
|
value: ret2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sbi_hart_start(hartid: usize, start_addr: usize, opaque: usize)->SBIRet{
|
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)
|
sbi_call(
|
||||||
|
SBICall {
|
||||||
|
eid: SBI_EID_HSM,
|
||||||
|
fid: SBI_FID_HSM_START,
|
||||||
|
},
|
||||||
|
hartid,
|
||||||
|
start_addr as usize,
|
||||||
|
opaque,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
pub fn sbi_hart_stop()->!{
|
pub fn sbi_hart_stop() -> ! {
|
||||||
sbi_call(SBICall{eid: SBI_EID_HSM, fid: SBI_FID_HSM_STOP}, 0, 0, 0);
|
sbi_call(
|
||||||
|
SBICall {
|
||||||
|
eid: SBI_EID_HSM,
|
||||||
|
fid: SBI_FID_HSM_STOP,
|
||||||
|
},
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
);
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
pub fn sbi_hart_get_status(hartid: usize)->SBIRet{
|
pub fn sbi_hart_get_status(hartid: usize) -> SBIRet {
|
||||||
sbi_call(SBICall{eid: SBI_EID_HSM, fid: SBI_FID_HSM_START}, hartid, 0, 0)
|
sbi_call(
|
||||||
|
SBICall {
|
||||||
|
eid: SBI_EID_HSM,
|
||||||
|
fid: SBI_FID_HSM_START,
|
||||||
|
},
|
||||||
|
hartid,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const SBI_SUCCESS: isize = 0;
|
const SBI_SUCCESS: isize = 0;
|
||||||
const SBI_ERR_FAILED: isize = -1;
|
const SBI_ERR_FAILED: isize = -1;
|
||||||
const SBI_ERR_NOT_SUPPORTED: isize = -2;
|
const SBI_ERR_NOT_SUPPORTED: isize = -2;
|
||||||
@ -56,7 +78,6 @@ const SBI_FID_HSM_STATUS: usize = 2;
|
|||||||
|
|
||||||
/// Legacy calls.
|
/// Legacy calls.
|
||||||
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn sbi_call_legacy(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize {
|
fn sbi_call_legacy(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize {
|
||||||
let ret;
|
let ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user