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.
45 lines
841 B
Rust
45 lines
841 B
Rust
// SPDX-License-Identifier: MIT
|
|
//
|
|
// Copyright (c) 2018-2019 Andre Richter <andre.o.richter@gmail.com>
|
|
|
|
//! Exception handling.
|
|
|
|
use cortex_a::regs::*;
|
|
|
|
pub trait DaifField {
|
|
fn daif_field() -> register::Field<u32, DAIF::Register>;
|
|
}
|
|
|
|
pub struct Debug;
|
|
pub struct SError;
|
|
pub struct IRQ;
|
|
pub struct FIQ;
|
|
|
|
impl DaifField for Debug {
|
|
fn daif_field() -> register::Field<u32, DAIF::Register> {
|
|
DAIF::D
|
|
}
|
|
}
|
|
|
|
impl DaifField for SError {
|
|
fn daif_field() -> register::Field<u32, DAIF::Register> {
|
|
DAIF::A
|
|
}
|
|
}
|
|
|
|
impl DaifField for IRQ {
|
|
fn daif_field() -> register::Field<u32, DAIF::Register> {
|
|
DAIF::I
|
|
}
|
|
}
|
|
|
|
impl DaifField for FIQ {
|
|
fn daif_field() -> register::Field<u32, DAIF::Register> {
|
|
DAIF::F
|
|
}
|
|
}
|
|
|
|
pub fn is_masked<T: DaifField>() -> bool {
|
|
DAIF.is_set(T::daif_field())
|
|
}
|