feat(kernel): ipc cap transfer drops Delegate; one owner per irq line, freed when owner dies

This commit is contained in:
2026-10-27 14:42:28 +01:00
parent 37c482c36c
commit 33e1c849d1
7 changed files with 175 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
use types::{
badge::Badge,
generation::Generation,
id::{IrqId, NotificationId},
id::{IrqId, NotificationId, ProcessId},
};
#[cfg(test)]
@@ -17,6 +17,8 @@ pub struct IrqRoute {
pub notification: NotificationId,
pub generation: Generation,
pub badge: Badge,
/// The process that set the route, and so owns the line.
pub owner: ProcessId,
}
pub struct IrqRoutingTable {
@@ -53,6 +55,15 @@ impl IrqRoutingTable {
}
}
/// Drops every route `owner` set, when it dies.
pub fn clear_owned_by(&mut self, owner: ProcessId) {
for slot in self.routes.iter_mut() {
if slot.is_some_and(|r| r.owner == owner) {
*slot = None;
}
}
}
/// The route for `irq`; `None` for unknown or unrouted lines.
pub fn route(&self, irq: IrqId) -> Option<IrqRoute> {
*self.routes.get(irq.raw() as usize)?

View File

@@ -8,6 +8,7 @@ fn route(n: u16) -> IrqRoute {
notification: NotificationId::from_raw(n),
generation: Generation::initial(),
badge: Badge::new(1 << n),
owner: types::id::ProcessId::from_raw(0),
}
}