mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
start fleshing out the susres server
This commit is contained in:
parent
3c66aff2a6
commit
d62f936454
4 changed files with 66 additions and 8 deletions
|
|
@ -70,7 +70,7 @@ impl<const N: usize> SuspendResume for RegManager<N> {
|
||||||
if let Some(sp) = self.sus_prologue {
|
if let Some(sp) = self.sus_prologue {
|
||||||
sp(self);
|
sp(self);
|
||||||
}
|
}
|
||||||
for entry in self.registers.iter_mut() {
|
for entry in self.registers.iter_mut().rev() {
|
||||||
if let Some(reg) = entry {
|
if let Some(reg) = entry {
|
||||||
// masking is done on the write side
|
// masking is done on the write side
|
||||||
match reg.item {
|
match reg.item {
|
||||||
|
|
@ -87,7 +87,7 @@ impl<const N: usize> SuspendResume for RegManager<N> {
|
||||||
if let Some(rp) = self.res_prologue {
|
if let Some(rp) = self.res_prologue {
|
||||||
rp(self);
|
rp(self);
|
||||||
}
|
}
|
||||||
for entry in self.registers.iter().rev() { // this is in reverse order to the suspend
|
for entry in self.registers.iter() { // this is in reverse order to the suspend
|
||||||
if let Some(reg) = entry {
|
if let Some(reg) = entry {
|
||||||
if let Some(mut value) = reg.value {
|
if let Some(mut value) = reg.value {
|
||||||
if let Some(mask) = reg.mask {
|
if let Some(mask) = reg.mask {
|
||||||
|
|
@ -105,12 +105,14 @@ impl<const N: usize> SuspendResume for RegManager<N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
// because the volatile memory regions can be potentially large (128kiB), but fewer (maybe 5-6 total in the system),
|
||||||
|
// we allocate these as stand-alone structures and manage them explicitly.
|
||||||
pub struct ManagedMem<const N: usize> {
|
pub struct ManagedMem<const N: usize> {
|
||||||
pub mem: xous::MemoryRange,
|
pub mem: xous::MemoryRange,
|
||||||
pub backing: [u32; N],
|
pub backing: [u32; N],
|
||||||
}
|
}
|
||||||
pub trait SusResMem {
|
impl<const N: usize> SuspendResume for ManagedMem<N> {
|
||||||
fn suspend(&mut self) {
|
fn suspend(&mut self) {
|
||||||
let src = self.mem.as_ptr() as *const u32;
|
let src = self.mem.as_ptr() as *const u32;
|
||||||
for words in 0..self.mem.len() {
|
for words in 0..self.mem.len() {
|
||||||
|
|
@ -124,7 +126,6 @@ pub trait SusResMem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,77 @@
|
||||||
#![cfg_attr(target_os = "none", no_main)]
|
#![cfg_attr(target_os = "none", no_main)]
|
||||||
|
|
||||||
mod api;
|
mod api;
|
||||||
|
use api::*;
|
||||||
|
|
||||||
use num_traits::FromPrimitive;
|
use num_traits::FromPrimitive;
|
||||||
|
|
||||||
use log::info;
|
#[cfg(target_os = "none")]
|
||||||
|
mod implementation {
|
||||||
|
use utralib::generated::*;
|
||||||
|
use crate::api::*;
|
||||||
|
|
||||||
|
fn handle_irq(_irq_no: usize, arg: *mut usize) {
|
||||||
|
let sr = unsafe{ &mut *(arg as *mut SusResHw) };
|
||||||
|
// dummy routine for now
|
||||||
|
sr.csr.wfo(utra::susres::EV_PENDING_SOFT_INT, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SusResHw {
|
||||||
|
/// our CSR
|
||||||
|
csr: utralib::CSR<u32>,
|
||||||
|
/// backing store for the ticktimer value
|
||||||
|
time_backing: Option<[u32; 2]>,
|
||||||
|
}
|
||||||
|
impl SusResHw {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let csr = xous::syscall::map_memory(
|
||||||
|
xous::MemoryAddress::new(utra::susres::HW_SUSRES_BASE),
|
||||||
|
None,
|
||||||
|
4096,
|
||||||
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
|
)
|
||||||
|
.expect("couldn't map SusRes CSR range");
|
||||||
|
|
||||||
|
let mut sr = SusResHw {
|
||||||
|
csr: CSR::new(csr.as_mut_ptr() as *mut u32),
|
||||||
|
time_backing: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
xous::claim_interrupt(
|
||||||
|
utra::susres::SUSRES_IRQ,
|
||||||
|
handle_irq,
|
||||||
|
(&mut sr) as *mut SusResHw as *mut usize,
|
||||||
|
).expect("couldn't claim IRQ");
|
||||||
|
|
||||||
|
sr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "none"))]
|
||||||
|
mod implementation {
|
||||||
|
pub struct SusResHw {
|
||||||
|
}
|
||||||
|
impl SusResHw {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
SusResHw {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[xous::xous_main]
|
#[xous::xous_main]
|
||||||
fn xmain() -> ! {
|
fn xmain() -> ! {
|
||||||
log_server::init_wait().unwrap();
|
log_server::init_wait().unwrap();
|
||||||
log::set_max_level(log::LevelFilter::Trace);
|
log::set_max_level(log::LevelFilter::Trace);
|
||||||
info!("my PID is {}", xous::process::id());
|
log::info!("my PID is {}", xous::process::id());
|
||||||
|
|
||||||
let xns = xous_names::XousNames::new().unwrap();
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
let susres_sid = xns.register_name(api::SERVER_NAME_SUSRES).expect("can't register server");
|
let susres_sid = xns.register_name(api::SERVER_NAME_SUSRES).expect("can't register server");
|
||||||
log::trace!("registered with NS -- {:?}", susres_sid);
|
log::trace!("registered with NS -- {:?}", susres_sid);
|
||||||
|
|
||||||
|
let susres_hw = implementation::SusResHw::new();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let msg = xous::receive_message(susres_sid).unwrap();
|
let msg = xous::receive_message(susres_sid).unwrap();
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ mod implementation {
|
||||||
)
|
)
|
||||||
.expect("couldn't map Watchdog timer CSR range");
|
.expect("couldn't map Watchdog timer CSR range");
|
||||||
|
|
||||||
let susres = RegManager::<TICKTIMER_NUMREGS>::new(csr.as_mut_ptr() as *mut u32);
|
let susres = RegManager::new(csr.as_mut_ptr() as *mut u32);
|
||||||
|
|
||||||
let mut xtt = XousTickTimer {
|
let mut xtt = XousTickTimer {
|
||||||
csr: CSR::new(csr.as_mut_ptr() as *mut u32),
|
csr: CSR::new(csr.as_mut_ptr() as *mut u32),
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,7 @@ cbtest builds an image for callback testing
|
||||||
trng-test [soc.svd] builds an image for TRNG testing (both avalanche and ring oscillator on)
|
trng-test [soc.svd] builds an image for TRNG testing (both avalanche and ring oscillator on)
|
||||||
ro-test [soc.svd] builds an image for ring oscillator only TRNG testing
|
ro-test [soc.svd] builds an image for ring oscillator only TRNG testing
|
||||||
av-test [soc.svd] builds an image for avalanche generater only TRNG testing
|
av-test [soc.svd] builds an image for avalanche generater only TRNG testing
|
||||||
|
sr-test [soc.svd] builds the suspend/resume testing image
|
||||||
"
|
"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue