2018-05-18 07:49:27 +04:00
|
|
|
use alloc::String;
|
2018-07-16 20:23:02 +04:00
|
|
|
pub use self::context::*;
|
2018-05-21 12:30:30 +04:00
|
|
|
pub use self::processor::*;
|
2018-06-03 19:05:43 +04:00
|
|
|
use spin::Once;
|
2018-07-16 20:23:02 +04:00
|
|
|
use sync::{SpinNoIrqLock, Mutex, MutexGuard, SpinNoIrq};
|
2018-04-27 19:10:39 +04:00
|
|
|
|
2018-07-16 20:23:02 +04:00
|
|
|
mod context;
|
2018-04-27 19:10:39 +04:00
|
|
|
mod processor;
|
2018-05-23 07:20:36 +04:00
|
|
|
mod scheduler;
|
2018-04-27 19:10:39 +04:00
|
|
|
|
2018-07-12 08:13:39 +04:00
|
|
|
pub fn init() {
|
2018-07-16 20:23:02 +04:00
|
|
|
PROCESSOR.call_once(||
|
|
|
|
SpinNoIrqLock::new(Processor::new(unsafe { Context::new_init() }))
|
|
|
|
);
|
2018-04-27 19:10:39 +04:00
|
|
|
}
|
|
|
|
|
2018-05-31 18:22:19 +04:00
|
|
|
pub static PROCESSOR: Once<SpinNoIrqLock<Processor>> = Once::new();
|
2018-04-27 19:10:39 +04:00
|
|
|
|
2018-07-16 20:23:02 +04:00
|
|
|
pub fn processor() -> MutexGuard<'static, Processor, SpinNoIrq> {
|
|
|
|
PROCESSOR.try().unwrap().lock()
|
2018-04-27 19:10:39 +04:00
|
|
|
}
|