mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
xous: Add missing mem functions
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
fb6d42be55
commit
6a098a222b
2 changed files with 73 additions and 0 deletions
41
xous-rs/src/arch/hosted/mem.rs
Normal file
41
xous-rs/src/arch/hosted/mem.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
use crate::{Error, MemoryAddress, MemoryFlags, MemoryRange};
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
use alloc::alloc::{alloc, dealloc, Layout};
|
||||||
|
|
||||||
|
pub fn map_memory_pre(
|
||||||
|
_phys: &Option<MemoryAddress>,
|
||||||
|
_virt: &Option<MemoryAddress>,
|
||||||
|
_size: usize,
|
||||||
|
_flags: MemoryFlags,
|
||||||
|
) -> core::result::Result<(), Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn map_memory_post(
|
||||||
|
_phys: Option<MemoryAddress>,
|
||||||
|
_virt: Option<MemoryAddress>,
|
||||||
|
_size: usize,
|
||||||
|
_flags: MemoryFlags,
|
||||||
|
mut range: MemoryRange,
|
||||||
|
) -> core::result::Result<MemoryRange, Error> {
|
||||||
|
let layout = Layout::from_size_align(range.len(), 4096).unwrap();
|
||||||
|
let new_mem = MemoryAddress::new(unsafe { alloc(layout) } as usize).ok_or(Error::BadAddress)?;
|
||||||
|
range.addr = new_mem;
|
||||||
|
Ok(range)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unmap_memory_pre(
|
||||||
|
_range: &MemoryRange
|
||||||
|
) -> core::result::Result<(), Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unmap_memory_post(
|
||||||
|
range: MemoryRange
|
||||||
|
) -> core::result::Result<(), Error> {
|
||||||
|
let layout = Layout::from_size_align(range.len(), 4096).unwrap();
|
||||||
|
let ptr = range.as_mut_ptr();
|
||||||
|
unsafe { dealloc(ptr, layout) };
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
32
xous-rs/src/arch/native/mem.rs
Normal file
32
xous-rs/src/arch/native/mem.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
use crate::{Error, MemoryAddress, MemoryFlags, MemoryRange};
|
||||||
|
|
||||||
|
pub fn map_memory_pre(
|
||||||
|
_phys: &Option<MemoryAddress>,
|
||||||
|
_virt: &Option<MemoryAddress>,
|
||||||
|
_size: usize,
|
||||||
|
_flags: MemoryFlags,
|
||||||
|
) -> core::result::Result<(), Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn map_memory_post(
|
||||||
|
_phys: Option<MemoryAddress>,
|
||||||
|
_virt: Option<MemoryAddress>,
|
||||||
|
_size: usize,
|
||||||
|
_flags: MemoryFlags,
|
||||||
|
range: MemoryRange,
|
||||||
|
) -> core::result::Result<MemoryRange, Error> {
|
||||||
|
Ok(range)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unmap_memory_pre(
|
||||||
|
_range: &MemoryRange
|
||||||
|
) -> core::result::Result<(), Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unmap_memory_post(
|
||||||
|
_range: MemoryRange
|
||||||
|
) -> core::result::Result<(), Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue