mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
xous: syscall: add function to modify memory ptr
Add a function to modify the pointer of a MemoryRange. This is used by `hosted` mode in order to modify memory pointers when we receive them from the remote client. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
f5de6551bc
commit
7dee05082c
1 changed files with 19 additions and 0 deletions
|
|
@ -985,6 +985,25 @@ impl SysCall {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If the syscall has memory attached to it, return the memory, mutably
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// This function is only safe to call to fixup the pointer. It should
|
||||||
|
/// not be used for any other purpose.
|
||||||
|
pub unsafe fn memory_mut(&mut self) -> Option<&mut MemoryRange> {
|
||||||
|
match self {
|
||||||
|
SysCall::TrySendMessage(_, msg) | SysCall::SendMessage(_, msg) => match msg {
|
||||||
|
Message::Move(memory_message)
|
||||||
|
| Message::Borrow(memory_message)
|
||||||
|
| Message::MutableBorrow(memory_message) => Some(&mut memory_message.buf),
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
|
SysCall::ReturnMemory(_, range, _, _) => Some(range),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns `true` if the given syscall may be called from an IRQ context
|
/// Returns `true` if the given syscall may be called from an IRQ context
|
||||||
pub fn can_call_from_interrupt(&self) -> bool {
|
pub fn can_call_from_interrupt(&self) -> bool {
|
||||||
if let SysCall::TrySendMessage(_cid, msg) = self {
|
if let SysCall::TrySendMessage(_cid, msg) = self {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue