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.
24 lines
946 B
Rust
24 lines
946 B
Rust
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
//
|
|
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
|
|
|
//! Architectural synchronous and asynchronous exception handling.
|
|
|
|
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"),
|
|
}
|
|
}
|