mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +00:00
commit
89ebd5d6e2
19 changed files with 14056 additions and 12626 deletions
|
|
@ -45,8 +45,8 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ci)', 'cfg(baremetal)'] }
|
|||
|
||||
[features]
|
||||
cramium-soc = ["utralib/cramium-soc", "cramium-hal", "rand_chacha", "raw-trng"]
|
||||
verilator-only = ["cramium-hal/verilator-only"]
|
||||
cramium-fpga = ["utralib/cramium-fpga"]
|
||||
verilator-only = []
|
||||
cramium-fpga = ["utralib/cramium-fpga", "rand_chacha"]
|
||||
board-baosec = ["cramium-hal/board-baosec"]
|
||||
board-baosor = ["cramium-hal/board-baosor"]
|
||||
board-dabao = ["cramium-hal/board-dabao"]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
// SPDX-FileCopyrightText: 2023 Foundation Devices, Inc. <hello@foundationdevices.com>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// allow all functions to go unused in case debug is disabled with a feature flag
|
||||
#![allow(dead_code)]
|
||||
|
||||
use core::fmt;
|
||||
|
||||
use crate::{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,13 @@
|
|||
// SPDX-FileCopyrightText: 2024 bunnie <bunnie@kosagi.com>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
pub mod rand;
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
pub mod rand_fake;
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
pub use rand_fake as rand;
|
||||
|
||||
#[cfg(any(feature = "debug-print", feature = "print-panics"))]
|
||||
pub mod uart;
|
||||
|
||||
|
|
|
|||
63
kernel/src/platform/cramium/rand_fake.rs
Normal file
63
kernel/src/platform/cramium/rand_fake.rs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
// SPDX-FileCopyrightText: 2020 Sean Cross <sean@xobs.io>
|
||||
// SPDX-FileCopyrightText: 2022 Foundation Devices, Inc. <hello@foundationdevices.com>
|
||||
// SPDX-FileCopyrightText: 2024 bunnie <bunnie@kosagi.com>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use core::convert::TryInto;
|
||||
use core::sync::atomic::{AtomicU32, Ordering};
|
||||
|
||||
use rand_chacha::ChaCha8Rng;
|
||||
use rand_chacha::rand_core::RngCore;
|
||||
use rand_chacha::rand_core::SeedableRng;
|
||||
|
||||
// This is the sum total of state used for simulations
|
||||
static LOCAL_RNG_STATE: [AtomicU32; 8] = [
|
||||
AtomicU32::new(0),
|
||||
AtomicU32::new(0),
|
||||
AtomicU32::new(0),
|
||||
AtomicU32::new(0),
|
||||
AtomicU32::new(0),
|
||||
AtomicU32::new(0),
|
||||
AtomicU32::new(0),
|
||||
AtomicU32::new(1),
|
||||
];
|
||||
|
||||
pub fn init() {}
|
||||
|
||||
/// This a fully deterministic PRNG that relies on Chacha8 for state evolution.
|
||||
pub fn get_u32() -> u32 {
|
||||
// Local storage for the seed.
|
||||
let mut seed = [0u8; 32];
|
||||
|
||||
// Pull our true seed data from the static AtomicU32 variables. We have to do this because
|
||||
// we're the kernel: any machine persistent state is by definition, global mutable state.
|
||||
//
|
||||
// Mix in more data from the TRNG while recovering the state from the kernel holding area.
|
||||
for (s, state) in seed.chunks_mut(4).zip(LOCAL_RNG_STATE.iter()) {
|
||||
let incoming = get_raw_u32() ^ state.load(Ordering::SeqCst);
|
||||
for (s_byte, &incoming_byte) in s.iter_mut().zip(incoming.to_le_bytes().iter()) {
|
||||
*s_byte ^= incoming_byte;
|
||||
}
|
||||
}
|
||||
let mut cstrng = ChaCha8Rng::from_seed(seed);
|
||||
// Mix up the internal state with output from the CSPRNG. We do this because the TRNG bits
|
||||
// could be biased, and by running the CSPRNG forward based on the new seed, we have a chance to
|
||||
// diffuse any true entropy over all bits in the seed pool.
|
||||
for s in seed.chunks_mut(8) {
|
||||
for (s_byte, chacha_byte) in s.iter_mut().zip(cstrng.next_u64().to_le_bytes()) {
|
||||
*s_byte ^= chacha_byte;
|
||||
}
|
||||
}
|
||||
// Now extract one value from the CSPRNG: this is the number we reveal to the outside world.
|
||||
// It should not, in theory, be possible to deduce the seed from this value.
|
||||
let ret_val = cstrng.next_u32();
|
||||
|
||||
// Save the mixed state into the kernel holding area
|
||||
for (s, state) in seed.chunks(4).zip(LOCAL_RNG_STATE.iter()) {
|
||||
state.store(u32::from_le_bytes(s.try_into().unwrap()), Ordering::SeqCst);
|
||||
}
|
||||
ret_val
|
||||
}
|
||||
|
||||
/// There is no TRNG in simulation, just return a constant and rely on the chacha8 whitener
|
||||
pub fn get_raw_u32() -> u32 { 0 }
|
||||
|
|
@ -6,16 +6,13 @@
|
|||
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
|
||||
#![allow(static_mut_refs)]
|
||||
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
use utralib::generated::*;
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
use xous_kernel::{MemoryFlags, MemoryType};
|
||||
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
use crate::{
|
||||
PID,
|
||||
debug::shell::process_characters,
|
||||
io::{SerialRead, SerialWrite},
|
||||
mem::MemoryManager,
|
||||
};
|
||||
use crate::io::{SerialRead, SerialWrite};
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
use crate::{
|
||||
PID,
|
||||
|
|
@ -27,117 +24,44 @@ use crate::{
|
|||
/// UART virtual address.
|
||||
///
|
||||
/// See https://github.com/betrusted-io/xous-core/blob/master/docs/memory.md
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
pub const UART_ADDR: usize = 0xffcf_0000;
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
pub const IRQ0_ADDR: usize = UART_ADDR + 0x1000;
|
||||
|
||||
/// UART instance.
|
||||
///
|
||||
/// Initialized by [`init`].
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
pub static mut UART: Option<Uart> = None;
|
||||
|
||||
/// UART peripheral driver.
|
||||
/// All dummy stubs for cramium-fpga because we want the console to have the DUART
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
pub struct Uart {
|
||||
uart_csr: CSR<u32>,
|
||||
irq_csr: CSR<u32>,
|
||||
callback: fn(&mut Self),
|
||||
}
|
||||
pub fn init() {}
|
||||
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
pub struct Uart {}
|
||||
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
#[allow(dead_code)]
|
||||
impl Uart {
|
||||
pub fn new(addr: usize, irq_addr: usize, callback: fn(&mut Self)) -> Uart {
|
||||
Uart { uart_csr: CSR::new(addr as *mut u32), irq_csr: CSR::new(irq_addr as *mut u32), callback }
|
||||
}
|
||||
pub fn new(_addr: usize, _irq_addr: usize, _callback: fn(&mut Self)) -> Uart { Uart {} }
|
||||
|
||||
pub fn init(&mut self) {
|
||||
self.uart_csr.rmwf(utra::uart::EV_ENABLE_RX, 1);
|
||||
self.irq_csr.rmwf(utra::irqarray0::EV_ENABLE_SOURCE0, 1);
|
||||
}
|
||||
|
||||
pub fn irq(_irq_number: usize, arg: *mut usize) {
|
||||
let uart = unsafe { &mut *(arg as *mut Uart) };
|
||||
(uart.callback)(uart);
|
||||
// uart.acknowledge_irq();
|
||||
}
|
||||
pub fn init(&mut self) {}
|
||||
}
|
||||
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
impl SerialWrite for Uart {
|
||||
fn putc(&mut self, c: u8) {
|
||||
// Wait until TXFULL is `0`
|
||||
while self.uart_csr.r(utra::uart::TXFULL) != 0 {}
|
||||
self.uart_csr.wfo(utra::uart::RXTX_RXTX, c as u32);
|
||||
}
|
||||
fn putc(&mut self, _c: u8) {}
|
||||
}
|
||||
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
impl SerialRead for Uart {
|
||||
fn getc(&mut self) -> Option<u8> {
|
||||
// If EV_PENDING_RX is 1, return the pending character.
|
||||
// Otherwise, return None.
|
||||
match self.uart_csr.rf(utra::uart::EV_PENDING_RX) {
|
||||
0 => None,
|
||||
_ => {
|
||||
let ret = Some(self.uart_csr.r(utra::uart::RXTX) as u8);
|
||||
self.uart_csr.wfo(utra::uart::EV_PENDING_RX, 1);
|
||||
self.irq_csr.wfo(utra::irqarray0::EV_PENDING_SOURCE0, 1);
|
||||
ret
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialize UART driver and debug shell.
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
pub fn init() {
|
||||
// Map the UART peripheral.
|
||||
MemoryManager::with_mut(|memory_manager| {
|
||||
memory_manager
|
||||
.map_range(
|
||||
utra::uart::HW_UART_BASE as *mut u8,
|
||||
(UART_ADDR & !4095) as *mut u8,
|
||||
4096,
|
||||
PID::new(1).unwrap(),
|
||||
MemoryFlags::R | MemoryFlags::W,
|
||||
MemoryType::Default,
|
||||
)
|
||||
.expect("unable to map serial port")
|
||||
});
|
||||
// Map the IRQ0 handler
|
||||
MemoryManager::with_mut(|memory_manager| {
|
||||
memory_manager
|
||||
.map_range(
|
||||
utra::irqarray0::HW_IRQARRAY0_BASE as *mut u8,
|
||||
(IRQ0_ADDR & !4095) as *mut u8,
|
||||
4096,
|
||||
PID::new(1).unwrap(),
|
||||
MemoryFlags::R | MemoryFlags::W,
|
||||
MemoryType::Default,
|
||||
)
|
||||
.expect("unable to map serial port")
|
||||
});
|
||||
|
||||
let mut uart = Uart::new(UART_ADDR, IRQ0_ADDR, process_characters);
|
||||
uart.init();
|
||||
|
||||
unsafe {
|
||||
UART = Some(uart);
|
||||
crate::debug::shell::init((&mut *(&raw mut UART)).as_mut().unwrap());
|
||||
|
||||
// Claim UART interrupt.
|
||||
println!("Claiming IRQ {} via syscall...", utra::uart::UART_IRQ);
|
||||
xous_kernel::claim_interrupt(
|
||||
utra::uart::UART_IRQ,
|
||||
Uart::irq,
|
||||
((&mut *(&raw mut UART)).as_mut().unwrap() as *mut Uart) as *mut usize,
|
||||
)
|
||||
.expect("Couldn't claim debug interrupt");
|
||||
}
|
||||
fn getc(&mut self) -> Option<u8> { None }
|
||||
}
|
||||
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
pub fn init() {
|
||||
// there is no kernel UART yet...just a placeholder function
|
||||
// Map the UART peripheral.
|
||||
MemoryManager::with_mut(|memory_manager| {
|
||||
memory_manager
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ board-baosec = [
|
|||
]
|
||||
board-baosor = ["cramium-hal/board-baosor"]
|
||||
board-dabao = ["cramium-hal/board-dabao"]
|
||||
cramium-fpga = ["utralib/cramium-fpga", "debug-print", "cramium-hal"]
|
||||
cramium-fpga = ["utralib/cramium-fpga", "debug-print"]
|
||||
atsama5d27 = ["utralib/atsama5d27", "armv7", "dep:atsama5d27"]
|
||||
|
||||
# precursor flags
|
||||
|
|
|
|||
|
|
@ -141,7 +141,8 @@ fn boot_sequence(args: KernelArguments, _signature: u32, fs_prehash: [u8; 64], _
|
|||
println!("No suspend marker found, doing a cold boot!");
|
||||
#[cfg(feature = "simulation-only")]
|
||||
println!("Configured for simulation. Skipping RAM clear!");
|
||||
#[cfg(not(feature = "cramium-soc"))] // cramium-soc target clears RAM with assembly routine on boot
|
||||
#[cfg(not(any(feature = "cramium-soc", feature = "cramium-fpga")))]
|
||||
// cramium target clears RAM with assembly routine on boot
|
||||
clear_ram(&mut cfg);
|
||||
phase_1(&mut cfg);
|
||||
phase_2(&mut cfg, &fs_prehash);
|
||||
|
|
@ -287,7 +288,7 @@ fn boot_sequence(args: KernelArguments, _signature: u32, fs_prehash: [u8; 64], _
|
|||
|
||||
#[cfg(not(feature = "atsama5d27"))]
|
||||
{
|
||||
#[cfg(not(feature = "cramium-soc"))]
|
||||
#[cfg(not(any(feature = "cramium-soc", feature = "cramium-fpga")))]
|
||||
{
|
||||
// uart mux only exists on the FPGA variant
|
||||
use utralib::generated::*;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
use cramium_hal::axp2101::Axp2101;
|
||||
#[cfg(not(feature = "verilator-only"))]
|
||||
use cramium_hal::iox::{Iox, IoxDir, IoxEnable, IoxFunction, IoxPort};
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
use cramium_hal::udma;
|
||||
#[cfg(any(feature = "board-baosec", feature = "board-baosor"))]
|
||||
use cramium_hal::udma::PeriphId;
|
||||
|
|
@ -1556,6 +1557,7 @@ fn fsfreq_to_hz(fs_freq: u32) -> u32 { (fs_freq * (48_000_000 / 32)) / 1_000_000
|
|||
fn fsfreq_to_hz_32(fs_freq: u32) -> u32 { (fs_freq * (32_000_000 / 32)) / 1_000_000 }
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
/// Used mainly for debug breaks. Not used in every configuration.
|
||||
pub fn getc() -> char {
|
||||
let uart_buf_addr = loader::UART_IFRAM_ADDR;
|
||||
|
|
|
|||
|
|
@ -16,9 +16,8 @@ num-derive = { version = "0.4.2", default-features = false }
|
|||
num-traits = { version = "0.2.14", default-features = false }
|
||||
|
||||
[features]
|
||||
"cramium" = []
|
||||
"cramium-soc" = []
|
||||
"cramium-fpga" = []
|
||||
"cramium" = ["utralib/cramium-fpga"]
|
||||
"hwsim" = []
|
||||
"ext" = [] # must match setting in cram-mbox2
|
||||
default = ["cramium", "ext"]
|
||||
# ext specifies to use the APB client, instead of the loopback local
|
||||
"ext" = [] # must match setting in cram-mbox2
|
||||
default = ["cramium"]
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ impl Mailbox {
|
|||
}
|
||||
|
||||
pub fn get(&mut self, ret: &mut [u32]) -> usize {
|
||||
let mut drain = false;
|
||||
let status = self.csr.r(utra::mailbox::STATUS);
|
||||
if status & self.csr.ms(utra::mailbox::STATUS_RX_ERR, 1) != 0
|
||||
|| status & self.csr.ms(utra::mailbox::STATUS_TX_ERR, 1) != 0
|
||||
|
|
@ -56,6 +57,7 @@ impl Mailbox {
|
|||
let rx_words = status & self.csr.ms(utra::mailbox::STATUS_RX_WORDS, !0);
|
||||
let rx_words_checked = if rx_words as usize > ret.len() {
|
||||
log::warn!("rx_words {} is more than ret.len() {}", rx_words, ret.len());
|
||||
drain = true;
|
||||
ret.len()
|
||||
} else {
|
||||
rx_words as usize
|
||||
|
|
@ -64,7 +66,7 @@ impl Mailbox {
|
|||
*r = self.csr.rf(utra::mailbox::RDATA_RDATA);
|
||||
}
|
||||
// throw away any excess words to avoid breaking the protocol
|
||||
for _ in 0..(rx_words as usize - rx_words_checked) {
|
||||
for _ in 0..(if drain { 1 } else { 0 } + rx_words as usize - rx_words_checked) {
|
||||
let _ = self.csr.rf(utra::mailbox::RDATA_RDATA);
|
||||
}
|
||||
// re-enable aborts
|
||||
|
|
@ -145,20 +147,6 @@ fn main() {
|
|||
let mbox_cid = xous::connect(mbox_sid).unwrap();
|
||||
log::info!("mbox SID: {:x?}", mbox_sid);
|
||||
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
let csr = xous::syscall::map_memory(
|
||||
xous::MemoryAddress::new(utra::main::HW_MAIN_BASE),
|
||||
None,
|
||||
4096,
|
||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
)
|
||||
.expect("couldn't map Core Control CSR range");
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
let mut core_csr = CSR::new(csr.as_mut_ptr() as *mut u32);
|
||||
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
core_csr.wfo(utra::main::REPORT_REPORT, 0x600d_0000);
|
||||
|
||||
let mbox_csr = xous::syscall::map_memory(
|
||||
xous::MemoryAddress::new(utra::mailbox::HW_MAILBOX_BASE),
|
||||
None,
|
||||
|
|
@ -214,7 +202,6 @@ fn main() {
|
|||
match num_traits::FromPrimitive::from_usize(msg.body.id()).unwrap_or(Opcode::InvalidCall) {
|
||||
Opcode::RunTest => {
|
||||
if let Some(scalar) = msg.body.scalar_message() {
|
||||
// core_csr.wfo(utra::main::REPORT_REPORT, scalar.arg1 as u32); // indicate the test start
|
||||
log::info!("test case {}", scalar.arg1);
|
||||
match scalar.arg1 {
|
||||
1 => {
|
||||
|
|
@ -262,8 +249,6 @@ fn main() {
|
|||
7 => {
|
||||
if !abort_done_seen {
|
||||
log::error!("We did not see an abort ack");
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
core_csr.wfo(utra::main::REPORT_REPORT, 0xdead_0007);
|
||||
break;
|
||||
}
|
||||
abort_done_seen = false;
|
||||
|
|
@ -305,8 +290,6 @@ fn main() {
|
|||
}
|
||||
11 => {
|
||||
log::info!("Last test done");
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
core_csr.wfo(utra::main::REPORT_REPORT, 0x600d_000a);
|
||||
break;
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -410,17 +393,17 @@ fn main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
core_csr.wfo(utra::main::SUCCESS_SUCCESS, 1);
|
||||
#[cfg(feature = "cramium-fpga")]
|
||||
core_csr.wfo(utra::main::DONE_DONE, 1); // this should stop the simulation
|
||||
}
|
||||
|
||||
fn check_results(test_array: &[u32], ret_array: &[u32], count: usize) -> bool {
|
||||
let test_len = (test_array[0] >> 16) as usize;
|
||||
if test_len > test_array.len() || test_len > ret_array.len() || test_len != count {
|
||||
log::error!("Test length is incorrect: expected {:x}, got {:x}", test_len, count);
|
||||
log::error!(
|
||||
"Test length is incorrect: expected {:x}, got {:x} [{:x}]",
|
||||
test_len,
|
||||
count,
|
||||
test_array[0]
|
||||
);
|
||||
return false;
|
||||
}
|
||||
let mut errcnt = 0;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ num-derive = { version = "0.4.2", default-features = false }
|
|||
num-traits = { version = "0.2.14", default-features = false }
|
||||
|
||||
[features]
|
||||
"cramium" = []
|
||||
"ext" = [] # must match setting in cram-mbox1
|
||||
default = ["cramium", "ext"]
|
||||
"cramium" = ["utralib/cramium-fpga"]
|
||||
# ext specifies to use the APB client, instead of the loopback local
|
||||
"ext" = [] # must match setting in cram-mbox1
|
||||
default = ["cramium"]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use core::fmt::{Error, Write};
|
||||
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
use cramium_hal::udma;
|
||||
|
||||
#[macro_export]
|
||||
|
|
@ -33,10 +34,10 @@ pub static mut DEFAULT_UART_ADDR: *mut usize = 0x0000_0000 as *mut usize;
|
|||
impl Uart {
|
||||
pub fn putc(&self, c: u8) {
|
||||
assert!(unsafe { DEFAULT_UART_ADDR } as usize != 0);
|
||||
let mut uart_csr = CSR::new(unsafe { DEFAULT_UART_ADDR as *mut u32 });
|
||||
let mut uart_csr = utralib::CSR::new(unsafe { DEFAULT_UART_ADDR as *mut u32 });
|
||||
|
||||
while uart_csr.r(utra::duart::SFR_SR) != 0 {}
|
||||
uart_csr.wo(utra::duart::SFR_TXD, c as u32);
|
||||
while uart_csr.r(utralib::utra::duart::SFR_SR) != 0 {}
|
||||
uart_csr.wo(utralib::utra::duart::SFR_TXD, c as u32);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
use core::fmt::{Error, Write};
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
use std::pin::Pin;
|
||||
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
use cramium_hal::board::UART_DMA_TX_BUF_PHYS;
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
use cramium_hal::udma;
|
||||
use utralib::generated::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<device schemaVersion="1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="CMSIS-SVD.xsd" >
|
||||
<vendor>litex</vendor>
|
||||
<name>SOC</name>
|
||||
<description><![CDATA[Litex SoC 2024-12-25 06:02:35]]></description>
|
||||
<description><![CDATA[Litex SoC 2025-01-01 15:33:54]]></description>
|
||||
|
||||
<addressUnitBits>8</addressUnitBits>
|
||||
<width>32</width>
|
||||
|
|
@ -343,28 +343,28 @@ directly to the bit position, and defaults to bit `0`]]></description>
|
|||
<msb>7</msb>
|
||||
<bitRange>[7:0]</bitRange>
|
||||
<lsb>0</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` ASID]]></description>
|
||||
<description><![CDATA[Value of `CoreUser` ASID bit 0]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>lut1</name>
|
||||
<msb>15</msb>
|
||||
<bitRange>[15:8]</bitRange>
|
||||
<lsb>8</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` ASID]]></description>
|
||||
<description><![CDATA[Value of `CoreUser` ASID bit 0]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>lut2</name>
|
||||
<msb>23</msb>
|
||||
<bitRange>[23:16]</bitRange>
|
||||
<lsb>16</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` ASID]]></description>
|
||||
<description><![CDATA[Value of `CoreUser` ASID bit 0]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>lut3</name>
|
||||
<msb>31</msb>
|
||||
<bitRange>[31:24]</bitRange>
|
||||
<lsb>24</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` ASID]]></description>
|
||||
<description><![CDATA[Value of `CoreUser` ASID bit 0]]></description>
|
||||
</field>
|
||||
</fields>
|
||||
</register>
|
||||
|
|
@ -379,35 +379,106 @@ directly to the bit position, and defaults to bit `0`]]></description>
|
|||
<msb>7</msb>
|
||||
<bitRange>[7:0]</bitRange>
|
||||
<lsb>0</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` ASID]]></description>
|
||||
<description><![CDATA[Value of `CoreUser` ASID bit 0]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>lut5</name>
|
||||
<msb>15</msb>
|
||||
<bitRange>[15:8]</bitRange>
|
||||
<lsb>8</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` ASID]]></description>
|
||||
<description><![CDATA[Value of `CoreUser` ASID bit 0]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>lut6</name>
|
||||
<msb>23</msb>
|
||||
<bitRange>[23:16]</bitRange>
|
||||
<lsb>16</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` ASID]]></description>
|
||||
<description><![CDATA[Value of `CoreUser` ASID bit 0]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>lut7</name>
|
||||
<msb>31</msb>
|
||||
<bitRange>[31:24]</bitRange>
|
||||
<lsb>24</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` ASID]]></description>
|
||||
<description><![CDATA[Value of `CoreUser` ASID bit 0]]></description>
|
||||
</field>
|
||||
</fields>
|
||||
</register>
|
||||
<register>
|
||||
<name>USERVALUE</name>
|
||||
<addressOffset>0x0010</addressOffset>
|
||||
<resetValue>0x00</resetValue>
|
||||
<size>32</size>
|
||||
<fields>
|
||||
<field>
|
||||
<name>user0</name>
|
||||
<msb>1</msb>
|
||||
<bitRange>[1:0]</bitRange>
|
||||
<lsb>0</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` for lut0 match]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>user1</name>
|
||||
<msb>3</msb>
|
||||
<bitRange>[3:2]</bitRange>
|
||||
<lsb>2</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` for lut1 match]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>user2</name>
|
||||
<msb>5</msb>
|
||||
<bitRange>[5:4]</bitRange>
|
||||
<lsb>4</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` for lut2 match]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>user3</name>
|
||||
<msb>7</msb>
|
||||
<bitRange>[7:6]</bitRange>
|
||||
<lsb>6</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` for lut3 match]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>user4</name>
|
||||
<msb>9</msb>
|
||||
<bitRange>[9:8]</bitRange>
|
||||
<lsb>8</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` for lut4 match]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>user5</name>
|
||||
<msb>11</msb>
|
||||
<bitRange>[11:10]</bitRange>
|
||||
<lsb>10</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` for lut5 match]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>user6</name>
|
||||
<msb>13</msb>
|
||||
<bitRange>[13:12]</bitRange>
|
||||
<lsb>12</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` for lut6 match]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>user7</name>
|
||||
<msb>15</msb>
|
||||
<bitRange>[15:14]</bitRange>
|
||||
<lsb>14</lsb>
|
||||
<description><![CDATA[Value of `CoreUser` for lut7 match]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>default</name>
|
||||
<msb>17</msb>
|
||||
<bitRange>[17:16]</bitRange>
|
||||
<lsb>16</lsb>
|
||||
<description><![CDATA[Default value of `CoreUser`, for when none of the others match]]></description>
|
||||
</field>
|
||||
</fields>
|
||||
</register>
|
||||
</registers>
|
||||
<addressBlock>
|
||||
<offset>0</offset>
|
||||
<size>0x10</size>
|
||||
<size>0x14</size>
|
||||
<usage>registers</usage>
|
||||
</addressBlock>
|
||||
</peripheral>
|
||||
|
|
|
|||
|
|
@ -3118,13 +3118,45 @@ position to clear the flag]]></description>
|
|||
<fields>
|
||||
<field>
|
||||
<name>sfr_cgufdpke</name>
|
||||
<msb>8</msb>
|
||||
<bitRange>[8:0]</bitRange>
|
||||
<msb>7</msb>
|
||||
<bitRange>[7:0]</bitRange>
|
||||
<lsb>0</lsb>
|
||||
<description><![CDATA[sfr_cgufdpke read/write control register]]></description>
|
||||
</field>
|
||||
</fields>
|
||||
</register>
|
||||
<register>
|
||||
<name>SFR_CGUFDAORAM</name>
|
||||
<description><![CDATA[See file:///F:/code/cram-nto/modules/sysctrl/rtl/sysctrl.sv]]></description>
|
||||
<addressOffset>0x0038</addressOffset>
|
||||
<resetValue>0x00</resetValue>
|
||||
<size>32</size>
|
||||
<fields>
|
||||
<field>
|
||||
<name>sfr_cgufdaoram</name>
|
||||
<msb>15</msb>
|
||||
<bitRange>[15:0]</bitRange>
|
||||
<lsb>0</lsb>
|
||||
<description><![CDATA[sfr_cgufdaoram read/write control register]]></description>
|
||||
</field>
|
||||
</fields>
|
||||
</register>
|
||||
<register>
|
||||
<name>SFR_CGUFDPER</name>
|
||||
<description><![CDATA[See file:///F:/code/cram-nto/modules/sysctrl/rtl/sysctrl.sv]]></description>
|
||||
<addressOffset>0x003c</addressOffset>
|
||||
<resetValue>0x00</resetValue>
|
||||
<size>32</size>
|
||||
<fields>
|
||||
<field>
|
||||
<name>sfr_cgufdper</name>
|
||||
<msb>23</msb>
|
||||
<bitRange>[23:0]</bitRange>
|
||||
<lsb>0</lsb>
|
||||
<description><![CDATA[sfr_cgufdper read/write control register]]></description>
|
||||
</field>
|
||||
</fields>
|
||||
</register>
|
||||
<register>
|
||||
<name>SFR_CGUFSSR_FSFREQ0</name>
|
||||
<description><![CDATA[See file:///F:/code/cram-nto/modules/sysctrl/rtl/sysctrl.sv]]></description>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -491,7 +491,7 @@ pub mod utra {
|
|||
}
|
||||
|
||||
pub mod coreuser {
|
||||
pub const COREUSER_NUMREGS: usize = 4;
|
||||
pub const COREUSER_NUMREGS: usize = 5;
|
||||
|
||||
pub const CONTROL: crate::Register = crate::Register::new(0, 0xff);
|
||||
pub const CONTROL_ENABLE: crate::Field = crate::Field::new(1, 0, CONTROL);
|
||||
|
|
@ -515,6 +515,17 @@ pub mod utra {
|
|||
pub const MAP_HI_LUT6: crate::Field = crate::Field::new(8, 16, MAP_HI);
|
||||
pub const MAP_HI_LUT7: crate::Field = crate::Field::new(8, 24, MAP_HI);
|
||||
|
||||
pub const USERVALUE: crate::Register = crate::Register::new(4, 0x3ffff);
|
||||
pub const USERVALUE_USER0: crate::Field = crate::Field::new(2, 0, USERVALUE);
|
||||
pub const USERVALUE_USER1: crate::Field = crate::Field::new(2, 2, USERVALUE);
|
||||
pub const USERVALUE_USER2: crate::Field = crate::Field::new(2, 4, USERVALUE);
|
||||
pub const USERVALUE_USER3: crate::Field = crate::Field::new(2, 6, USERVALUE);
|
||||
pub const USERVALUE_USER4: crate::Field = crate::Field::new(2, 8, USERVALUE);
|
||||
pub const USERVALUE_USER5: crate::Field = crate::Field::new(2, 10, USERVALUE);
|
||||
pub const USERVALUE_USER6: crate::Field = crate::Field::new(2, 12, USERVALUE);
|
||||
pub const USERVALUE_USER7: crate::Field = crate::Field::new(2, 14, USERVALUE);
|
||||
pub const USERVALUE_DEFAULT: crate::Field = crate::Field::new(2, 16, USERVALUE);
|
||||
|
||||
pub const HW_COREUSER_BASE: usize = 0xe0002000;
|
||||
}
|
||||
|
||||
|
|
@ -5719,6 +5730,54 @@ mod tests {
|
|||
let mut baz = coreuser_csr.zf(utra::coreuser::MAP_HI_LUT7, bar);
|
||||
baz |= coreuser_csr.ms(utra::coreuser::MAP_HI_LUT7, 1);
|
||||
coreuser_csr.wfo(utra::coreuser::MAP_HI_LUT7, baz);
|
||||
|
||||
let foo = coreuser_csr.r(utra::coreuser::USERVALUE);
|
||||
coreuser_csr.wo(utra::coreuser::USERVALUE, foo);
|
||||
let bar = coreuser_csr.rf(utra::coreuser::USERVALUE_USER0);
|
||||
coreuser_csr.rmwf(utra::coreuser::USERVALUE_USER0, bar);
|
||||
let mut baz = coreuser_csr.zf(utra::coreuser::USERVALUE_USER0, bar);
|
||||
baz |= coreuser_csr.ms(utra::coreuser::USERVALUE_USER0, 1);
|
||||
coreuser_csr.wfo(utra::coreuser::USERVALUE_USER0, baz);
|
||||
let bar = coreuser_csr.rf(utra::coreuser::USERVALUE_USER1);
|
||||
coreuser_csr.rmwf(utra::coreuser::USERVALUE_USER1, bar);
|
||||
let mut baz = coreuser_csr.zf(utra::coreuser::USERVALUE_USER1, bar);
|
||||
baz |= coreuser_csr.ms(utra::coreuser::USERVALUE_USER1, 1);
|
||||
coreuser_csr.wfo(utra::coreuser::USERVALUE_USER1, baz);
|
||||
let bar = coreuser_csr.rf(utra::coreuser::USERVALUE_USER2);
|
||||
coreuser_csr.rmwf(utra::coreuser::USERVALUE_USER2, bar);
|
||||
let mut baz = coreuser_csr.zf(utra::coreuser::USERVALUE_USER2, bar);
|
||||
baz |= coreuser_csr.ms(utra::coreuser::USERVALUE_USER2, 1);
|
||||
coreuser_csr.wfo(utra::coreuser::USERVALUE_USER2, baz);
|
||||
let bar = coreuser_csr.rf(utra::coreuser::USERVALUE_USER3);
|
||||
coreuser_csr.rmwf(utra::coreuser::USERVALUE_USER3, bar);
|
||||
let mut baz = coreuser_csr.zf(utra::coreuser::USERVALUE_USER3, bar);
|
||||
baz |= coreuser_csr.ms(utra::coreuser::USERVALUE_USER3, 1);
|
||||
coreuser_csr.wfo(utra::coreuser::USERVALUE_USER3, baz);
|
||||
let bar = coreuser_csr.rf(utra::coreuser::USERVALUE_USER4);
|
||||
coreuser_csr.rmwf(utra::coreuser::USERVALUE_USER4, bar);
|
||||
let mut baz = coreuser_csr.zf(utra::coreuser::USERVALUE_USER4, bar);
|
||||
baz |= coreuser_csr.ms(utra::coreuser::USERVALUE_USER4, 1);
|
||||
coreuser_csr.wfo(utra::coreuser::USERVALUE_USER4, baz);
|
||||
let bar = coreuser_csr.rf(utra::coreuser::USERVALUE_USER5);
|
||||
coreuser_csr.rmwf(utra::coreuser::USERVALUE_USER5, bar);
|
||||
let mut baz = coreuser_csr.zf(utra::coreuser::USERVALUE_USER5, bar);
|
||||
baz |= coreuser_csr.ms(utra::coreuser::USERVALUE_USER5, 1);
|
||||
coreuser_csr.wfo(utra::coreuser::USERVALUE_USER5, baz);
|
||||
let bar = coreuser_csr.rf(utra::coreuser::USERVALUE_USER6);
|
||||
coreuser_csr.rmwf(utra::coreuser::USERVALUE_USER6, bar);
|
||||
let mut baz = coreuser_csr.zf(utra::coreuser::USERVALUE_USER6, bar);
|
||||
baz |= coreuser_csr.ms(utra::coreuser::USERVALUE_USER6, 1);
|
||||
coreuser_csr.wfo(utra::coreuser::USERVALUE_USER6, baz);
|
||||
let bar = coreuser_csr.rf(utra::coreuser::USERVALUE_USER7);
|
||||
coreuser_csr.rmwf(utra::coreuser::USERVALUE_USER7, bar);
|
||||
let mut baz = coreuser_csr.zf(utra::coreuser::USERVALUE_USER7, bar);
|
||||
baz |= coreuser_csr.ms(utra::coreuser::USERVALUE_USER7, 1);
|
||||
coreuser_csr.wfo(utra::coreuser::USERVALUE_USER7, baz);
|
||||
let bar = coreuser_csr.rf(utra::coreuser::USERVALUE_DEFAULT);
|
||||
coreuser_csr.rmwf(utra::coreuser::USERVALUE_DEFAULT, bar);
|
||||
let mut baz = coreuser_csr.zf(utra::coreuser::USERVALUE_DEFAULT, bar);
|
||||
baz |= coreuser_csr.ms(utra::coreuser::USERVALUE_DEFAULT, 1);
|
||||
coreuser_csr.wfo(utra::coreuser::USERVALUE_DEFAULT, baz);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -1012,6 +1012,8 @@ impl Builder {
|
|||
args.push("atsama5d2");
|
||||
} else if self.utra_target.contains("cramium-soc") {
|
||||
args.push("cramium-soc")
|
||||
} else if self.utra_target.contains("cramium-fpga") {
|
||||
args.push("cramium-soc")
|
||||
}
|
||||
args.push("--");
|
||||
|
||||
|
|
|
|||
|
|
@ -516,17 +516,22 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
}
|
||||
|
||||
// ------ Cramium hardware image configs ------
|
||||
Some("cramium-fpga") | Some("cramium-soc") => {
|
||||
let board = "board-dabao";
|
||||
// select the board
|
||||
builder.add_feature(board);
|
||||
builder.add_loader_feature(board);
|
||||
builder.add_kernel_feature(board);
|
||||
Some("cramium-sim") | Some("cramium-soc") => {
|
||||
match task.as_deref() {
|
||||
Some("cramium-soc") => {
|
||||
let board = "board-dabao";
|
||||
// select the board
|
||||
builder.add_feature(board);
|
||||
builder.add_loader_feature(board);
|
||||
builder.add_kernel_feature(board);
|
||||
}
|
||||
_ => (), // don't add any board because this is simulation
|
||||
};
|
||||
|
||||
// placement in flash is a tension between dev convenience and RAM usage. Things in flash
|
||||
// are resident, non-swapable, but end up making the slow kernel burn process take longer.
|
||||
let cramium_flash_pkgs =
|
||||
["xous-ticktimer", "xous-log", "xous-names" /* "cram-hal-service" */].to_vec();
|
||||
["xous-log", "xous-names", "cram-mbox1", "cram-mbox2" /* "cram-hal-service" */].to_vec();
|
||||
let cramium_swap_pkgs = [].to_vec();
|
||||
|
||||
builder.add_loader_feature("debug-print");
|
||||
|
|
@ -541,7 +546,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
builder.add_loader_feature("sram-margin");
|
||||
match task.as_deref() {
|
||||
Some("cramium-fpga") => builder.target_cramium_fpga(),
|
||||
Some("cramium-sim") => builder.target_cramium_fpga(),
|
||||
Some("cramium-soc") => builder.target_cramium_soc(),
|
||||
_ => panic!("should be unreachable"),
|
||||
};
|
||||
|
|
@ -787,6 +792,7 @@ Hardware images:
|
|||
av-test automation framework for TRNG testing (AV directly, no CPRNG). [cratespecs] ignored.
|
||||
tiny Precursor tiny image. For testing with services built out-of-tree.
|
||||
cramium-soc BSP validation image for Cramium. Contains a superset of features, in various states of testing.
|
||||
cramium-sim Tiny target for verilator simulation
|
||||
baosec Baosec application target image.
|
||||
|
||||
Hosted emulation:
|
||||
|
|
|
|||
Loading…
Reference in a new issue