// SPDX-License-Identifier: MIT OR Apache-2.0 // // Copyright (c) 2018-2022 Andre Richter //! Architectural asynchronous exception handling. //! //! # Orientation //! //! Since arch modules are imported into generic modules using the path attribute, the path of this //! file is: //! //! crate::exception::asynchronous::arch_asynchronous use aarch64_cpu::registers::*; use tock_registers::interfaces::Readable; //-------------------------------------------------------------------------------------------------- // Private Definitions //-------------------------------------------------------------------------------------------------- trait DaifField { fn daif_field() -> tock_registers::fields::Field; } struct Debug; struct SError; struct IRQ; struct FIQ; //-------------------------------------------------------------------------------------------------- // Private Code //-------------------------------------------------------------------------------------------------- impl DaifField for Debug { fn daif_field() -> tock_registers::fields::Field { DAIF::D } } impl DaifField for SError { fn daif_field() -> tock_registers::fields::Field { DAIF::A } } impl DaifField for IRQ { fn daif_field() -> tock_registers::fields::Field { DAIF::I } } impl DaifField for FIQ { fn daif_field() -> tock_registers::fields::Field { DAIF::F } } fn is_masked() -> bool where T: DaifField, { DAIF.is_set(T::daif_field()) } //-------------------------------------------------------------------------------------------------- // Public Code //-------------------------------------------------------------------------------------------------- /// Print the AArch64 exceptions status. #[rustfmt::skip] pub fn print_state() { use crate::info; let to_mask_str = |x| -> _ { if x { "Masked" } else { "Unmasked" } }; info!(" Debug: {}", to_mask_str(is_masked::())); info!(" SError: {}", to_mask_str(is_masked::())); info!(" IRQ: {}", to_mask_str(is_masked::())); info!(" FIQ: {}", to_mask_str(is_masked::())); }