refactor(domain): move irq tests to separate file, fix MemoryRegion import in platform

This commit is contained in:
2026-10-17 23:54:16 +02:00
parent 328708ed58
commit 8dd36e7d6d
4 changed files with 89 additions and 88 deletions

View File

@@ -0,0 +1,38 @@
use types::id::{IrqId, ThreadId};
use crate::error::KernelError;
#[cfg(test)]
#[path = "tests.rs"]
mod tests;
const MAX_IRQS: usize = 256;
pub struct IrqRoutingTable {
owners: [Option<ThreadId>; MAX_IRQS],
}
impl IrqRoutingTable {
pub fn new() -> Self {
Self {
owners: [None; MAX_IRQS],
}
}
pub fn register(&mut self, irq: IrqId, thread: ThreadId) -> Result<(), KernelError> {
let idx = irq.raw() as usize;
if self.owners[idx].is_some() {
return Err(KernelError::IrqAlreadyOwned(irq));
}
self.owners[idx] = Some(thread);
Ok(())
}
pub fn unregister(&mut self, irq: IrqId) {
self.owners[irq.raw() as usize] = None;
}
pub fn owner(&self, irq: IrqId) -> Option<ThreadId> {
self.owners[irq.raw() as usize]
}
}