mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +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::*;
|
use utralib::generated::*;
|
||||||
|
|
||||||
pub(crate) const SERVER_NAME_SUSRES: &str = "_Suspend/resume manager_";
|
pub(crate) const SERVER_NAME_SUSRES: &str = "_Suspend/resume manager_";
|
||||||
|
|
@ -20,11 +21,13 @@ pub(crate) enum ExecGateOpcode {
|
||||||
SuspendNow,
|
SuspendNow,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "none")]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub enum RegOrField {
|
pub enum RegOrField {
|
||||||
Field(Field),
|
Field(Field),
|
||||||
Reg(Register),
|
Reg(Register),
|
||||||
}
|
}
|
||||||
|
#[cfg(target_os = "none")]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct ManagedReg {
|
pub struct ManagedReg {
|
||||||
/// register, or a field of a register
|
/// register, or a field of a register
|
||||||
|
|
@ -34,7 +37,9 @@ pub struct ManagedReg {
|
||||||
/// the saved value of the field or register
|
/// the saved value of the field or register
|
||||||
pub value: Option<usize>,
|
pub value: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
//#[derive(Debug)]
|
//#[derive(Debug)]
|
||||||
|
#[cfg(target_os = "none")]
|
||||||
pub struct RegManager<const N: usize> {
|
pub struct RegManager<const N: usize> {
|
||||||
pub csr: CSR<u32>,
|
pub csr: CSR<u32>,
|
||||||
pub registers: [Option<ManagedReg>; N],
|
pub registers: [Option<ManagedReg>; N],
|
||||||
|
|
@ -43,6 +48,7 @@ pub struct RegManager<const N: usize> {
|
||||||
pub res_prologue: Option<fn(&mut Self)>,
|
pub res_prologue: Option<fn(&mut Self)>,
|
||||||
pub res_epilogue: 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 {
|
impl<const N: usize> RegManager::<N> where ManagedReg: core::marker::Copy {
|
||||||
pub fn new(reg_base: *mut u32) -> RegManager::<N> {
|
pub fn new(reg_base: *mut u32) -> RegManager::<N> {
|
||||||
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!");
|
panic!("Ran out of space pushing to suspend/resume manager structure. Please increase the allocated size!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(target_os = "none")]
|
||||||
pub trait SuspendResume {
|
pub trait SuspendResume {
|
||||||
fn suspend(&mut self);
|
fn suspend(&mut self);
|
||||||
fn resume(&mut self);
|
fn resume(&mut self);
|
||||||
}
|
}
|
||||||
|
#[cfg(target_os = "none")]
|
||||||
impl<const N: usize> SuspendResume for RegManager<N> {
|
impl<const N: usize> SuspendResume for RegManager<N> {
|
||||||
fn suspend(&mut self) {
|
fn suspend(&mut self) {
|
||||||
if let Some(sp) = self.sus_prologue {
|
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),
|
// 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.
|
// we allocate these as stand-alone structures and manage them explicitly.
|
||||||
|
#[cfg(target_os = "none")]
|
||||||
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],
|
||||||
}
|
}
|
||||||
|
#[cfg(target_os = "none")]
|
||||||
impl<const N: usize> SuspendResume for ManagedMem<N> {
|
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;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue