mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add legacy_int handler to the kernel, handle vexii init case
The "main" product line is affected here in that the UART init is hosted above the trng init. This should have no impact on security or boot time, but allows us to more easily debug TRNG init issues. This is necessary because in the vexii test version the XADC interface is broken by the slower clocking and I'm not taking the time to trace down that issue as it does nothing to further the goal of testing the vex-ii core in a non-production config. legacy_int handler allows vex-ii to emulate/behave like the vex-i in terms of interrupt handling. eventually this will be replaced with/augmeted by a PLIC.
This commit is contained in:
parent
52abe83b74
commit
1effeab858
2 changed files with 59 additions and 1 deletions
|
|
@ -44,6 +44,7 @@ critical-section = "1.1.1"
|
|||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ci)', 'cfg(baremetal)'] }
|
||||
|
||||
[features]
|
||||
vexii-test = [] # integration test for vexii, not a production configuration
|
||||
cramium-soc = ["utralib/cramium-soc", "rand_chacha", "raw-trng"]
|
||||
verilator-only = []
|
||||
cramium-fpga = ["utralib/cramium-fpga", "rand_chacha"]
|
||||
|
|
|
|||
|
|
@ -9,13 +9,70 @@ pub mod rand;
|
|||
#[cfg(any(feature = "debug-print", feature = "print-panics"))]
|
||||
pub mod uart;
|
||||
|
||||
#[cfg(feature = "vexii-test")]
|
||||
use crate::{MemoryFlags, MemoryType, PID, mem::MemoryManager};
|
||||
#[cfg(feature = "vexii-test")]
|
||||
pub const LEGACY_INT_VMEM: usize = 0xffcf_1000; // see https://github.com/betrusted-io/xous-core/blob/master/docs/memory.md
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[cfg(feature = "vexii-test")]
|
||||
pub mod legacy_int {
|
||||
// this enum is vestigal, and currently not used by anything
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum LegacyIntOffset {
|
||||
MachMask = 0,
|
||||
MachPending = 1,
|
||||
SuperMask = 2,
|
||||
SuperPending = 3,
|
||||
}
|
||||
pub const LEGACY_INT_NUMREGS: usize = 4;
|
||||
|
||||
pub const MACH_MASK: utralib::Register = utralib::Register::new(0, 0xffffffff);
|
||||
pub const MACH_MASK_MACH_MASK: utralib::Field = utralib::Field::new(32, 0, MACH_MASK);
|
||||
|
||||
pub const MACH_PENDING: utralib::Register = utralib::Register::new(1, 0xffffffff);
|
||||
pub const MACH_PENDING_MACH_PENDING: utralib::Field = utralib::Field::new(32, 0, MACH_PENDING);
|
||||
|
||||
pub const SUPER_MASK: utralib::Register = utralib::Register::new(2, 0xffffffff);
|
||||
pub const SUPER_MASK_SUPER_MASK: utralib::Field = utralib::Field::new(32, 0, SUPER_MASK);
|
||||
|
||||
pub const SUPER_PENDING: utralib::Register = utralib::Register::new(3, 0xffffffff);
|
||||
pub const SUPER_PENDING_SUPER_PENDING: utralib::Field = utralib::Field::new(32, 0, SUPER_PENDING);
|
||||
|
||||
pub const HW_LEGACY_INT_BASE: usize = 0xf0010000;
|
||||
}
|
||||
|
||||
/// Precursor specific initialization.
|
||||
pub fn init() {
|
||||
self::rand::init();
|
||||
#[cfg(feature = "vexii-test")]
|
||||
// Map the interrupt manager shim
|
||||
MemoryManager::with_mut(|memory_manager| {
|
||||
memory_manager
|
||||
.map_range(
|
||||
legacy_int::HW_LEGACY_INT_BASE as *mut u8,
|
||||
(LEGACY_INT_VMEM & !4095) as *mut u8,
|
||||
4096,
|
||||
PID::new(1).unwrap(),
|
||||
MemoryFlags::R | MemoryFlags::W,
|
||||
MemoryType::Default,
|
||||
)
|
||||
.expect("unable to map legacy interrupt shim for vexii CPU")
|
||||
});
|
||||
|
||||
#[cfg(any(feature = "debug-print", feature = "print-panics"))]
|
||||
self::uart::init();
|
||||
|
||||
// handy routine for oscope debugging of up-ness of the CPU
|
||||
#[cfg(feature = "vexii-test")]
|
||||
let mut uart_csr = utralib::CSR::<u32>::new(0xffcf0000 as *mut u32);
|
||||
#[cfg(feature = "vexii-test")]
|
||||
for _ in 0..100 {
|
||||
uart_csr.wfo(utralib::utra::uart::RXTX_RXTX, 'b' as u32);
|
||||
while uart_csr.r(utralib::utra::uart::TXFULL) != 0 {}
|
||||
}
|
||||
|
||||
self::rand::init();
|
||||
|
||||
#[cfg(feature = "gdb-stub")]
|
||||
crate::debug::gdb::init();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue