xref: /DragonOS/kernel/src/driver/base/platform/platform_device.rs (revision 78bf93f02f84bf5e024ddfb559f040e68ce39ccf)
1 use super::{
2     super::device::{Device, DeviceState, DeviceType},
3     platform_driver::PlatformDriver,
4     CompatibleTable,
5 };
6 use alloc::sync::Arc;
7 
8 /// @brief: 实现该trait的设备实例应挂载在platform总线上,
9 ///         同时应该实现Device trait
10 pub trait PlatformDevice: Device {
11     fn get_type(&self) -> DeviceType {
12         DeviceType::PlatformDev
13     }
14 
15     /// @brief: 获取设备匹配表
16     /// @parameter: None
17     /// @return: 设备匹配表
18     fn get_compatible_table(&self) -> CompatibleTable;
19 
20     /// @brief: 判断设备是否初始化
21     /// @parameter: None
22     /// @return: 如果已经初始化,返回true,否则,返回false
23     fn is_initialized(&self) -> bool;
24 
25     /// @brief: 设置设备状态
26     /// @parameter set_state: 设备状态
27     /// @return: None
28     fn set_state(&self, set_state: DeviceState);
29 
30     /// @brief: 设置platform设备驱动
31     /// @parameter driver: platform设备驱动
32     /// @return: None
33     fn set_driver(&self, driver: Option<Arc<dyn PlatformDriver>>);
34 }
35