1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-27 02:03:29 +04:00
rCore/kernel/src/trap.rs

27 lines
533 B
Rust
Raw Normal View History

2018-11-19 13:21:06 +04:00
use crate::process::*;
use crate::arch::interrupt::TrapFrame;
use crate::arch::cpu;
use log::*;
2018-10-25 20:49:19 +04:00
pub static mut TICK: usize = 0;
pub fn timer() {
2018-10-25 20:49:19 +04:00
if cpu::id() == 0 {
unsafe { TICK += 1; }
}
2018-11-02 12:36:46 +04:00
processor().tick();
}
2018-07-17 08:07:21 +04:00
pub fn error(tf: &TrapFrame) -> ! {
2018-10-26 19:43:12 +04:00
error!("{:#x?}", tf);
let pid = processor().pid();
2018-10-26 19:43:12 +04:00
error!("On CPU{} Process {}", cpu::id(), pid);
2018-10-25 20:49:19 +04:00
processor().manager().exit(pid, 0x100);
processor().yield_now();
unreachable!();
2018-11-02 12:36:46 +04:00
}
pub fn serial(c: char) {
2018-11-19 13:21:06 +04:00
crate::fs::STDIN.push(c);
}