xref: /DragonOS/kernel/src/driver/base/firmware.rs (revision c635d8a9cfe25bc11779f323ef0c7d7a0f597d4a)
1 use alloc::{string::ToString, sync::Arc};
2 
3 use system_error::SystemError;
4 
5 use super::kset::KSet;
6 
7 /// `/sys/firmware`的kset
8 static mut FIRMWARE_KSET_INSTANCE: Option<Arc<KSet>> = None;
9 
10 #[inline(always)]
11 #[allow(dead_code)]
12 pub fn sys_firmware_kset() -> Arc<KSet> {
13     unsafe { FIRMWARE_KSET_INSTANCE.clone().unwrap() }
14 }
15 
16 /// 初始化`/sys/firmware`的kset
17 pub(super) fn firmware_init() -> Result<(), SystemError> {
18     let firmware_kset = KSet::new("firmware".to_string());
19     firmware_kset
20         .register(None)
21         .expect("register firmware kset failed");
22     unsafe {
23         FIRMWARE_KSET_INSTANCE = Some(firmware_kset);
24     }
25     return Ok(());
26 }
27