feat: kernel/plat/irq: wire up dispatch

This commit is contained in:
Paul Pan 2024-08-23 20:52:39 +08:00
parent 6bbc889d7f
commit a867e77e3c
2 changed files with 13 additions and 5 deletions

View File

@ -2,6 +2,7 @@ use crate::arch::riscv::backtrace::read_sp;
use crate::entry::HART_ID;
use crate::objects::*;
use crate::plat::console::CONSOLE;
use crate::plat::irq::IRQ_MANAGER;
use crate::plat::timer::{Timer, TimerOps};
use crate::plat::trap::{Trap, TrapContextOps, TrapOps};
use core::ops::{Index, IndexMut};
@ -96,14 +97,17 @@ impl TrapContextOps for TrapContext {
tcb.do_tick();
}
},
T::Interrupt(I::SupervisorExternal) => {
IRQ_MANAGER.lock().dispatch();
},
T::Interrupt(I::SupervisorSoft) => {
// This should never happen
panic_fatal!("Buggy kernel: supervisor software interrupt triggered");
},
T::Exception(E::UserEnvCall) => {
tcb.handle_syscall();
self.sepc += 4;
},
T::Interrupt(I::SupervisorExternal) => {
// TODO: handle external interrupt, e.g. plic
panic_fatal!("Unhandled External Interrupt");
},
T::Exception(E::InstructionPageFault) | T::Exception(E::LoadPageFault) | T::Exception(E::StorePageFault) => {
if from_kernel {
panic_fatal!("Page Fault in Kernel");

View File

@ -52,7 +52,7 @@ pub struct IrqManager {
state: [IrqState; IRQ_NUM],
}
pub static IRQ_MANAGER: Mutex<Lazy<IrqManager>> = Mutex::new(Lazy::new(IrqManager::new));
pub static IRQ_MANAGER: Lazy<Mutex<IrqManager>> = Lazy::new(|| Mutex::new(IrqManager::new()));
impl IrqManager {
pub fn new() -> Self {
@ -61,4 +61,8 @@ impl IrqManager {
state: [IrqState::Inactive; IRQ_NUM],
}
}
pub fn dispatch(&mut self) {
todo!("forward to endpoint cap");
}
}