Skip to content

Commit

Permalink
add some prelim coreuser test routines
Browse files Browse the repository at this point in the history
these currently only make sense in a simulation environment,
but they allow us to work the significant configuration test
cases for practical execution to make sure we haven't missed
something in the coreuser spec.
  • Loading branch information
bunnie committed Jan 11, 2025
1 parent db83d38 commit cb60120
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
5 changes: 5 additions & 0 deletions loader/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ pub enum IniType {
pub unsafe extern "C" fn rust_entry(signed_buffer: *const usize, signature: u32) -> ! {
#[cfg(all(feature = "cramium-soc", not(feature = "verilator-only")))]
let perclk_freq = crate::platform::early_init(); // sets up PLLs so we're not running at 16MHz...
// need to make this "official" for NTO, the feature flag combo below works around some simulation config
// conflicts.
#[cfg(all(feature = "verilator-only", not(feature = "cramium-mpw")))]
platform::coreuser_config();

#[cfg(not(all(feature = "cramium-soc", not(feature = "verilator-only"))))]
let perclk_freq = 0;

Expand Down
32 changes: 32 additions & 0 deletions loader/src/platform/cramium/cramium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1975,3 +1975,35 @@ pub unsafe fn init_clock_asic_c(freq_hz: u32, duty_sram: u32) -> u32 {

100_000_000 // bodge for now
}

#[cfg(all(feature = "verilator-only", not(feature = "cramium-mpw")))]
pub fn coreuser_config() {
// configure coruser signals. Specific to NTO.
use utra::coreuser::*;
crate::println!("coreuser setup...");
let mut coreuser = CSR::new(utra::coreuser::HW_COREUSER_BASE as *mut u32);
// set to 0 so we can safely mask it later on
coreuser.wo(USERVALUE, 0);
coreuser.rmwf(utra::coreuser::USERVALUE_DEFAULT, 3);
let trusted_asids = [(1, 0), (2, 0), (3, 1), (4, 2), (1, 0), (1, 0), (1, 0), (1, 0)];
let asid_fields = [
(utra::coreuser::MAP_LO_LUT0, utra::coreuser::USERVALUE_USER0),
(utra::coreuser::MAP_LO_LUT1, utra::coreuser::USERVALUE_USER1),
(utra::coreuser::MAP_LO_LUT2, utra::coreuser::USERVALUE_USER2),
(utra::coreuser::MAP_LO_LUT3, utra::coreuser::USERVALUE_USER3),
(utra::coreuser::MAP_HI_LUT4, utra::coreuser::USERVALUE_USER4),
(utra::coreuser::MAP_HI_LUT5, utra::coreuser::USERVALUE_USER5),
(utra::coreuser::MAP_HI_LUT6, utra::coreuser::USERVALUE_USER6),
(utra::coreuser::MAP_HI_LUT7, utra::coreuser::USERVALUE_USER7),
];
for (&(asid, value), (map_field, uservalue_field)) in trusted_asids.iter().zip(asid_fields) {
coreuser.rmwf(map_field, asid);
coreuser.rmwf(uservalue_field, value);
}
coreuser.rmwf(CONTROL_INVERT_PRIV, 1);
coreuser.rmwf(CONTROL_ENABLE, 1);

// turn off updates
coreuser.wo(utra::coreuser::PROTECT, 1);
crate::println!("coreuser locked!");
}
4 changes: 2 additions & 2 deletions loader/src/platform/cramium/link-soc.x
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ SECTIONS
. = ALIGN(4);
_edata = .;
} > REGION_DATA AT > REGION_RODATA

/*
.fonts : ALIGN(65536)
{
KEEP(*(.fontdata));
} > FONTS

*/
.bss (NOLOAD) :
{
_sbss = .;
Expand Down

0 comments on commit cb60120

Please sign in to comment.