You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.1 KiB
Rust
31 lines
1.1 KiB
Rust
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
//
|
|
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
|
|
|
//! 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 cortex_a::regs::*;
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
// 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"),
|
|
}
|
|
}
|