Skip to main content

strat9_bus_drivers/
stm32_firewall.rs

1/*
2 * This file is part of strat9-os.
3 *
4 * strat9-os is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * strat9-os is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with strat9-os. If not, see <https://www.gnu.org/licenses/>.
16 *
17 * Website: https://www.strat9-os.org
18 * Repository: https://github.com/strat9-os/strat9-os
19 *
20 * Copyright (C) 2023-26 Guillaume Gielly
21 */
22
23use crate::BusError;
24use alloc::{string::String, vec::Vec};
25
26#[derive(Debug, Clone, Copy, PartialEq, Eq)]
27pub enum FirewallType {
28    Peripheral,
29    Memory,
30    NoType,
31}
32
33pub struct FirewallEntry {
34    pub firewall_id: u32,
35    pub extra_args: [u32; 4],
36    pub extra_args_count: usize,
37}
38
39pub trait FirewallController: Send + Sync {
40    /// Performs the name operation.
41    fn name(&self) -> &str;
42    /// Performs the firewall type operation.
43    fn firewall_type(&self) -> FirewallType;
44    /// Performs the max entries operation.
45    fn max_entries(&self) -> u32;
46    /// Performs the grant access operation.
47    fn grant_access(&self, firewall_id: u32) -> Result<(), BusError>;
48    /// Performs the release access operation.
49    fn release_access(&self, firewall_id: u32) -> Result<(), BusError>;
50    /// Performs the grant memory range operation.
51    fn grant_memory_range(&self, _start: u64, _size: u64) -> Result<(), BusError> {
52        Err(BusError::NotSupported)
53    }
54}