Skip to content

Commit

Permalink
wip: initialize misa register with h mode if available
Browse files Browse the repository at this point in the history
  • Loading branch information
francois141 committed Sep 20, 2024
1 parent d411267 commit c5f8985
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/virt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Firmware Virtualisation
use miralis_core::abi;

use crate::arch::misa::H;
use crate::arch::pmp::pmpcfg;
use crate::arch::{
mie, misa, mstatus, mtvec, parse_mpp_return_mode, satp, Arch, Architecture, Csr,
Expand Down Expand Up @@ -52,11 +53,17 @@ impl VirtContext {
pub const fn new(hart_id: usize, nb_pmp: usize) -> Self {
assert!(nb_pmp <= 64, "Too many PMP registers");

let mut misa_value: usize = 0x0;

if Plat::HAS_H_MODE {
misa_value |= H
}

VirtContext {
host_stack: 0,
regs: [0; 32],
csr: VirtCsr {
misa: 0,
misa: misa_value,
mie: 0,
mip: 0,
mtvec: 0,
Expand Down Expand Up @@ -1157,9 +1164,8 @@ impl HwRegisterContextSetter<Csr> for VirtContext {
// misa shows the extensions available : we cannot have more than possible in hardware
let arch_misa: usize = Arch::read_csr(Csr::Misa);
// Update misa to a legal value
self.csr.misa = (value & arch_misa & misa::MISA_CHANGE_FILTER & !misa::DISABLED)
| misa::MXL
| misa::H;
self.csr.misa =
(value & arch_misa & misa::MISA_CHANGE_FILTER & !misa::DISABLED) | misa::MXL;
}
Csr::Mie => self.csr.mie = value & hw.interrupts & mie::MIE_WRITE_FILTER,
Csr::Mip => {
Expand Down

0 comments on commit c5f8985

Please sign in to comment.