fix format issue
diff --git a/target/ast10x0/peripherals/spimonitor/controller.rs b/target/ast10x0/peripherals/spimonitor/controller.rs index 777eee0..39b1a1e 100644 --- a/target/ast10x0/peripherals/spimonitor/controller.rs +++ b/target/ast10x0/peripherals/spimonitor/controller.rs
@@ -142,14 +142,16 @@ /// /// Mirrors Zephyr's `spim_monitor_enable(dev, true)`. pub fn enable(&self) { - self.regs.modify_ctrl(|bits| *bits |= CTRL_MONITOR_ENABLE_BIT); + self.regs + .modify_ctrl(|bits| *bits |= CTRL_MONITOR_ENABLE_BIT); } /// Disable the monitor filter (SPIPF000 bit 0). /// /// Mirrors Zephyr's `spim_monitor_enable(dev, false)`. pub fn disable(&self) { - self.regs.modify_ctrl(|bits| *bits &= !CTRL_MONITOR_ENABLE_BIT); + self.regs + .modify_ctrl(|bits| *bits &= !CTRL_MONITOR_ENABLE_BIT); } /// Configure passthrough mode (SPIPF000 passthrough bit). @@ -172,19 +174,19 @@ /// for each SPIPF instance, following the aspeed-rust pattern. pub fn set_ext_mux(&self, sel: ExtMuxSel) { use crate::scu::types::{ScuExtMuxSelect, SpiMonitorInstance}; - + let mux_sel = match sel { ExtMuxSel::Sel0 => ScuExtMuxSelect::Mux0, ExtMuxSel::Sel1 => ScuExtMuxSelect::Mux1, }; - + let instance = match self.controller { SpiMonitorController::Spim0 => SpiMonitorInstance::Spim0, SpiMonitorController::Spim1 => SpiMonitorInstance::Spim1, SpiMonitorController::Spim2 => SpiMonitorInstance::Spim2, SpiMonitorController::Spim3 => SpiMonitorInstance::Spim3, }; - + self.scu.set_spim_ext_mux(instance, mux_sel); } @@ -328,19 +330,19 @@ /// Confirmed from aspeed-rust implementation (src/spimonitor/hardware.rs). /// Register field names from ast1060_pac provide safe typed accessors. const CTRL_MONITOR_ENABLE_BIT: u32 = 1 << 0; // enbl_filter_fn() in SPIPF000[0] -const CTRL_PASSTHROUGH_BIT: u32 = 1 << 1; // enbl_single_bit_passthrough() in SPIPF000[1] +const CTRL_PASSTHROUGH_BIT: u32 = 1 << 1; // enbl_single_bit_passthrough() in SPIPF000[1] #[allow(dead_code)] -const CTRL_SW_RESET_BIT: u32 = 1 << 0; // sweng_rst() in SPIPF000[?] - uses PAC field +const CTRL_SW_RESET_BIT: u32 = 1 << 0; // sweng_rst() in SPIPF000[?] - uses PAC field #[allow(dead_code)] -const CTRL_EXT_MUX_SEL_BIT: u32 = 1 << 2; // PLACEHOLDER - NOT in SPIPF000! See note below. +const CTRL_EXT_MUX_SEL_BIT: u32 = 1 << 2; // PLACEHOLDER - NOT in SPIPF000! See note below. #[allow(dead_code)] -const CTRL_LOCK_BIT: u32 = 1 << 31; // PLACEHOLDER - NOT in SPIPF000! See note below. -// -// NOTE: CTRL_EXT_MUX_SEL and CTRL_LOCK are NOT in SPIPF000 register: -// - ExtMux is controlled via SCU0F0 register (ext_mux_select_sig_of_spipfN bits) -// See aspeed-rust: spim_ext_mux_config() -// - Lock is controlled via SPIPF07C write-disable bits and individual command -// table entry lock bits. See aspeed-rust: spim_lock_common(), spim_lock_rw_priv_table() +const CTRL_LOCK_BIT: u32 = 1 << 31; // PLACEHOLDER - NOT in SPIPF000! See note below. + // + // NOTE: CTRL_EXT_MUX_SEL and CTRL_LOCK are NOT in SPIPF000 register: + // - ExtMux is controlled via SCU0F0 register (ext_mux_select_sig_of_spipfN bits) + // See aspeed-rust: spim_ext_mux_config() + // - Lock is controlled via SPIPF07C write-disable bits and individual command + // table entry lock bits. See aspeed-rust: spim_lock_common(), spim_lock_rw_priv_table() /// Shared drain-log implementation used by both `Configured` and `Locked`. fn drain_log_impl<'a>( @@ -357,9 +359,7 @@ for i in 0..count { // SAFETY: log_base is a hardware RAM address validated by the PAC // base-address mapping. Offset stays within [0, max_entries) words. - let word = unsafe { - core::ptr::read_volatile((log_base as *const u32).add(i)) - }; + let word = unsafe { core::ptr::read_volatile((log_base as *const u32).add(i)) }; buf[i] = ViolationLogEntry::parse(word); }
diff --git a/target/ast10x0/peripherals/spimonitor/mod.rs b/target/ast10x0/peripherals/spimonitor/mod.rs index 049a4a8..8f649e1 100644 --- a/target/ast10x0/peripherals/spimonitor/mod.rs +++ b/target/ast10x0/peripherals/spimonitor/mod.rs
@@ -3,25 +3,25 @@ //! AST10x0 SPI monitor (SPIPF) module. -pub mod registers; -pub mod types; +pub mod controller; pub mod policy; pub mod profile; -pub mod controller; +pub mod registers; pub mod traits; +pub mod types; +pub use controller::{ + Configured, ConfiguredSpiMonitor, Locked, LockedSpiMonitor, SpiMonitor, UninitSpiMonitor, + Uninitialized, +}; +pub use policy::{MonitorPolicy, MAX_CMD_SLOTS, MAX_REGION_SLOTS}; pub use registers::{ SpiMonitorController, SpiMonitorRegisters, SPIPF1_BASE, SPIPF2_BASE, SPIPF3_BASE, SPIPF4_BASE, SPIPF_REG_SIZE, }; +pub use traits::Monitor; pub use types::{ BootConfig, BootError, BootPhase, BootResult, ExtMuxSel, LockState, MonitorInstance, MonitorState, MonitorStatus, MuxSelect, PassthroughMode, PrivilegeDirection, PrivilegeOp, RegionPolicy, Result as SpiMonitorResult, SpiMonitorError, ViolationLogEntry, }; -pub use policy::{MonitorPolicy, MAX_CMD_SLOTS, MAX_REGION_SLOTS}; -pub use controller::{ - Configured, ConfiguredSpiMonitor, Locked, LockedSpiMonitor, SpiMonitor, Uninitialized, - UninitSpiMonitor, -}; -pub use traits::Monitor;
diff --git a/target/ast10x0/peripherals/spimonitor/policy.rs b/target/ast10x0/peripherals/spimonitor/policy.rs index f6e5117..fee1082 100644 --- a/target/ast10x0/peripherals/spimonitor/policy.rs +++ b/target/ast10x0/peripherals/spimonitor/policy.rs
@@ -42,7 +42,12 @@ if self.region_count >= MAX_REGION_SLOTS { return false; } - self.regions[self.region_count] = Some(RegionPolicy { start, length, direction, op }); + self.regions[self.region_count] = Some(RegionPolicy { + start, + length, + direction, + op, + }); self.region_count += 1; true }
diff --git a/target/ast10x0/peripherals/spimonitor/traits.rs b/target/ast10x0/peripherals/spimonitor/traits.rs index ca95e57..af455d6 100644 --- a/target/ast10x0/peripherals/spimonitor/traits.rs +++ b/target/ast10x0/peripherals/spimonitor/traits.rs
@@ -7,8 +7,8 @@ //! with SPI monitor hardware during platform initialization. use super::types::{ - BootError, BootResult, MuxSelect, MonitorInstance, MonitorStatus, - PrivilegeDirection, PrivilegeOp, + BootError, BootResult, MonitorInstance, MonitorStatus, MuxSelect, PrivilegeDirection, + PrivilegeOp, }; /// Abstract hardware interface for SPI monitor boot operations. @@ -89,14 +89,8 @@ #[test] fn test_mux_select_conversion() { - assert_eq!( - ExtMuxSel::from(MuxSelect::RotControl), - ExtMuxSel::Sel0 - ); - assert_eq!( - ExtMuxSel::from(MuxSelect::HostControl), - ExtMuxSel::Sel1 - ); + assert_eq!(ExtMuxSel::from(MuxSelect::RotControl), ExtMuxSel::Sel0); + assert_eq!(ExtMuxSel::from(MuxSelect::HostControl), ExtMuxSel::Sel1); } #[test]
diff --git a/target/ast10x0/peripherals/spimonitor/types.rs b/target/ast10x0/peripherals/spimonitor/types.rs index 43150c0..4be2d82 100644 --- a/target/ast10x0/peripherals/spimonitor/types.rs +++ b/target/ast10x0/peripherals/spimonitor/types.rs
@@ -72,13 +72,23 @@ /// Construct a region that grants access in the given direction. #[must_use] pub const fn allow(start: u32, length: u32, direction: PrivilegeDirection) -> Self { - Self { start, length, direction, op: PrivilegeOp::Enable } + Self { + start, + length, + direction, + op: PrivilegeOp::Enable, + } } /// Construct a region that denies access in the given direction. #[must_use] pub const fn deny(start: u32, length: u32, direction: PrivilegeDirection) -> Self { - Self { start, length, direction, op: PrivilegeOp::Disable } + Self { + start, + length, + direction, + op: PrivilegeOp::Disable, + } } }