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)] sys_firmware_kset() -> Arc<KSet>12pub fn sys_firmware_kset() -> Arc<KSet> { 13 unsafe { FIRMWARE_KSET_INSTANCE.clone().unwrap() } 14 } 15 16 /// 初始化`/sys/firmware`的kset firmware_init() -> Result<(), SystemError>17pub(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