Skip to main content

strat9_bus_drivers/
lib.rs

1#![no_std]
2#![feature(alloc_error_handler)]
3#![allow(unused_imports)]
4#![allow(unused_variables)]
5#![allow(dead_code)]
6
7extern crate alloc;
8
9pub mod mmio;
10pub mod probe;
11pub mod scheme;
12
13pub mod arm_cci;
14pub mod arm_integrator_lm;
15pub mod brcmstb_gisb;
16pub mod bt1_apb;
17pub mod bt1_axi;
18pub mod da8xx_mstpri;
19pub mod hisi_lpc;
20pub mod imx_aipstz;
21pub mod imx_weim;
22pub mod intel_ixp4xx_eb;
23pub mod mips_cdmm;
24pub mod moxtet;
25pub mod mvebu_mbus;
26pub mod omap_l3_noc;
27pub mod omap_l3_smx;
28pub mod omap_ocp2scp;
29pub mod qcom_ebi2;
30pub mod qcom_ssc_block_bus;
31pub mod simple_pm_bus;
32pub mod stm32_etzpc;
33pub mod stm32_firewall;
34pub mod stm32_rifsc;
35pub mod sun50i_de2;
36pub mod sunxi_rsb;
37pub mod tegra_aconnect;
38pub mod tegra_gmi;
39pub mod ti_pwmss;
40pub mod ti_sysc;
41pub mod ts_nbus;
42pub mod uniphier_system_bus;
43pub mod vexpress_config;
44
45use alloc::{string::String, vec::Vec};
46
47#[derive(Debug, Clone, Copy, PartialEq, Eq)]
48pub enum BusError {
49    InitFailed,
50    Timeout,
51    InvalidAddress,
52    PermissionDenied,
53    NotSupported,
54    IoError,
55    InvalidArgument,
56    DeviceNotFound,
57    BusFault,
58    SlaveError,
59    ProtocolError,
60}
61
62#[derive(Debug, Clone, Copy, PartialEq, Eq)]
63pub enum PowerState {
64    On,
65    Suspended,
66    Off,
67}
68
69#[derive(Debug, Clone)]
70pub struct BusChild {
71    pub name: String,
72    pub base_addr: u64,
73    pub size: u64,
74}
75
76pub trait BusDriver: Send + Sync {
77    /// Performs the name operation.
78    fn name(&self) -> &str;
79    /// Performs the compatible operation.
80    fn compatible(&self) -> &[&str];
81    /// Performs the init operation.
82    fn init(&mut self, base: usize) -> Result<(), BusError>;
83    /// Performs the shutdown operation.
84    fn shutdown(&mut self) -> Result<(), BusError>;
85    /// Performs the suspend operation.
86    fn suspend(&mut self) -> Result<(), BusError> {
87        Ok(())
88    }
89    /// Performs the resume operation.
90    fn resume(&mut self) -> Result<(), BusError> {
91        Ok(())
92    }
93    /// Reads reg.
94    fn read_reg(&self, offset: usize) -> Result<u32, BusError>;
95    /// Writes reg.
96    fn write_reg(&mut self, offset: usize, value: u32) -> Result<(), BusError>;
97    /// Performs the error count operation.
98    fn error_count(&self) -> u64 {
99        0
100    }
101    /// Performs the children operation.
102    fn children(&self) -> Vec<BusChild> {
103        Vec::new()
104    }
105    /// Handles irq.
106    fn handle_irq(&mut self) -> bool {
107        false
108    }
109}