1 use alloc::sync::Arc; 2 use system_error::SystemError; 3 use unified_init::macros::unified_init; 4 5 use crate::{ 6 driver::base::kobject::{KObjType, KObject, KObjectSysFSOps}, 7 filesystem::{ 8 sysfs::{Attribute, AttributeGroup, SysFSOps}, 9 vfs::syscall::ModeType, 10 }, 11 init::initcall::INITCALL_POSTCORE, 12 }; 13 14 /// 中断描述符的kobjtype 15 /// 16 /// https://code.dragonos.org.cn/xref/linux-6.1.9/kernel/irq/irqdesc.c#280 17 #[derive(Debug)] 18 pub(super) struct IrqKObjType; 19 20 impl KObjType for IrqKObjType { 21 fn sysfs_ops(&self) -> Option<&dyn SysFSOps> { 22 Some(&KObjectSysFSOps) 23 } 24 25 fn attribute_groups(&self) -> Option<&'static [&'static dyn AttributeGroup]> { 26 Some(&[&IrqAttrGroup]) 27 } 28 29 fn release(&self, _kobj: Arc<dyn KObject>) { 30 31 // https://code.dragonos.org.cn/xref/linux-6.1.9/kernel/irq/irqdesc.c#428 32 } 33 } 34 35 #[derive(Debug)] 36 struct IrqAttrGroup; 37 38 impl AttributeGroup for IrqAttrGroup { 39 fn name(&self) -> Option<&str> { 40 None 41 } 42 43 fn attrs(&self) -> &[&'static dyn Attribute] { 44 todo!("irq_attr_group.attrs") 45 // todo: https://code.dragonos.org.cn/xref/linux-6.1.9/kernel/irq/irqdesc.c#268 46 } 47 48 fn is_visible( 49 &self, 50 _kobj: Arc<dyn KObject>, 51 attr: &'static dyn Attribute, 52 ) -> Option<ModeType> { 53 Some(attr.mode()) 54 } 55 } 56 57 /// 初始化irq模块在sysfs中的目录 58 /// 59 /// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/kernel/irq/irqdesc.c#313 60 #[unified_init(INITCALL_POSTCORE)] 61 fn irq_sysfs_init() -> Result<(), SystemError> { 62 // todo!("irq_sysfs_init"); 63 kwarn!("Unimplemented: irq_sysfs_init"); 64 Ok(()) 65 } 66