xref: /DragonOS/kernel/src/driver/base/platform/platform_device.rs (revision 8d94ea66a3eb3e02039730c8d08e9bead8c344b8)
1 use super::{
2     super::device::{Device, DeviceState},
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     /// @brief: 获取设备匹配表
12     /// @parameter: None
13     /// @return: 设备匹配表
14     fn compatible_table(&self) -> CompatibleTable;
15 
16     /// @brief: 判断设备是否初始化
17     /// @parameter: None
18     /// @return: 如果已经初始化,返回true,否则,返回false
19     fn is_initialized(&self) -> bool;
20 
21     /// @brief: 设置设备状态
22     /// @parameter set_state: 设备状态
23     /// @return: None
24     fn set_state(&self, set_state: DeviceState);
25 
26     /// @brief: 设置platform设备驱动
27     /// @parameter driver: platform设备驱动
28     /// @return: None
29     fn set_driver(&self, driver: Option<Arc<dyn PlatformDriver>>);
30 }
31