fdt_parser/cache/node/
interrupt_controller.rs1use core::{fmt::Debug, ops::Deref};
2
3use crate::{cache::node::NodeBase, FdtError};
4
5#[derive(Clone)]
6pub struct InterruptController {
7 node: NodeBase,
8}
9
10impl InterruptController {
11 pub(crate) fn new(node: NodeBase) -> Self {
12 InterruptController { node }
13 }
14
15 pub fn interrupt_cells(&self) -> Result<u32, FdtError> {
17 match self.node.find_property("#interrupt-cells") {
18 Some(prop) => prop.u32(),
19 None => Err(FdtError::PropertyNotFound("#interrupt-cells")),
20 }
21 }
22}
23
24impl Debug for InterruptController {
25 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
26 f.debug_struct("InterruptController")
27 .field("name", &self.node.name())
28 .field("interrupt_cells", &self.interrupt_cells())
29 .finish()
30 }
31}
32
33impl Deref for InterruptController {
34 type Target = NodeBase;
35
36 fn deref(&self) -> &Self::Target {
37 &self.node
38 }
39}