// SPDX-License-Identifier: MIT OR Apache-2.0 // // Copyright (c) 2018-2022 Andre Richter //! Architectural synchronous and asynchronous exception handling. //! //! # Orientation //! //! Since arch modules are imported into generic modules using the path attribute, the path of this //! file is: //! //! crate::exception::arch_exception use aarch64_cpu::registers::*; use tock_registers::interfaces::Readable; //-------------------------------------------------------------------------------------------------- // Public Code //-------------------------------------------------------------------------------------------------- use crate::exception::PrivilegeLevel; /// The processing element's current privilege level. pub fn current_privilege_level() -> (PrivilegeLevel, &'static str) { let el = CurrentEL.read_as_enum(CurrentEL::EL); match el { Some(CurrentEL::EL::Value::EL2) => (PrivilegeLevel::Hypervisor, "EL2"), Some(CurrentEL::EL::Value::EL1) => (PrivilegeLevel::Kernel, "EL1"), Some(CurrentEL::EL::Value::EL0) => (PrivilegeLevel::User, "EL0"), _ => (PrivilegeLevel::Unknown, "Unknown"), } }