mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 01:35:19 +08:00
feat: kernel/plat/irq: wire up dispatch
This commit is contained in:
parent
6bbc889d7f
commit
a867e77e3c
@ -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");
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user