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.

49 lines
1.5 KiB
Rust

4 years ago
// SPDX-License-Identifier: MIT OR Apache-2.0
//
2 years ago
// Copyright (c) 2020-2022 Andre Richter <andre.o.richter@gmail.com>
4 years ago
//! Synchronous and asynchronous exception handling.
4 years ago
#[cfg(target_arch = "aarch64")]
#[path = "_arch/aarch64/exception.rs"]
mod arch_exception;
4 years ago
pub mod asynchronous;
4 years ago
//--------------------------------------------------------------------------------------------------
// Architectural Public Reexports
//--------------------------------------------------------------------------------------------------
pub use arch_exception::{current_privilege_level, handling_init};
//--------------------------------------------------------------------------------------------------
// Public Definitions
//--------------------------------------------------------------------------------------------------
/// Kernel privilege levels.
4 years ago
#[allow(missing_docs)]
#[derive(Eq, PartialEq)]
4 years ago
pub enum PrivilegeLevel {
User,
Kernel,
Hypervisor,
Unknown,
}
//--------------------------------------------------------------------------------------------------
// Testing
//--------------------------------------------------------------------------------------------------
#[cfg(test)]
mod tests {
use super::*;
use test_macros::kernel_test;
/// Libkernel unit tests must execute in kernel mode.
#[kernel_test]
fn test_runner_executes_in_kernel_mode() {
let (level, _) = current_privilege_level();
4 years ago
assert!(level == PrivilegeLevel::Kernel)
}
}