mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
fix hosted mode compatibility issues
This commit is contained in:
parent
d2e9d35d37
commit
77ad54e193
1 changed files with 10 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#[cfg(target_os = "none")]
|
||||
use utralib::generated::*;
|
||||
|
||||
pub(crate) const SERVER_NAME_SUSRES: &str = "_Suspend/resume manager_";
|
||||
|
|
@ -20,11 +21,13 @@ pub(crate) enum ExecGateOpcode {
|
|||
SuspendNow,
|
||||
}
|
||||
|
||||
#[cfg(target_os = "none")]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum RegOrField {
|
||||
Field(Field),
|
||||
Reg(Register),
|
||||
}
|
||||
#[cfg(target_os = "none")]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct ManagedReg {
|
||||
/// register, or a field of a register
|
||||
|
|
@ -34,7 +37,9 @@ pub struct ManagedReg {
|
|||
/// the saved value of the field or register
|
||||
pub value: Option<usize>,
|
||||
}
|
||||
|
||||
//#[derive(Debug)]
|
||||
#[cfg(target_os = "none")]
|
||||
pub struct RegManager<const N: usize> {
|
||||
pub csr: CSR<u32>,
|
||||
pub registers: [Option<ManagedReg>; N],
|
||||
|
|
@ -43,6 +48,7 @@ pub struct RegManager<const N: usize> {
|
|||
pub res_prologue: Option<fn(&mut Self)>,
|
||||
pub res_epilogue: Option<fn(&mut Self)>,
|
||||
}
|
||||
#[cfg(target_os = "none")]
|
||||
impl<const N: usize> RegManager::<N> where ManagedReg: core::marker::Copy {
|
||||
pub fn new(reg_base: *mut u32) -> RegManager::<N> {
|
||||
RegManager::<N> {
|
||||
|
|
@ -72,10 +78,12 @@ impl<const N: usize> RegManager::<N> where ManagedReg: core::marker::Copy {
|
|||
panic!("Ran out of space pushing to suspend/resume manager structure. Please increase the allocated size!");
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "none")]
|
||||
pub trait SuspendResume {
|
||||
fn suspend(&mut self);
|
||||
fn resume(&mut self);
|
||||
}
|
||||
#[cfg(target_os = "none")]
|
||||
impl<const N: usize> SuspendResume for RegManager<N> {
|
||||
fn suspend(&mut self) {
|
||||
if let Some(sp) = self.sus_prologue {
|
||||
|
|
@ -119,10 +127,12 @@ 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.
|
||||
#[cfg(target_os = "none")]
|
||||
pub struct ManagedMem<const N: usize> {
|
||||
pub mem: xous::MemoryRange,
|
||||
pub backing: [u32; N],
|
||||
}
|
||||
#[cfg(target_os = "none")]
|
||||
impl<const N: usize> SuspendResume for ManagedMem<N> {
|
||||
fn suspend(&mut self) {
|
||||
let src = self.mem.as_ptr() as *const u32;
|
||||
|
|
|
|||
Loading…
Reference in a new issue