1
0
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:
Jiajie Chen 2020-07-07 17:12:07 +08:00
parent e554754e79
commit c170eb0414
6 changed files with 26 additions and 2 deletions

View File

@ -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
}

View File

@ -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,
}
}

View File

@ -133,7 +133,7 @@ fn ipi() {
cp0::cause::reset_soft_int1();
}
fn timer() {
pub fn timer() {
super::timer::set_next();
crate::trap::timer();
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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));
}
_ => {