Skip to content

Commit

Permalink
cpu: Add module for dealing with interrupt related CSR
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Heymans <[email protected]>
  • Loading branch information
ArthurHeymans authored and jhand2 committed Feb 5, 2024
1 parent 1858eca commit 67baa9c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cpu/src/csr.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed under the Apache-2.0 license

// Standard RISC-V MIE CSR
#[cfg(feature = "riscv")]
pub fn mie_enable_external_interrupts() {
const MEIE: usize = 1 << 11;
unsafe {
core::arch::asm!("csrrs zero, mie, {r}", r = in(reg) MEIE);
}
}

// VeeR EL2 PRM 5.5.1 Power Management Control Register
// If bit 1 is set, setting bit0 globally enables interrupts, i.e. MIE in mstatus CSR
#[cfg(feature = "riscv")]
pub fn mpmc_halt() {
const HALT: usize = 1 << 0;
unsafe {
core::arch::asm!("csrrs zero, 0x7c6, {r}", r = in(reg) HALT);
}
}
1 change: 1 addition & 0 deletions cpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ core::arch::global_asm!(include_str!("nmi.S"));
#[cfg(feature = "riscv")]
core::arch::global_asm!(include_str!("trap.S"));

pub mod csr;
pub mod trap;

use caliptra_registers::soc_ifc::SocIfcReg;
Expand Down

0 comments on commit 67baa9c

Please sign in to comment.