chore: irq: rename IRQ_INVALID

This commit is contained in:
Paul Pan 2024-08-05 15:20:21 +08:00
parent 08f9374c8b
commit 6336693e34
3 changed files with 12 additions and 3 deletions

View File

@ -16,7 +16,7 @@ unsafe extern "C" fn _start(hart_id: usize, fdt_addr: usize) -> ! {
// we should be launched by OpenSBI and running is S-mode // we should be launched by OpenSBI and running is S-mode
// 128 KiB stack for debugging only // 128 KiB stack for debugging only
const STACK_SIZE: usize = 4096 * 32; const STACK_SIZE: usize = 4096 * 32; // at least 21, TODO: figure out why we need sooo much stack
#[link_section = ".bss.boot_stack"] #[link_section = ".bss.boot_stack"]
static mut STACK: [u8; STACK_SIZE] = [0u8; STACK_SIZE]; static mut STACK: [u8; STACK_SIZE] = [0u8; STACK_SIZE];

View File

@ -6,7 +6,7 @@ use fdt::{node::FdtNode, Fdt};
use log::trace; use log::trace;
use spin::Mutex; use spin::Mutex;
const IRQ_INVALID: usize = u32::MAX as usize; const IRQ_OCCUPIED: usize = u32::MAX as usize; // OpenSBI will rewrite IRQ_M_EXT to this value
const IRQ_S_EXT: usize = 9; const IRQ_S_EXT: usize = 9;
const IRQ_M_EXT: usize = 11; const IRQ_M_EXT: usize = 11;
@ -62,7 +62,7 @@ impl Driver for IrqPlic {
let phandle = ctx.phandle; // cpu intc let phandle = ctx.phandle; // cpu intc
let irq = ctx.interrupts().next().unwrap(); // IRQ_M_EXT/IRQ_S_EXT let irq = ctx.interrupts().next().unwrap(); // IRQ_M_EXT/IRQ_S_EXT
if irq == IRQ_INVALID { if irq == IRQ_OCCUPIED {
trace!("[IrqPlic] context {} taken by SBI", i); trace!("[IrqPlic] context {} taken by SBI", i);
continue; continue;
} }

View File

@ -23,3 +23,12 @@ pub struct IrqManager {
state: [IrqState; IRQ_NUM], state: [IrqState; IRQ_NUM],
} }
impl IrqManager {
pub fn new() -> Self {
Self {
handler: core::array::from_fn::<_, IRQ_NUM, _>(|_| CapEntry::new(NullCap::mint())),
state: [IrqState::Inactive; IRQ_NUM],
}
}
}