mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-21 23:56:18 +04:00
Fix timer interrupt
This commit is contained in:
parent
e554754e79
commit
c170eb0414
@ -36,3 +36,7 @@ pub fn is_syscall(trap: usize) -> bool {
|
||||
pub fn is_intr(trap: usize) -> bool {
|
||||
IrqMin <= trap && trap <= IrqMax
|
||||
}
|
||||
|
||||
pub fn is_timer_intr(trap: usize) -> bool {
|
||||
trap == Timer
|
||||
}
|
||||
|
@ -28,3 +28,12 @@ pub fn is_intr(trap: usize) -> bool {
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_timer_intr(trap: usize) -> bool {
|
||||
use cp0::cause::Exception as E;
|
||||
let cause = cp0::cause::Cause { bits: trap as u32 };
|
||||
match cause.cause() {
|
||||
E::Interrupt => trap & (1 << 30) != 0,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ fn ipi() {
|
||||
cp0::cause::reset_soft_int1();
|
||||
}
|
||||
|
||||
fn timer() {
|
||||
pub fn timer() {
|
||||
super::timer::set_next();
|
||||
crate::trap::timer();
|
||||
}
|
||||
|
@ -21,3 +21,7 @@ pub fn is_syscall(trap: usize) -> bool {
|
||||
pub fn is_intr(trap: usize) -> bool {
|
||||
IrqMin <= trap && trap <= IrqMax
|
||||
}
|
||||
|
||||
pub fn is_timer_intr(trap: usize) -> bool {
|
||||
trap == Timer
|
||||
}
|
||||
|
@ -57,3 +57,7 @@ pub fn is_syscall(trap: usize) -> bool {
|
||||
pub fn is_intr(trap: usize) -> bool {
|
||||
IrqMin <= trap && trap <= IrqMax
|
||||
}
|
||||
|
||||
pub fn is_timer_intr(trap: usize) -> bool {
|
||||
trap == Timer
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use super::{
|
||||
abi::{self, ProcInitInfo},
|
||||
add_to_process_table, Pid, Process, PROCESSORS,
|
||||
};
|
||||
use crate::arch::interrupt::consts::{is_intr, is_page_fault, is_syscall};
|
||||
use crate::arch::interrupt::consts::{is_intr, is_page_fault, is_syscall, is_timer_intr};
|
||||
use crate::arch::interrupt::{get_trap_num, handle_user_page_fault};
|
||||
use crate::arch::{
|
||||
cpu,
|
||||
@ -520,6 +520,9 @@ pub fn spawn(thread: Arc<Thread>) {
|
||||
_ if is_intr(trap_num) => {
|
||||
crate::arch::interrupt::ack(trap_num);
|
||||
trace!("handle irq {:#x}", trap_num);
|
||||
if is_timer_intr(trap_num) {
|
||||
crate::arch::interrupt::timer();
|
||||
}
|
||||
IRQ_MANAGER.read().try_handle_interrupt(Some(trap_num));
|
||||
}
|
||||
_ => {
|
||||
|
Loading…
Reference in New Issue
Block a user