-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple ROM test for SoC interface
Create a small ROM image that interacts with the SoC-visible registers. This is useful for running fast tests during initial Caliptra integration into SoCs.
- Loading branch information
Showing
5 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Licensed under the Apache-2.0 license | ||
|
||
#![no_std] | ||
#![no_main] | ||
|
||
core::arch::global_asm!(include_str!("../src/start.S")); | ||
|
||
#[path = "../src/exception.rs"] | ||
mod exception; | ||
|
||
use caliptra_drivers::cprintln; | ||
use caliptra_drivers::ExitCtrl; | ||
|
||
#[no_mangle] | ||
#[inline(never)] | ||
extern "C" fn exception_handler(exception: &exception::ExceptionRecord) { | ||
cprintln!( | ||
"EXCEPTION mcause=0x{:08X} mscause=0x{:08X} mepc=0x{:08X}", | ||
exception.mcause, | ||
exception.mscause, | ||
exception.mepc | ||
); | ||
|
||
ExitCtrl::exit(1); | ||
} | ||
|
||
#[no_mangle] | ||
#[inline(never)] | ||
extern "C" fn nmi_handler(exception: &exception::ExceptionRecord) { | ||
cprintln!( | ||
"NMI mcause=0x{:08X} mscause=0x{:08X} mepc=0x{:08X}", | ||
exception.mcause, | ||
exception.mscause, | ||
exception.mepc | ||
); | ||
|
||
ExitCtrl::exit(1); | ||
} | ||
|
||
#[panic_handler] | ||
#[inline(never)] | ||
#[cfg(not(feature = "std"))] | ||
fn handle_panic(pi: &core::panic::PanicInfo) -> ! { | ||
match pi.location() { | ||
Some(loc) => cprintln!("Panic at file {} line {}", loc.file(), loc.line()), | ||
_ => {} | ||
} | ||
ExitCtrl::exit(1); | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn rom_entry() -> ! { | ||
let mut soc_ifc = unsafe { caliptra_registers::soc_ifc::SocIfcReg::new() }; | ||
|
||
let fuse_wr_done: u32 = soc_ifc.regs_mut().cptra_fuse_wr_done().read().into(); | ||
let valid_pauser: u32 = soc_ifc | ||
.regs_mut() | ||
.cptra_mbox_valid_pauser() | ||
.at(0) | ||
.read() | ||
.into(); | ||
let fuse_life_cycle: u32 = soc_ifc.regs_mut().fuse_life_cycle().read().into(); | ||
|
||
// Print some registers populated by SoC | ||
cprintln!("FUSE_WR_DONE = {}", fuse_wr_done); | ||
cprintln!("VALID_PAUSER[0] = {}", valid_pauser); | ||
cprintln!("FUSE_LIFE_CYCLE = {}", fuse_life_cycle); | ||
|
||
// Write to some registers read by SoC | ||
soc_ifc.regs_mut().cptra_boot_status().write(|_| 0xff); | ||
|
||
ExitCtrl::exit(0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
rom/dev/tests/rom_integration_tests/test_soc_integration.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed under the Apache-2.0 license | ||
|
||
use caliptra_builder::firmware; | ||
use caliptra_hw_model::{BootParams, HwModel, InitParams}; | ||
|
||
#[test] | ||
fn test_soc_integration() { | ||
let rom = caliptra_builder::build_firmware_rom(&firmware::rom_tests::SOC_TESTS).unwrap(); | ||
let mut hw = caliptra_hw_model::new( | ||
InitParams { | ||
rom: &rom, | ||
iccm: &vec![0x55u8; 128 * 1024], | ||
dccm: &vec![0x66u8; 128 * 1024], | ||
..Default::default() | ||
}, | ||
BootParams::default(), | ||
) | ||
.unwrap(); | ||
|
||
let mut output = vec![]; | ||
hw.copy_output_until_exit_success(&mut output).unwrap(); | ||
assert_eq!( | ||
std::str::from_utf8(&output), | ||
Ok("FUSE_WR_DONE = 1\n\ | ||
VALID_PAUSER[0] = 1\n\ | ||
FUSE_LIFE_CYCLE = 0\n") | ||
); | ||
|
||
assert_eq!(hw.soc_ifc().cptra_boot_status().read(), 0xffu32); | ||
} |