mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
add a try_send() routine to buffers
this allows us to send memory messages from an IRQ context
This commit is contained in:
parent
9a0bbbd2fb
commit
186534187e
1 changed files with 16 additions and 1 deletions
|
|
@ -10,7 +10,7 @@ use rkyv::{
|
||||||
};
|
};
|
||||||
use xous::{
|
use xous::{
|
||||||
CID, Error, MemoryAddress, MemoryFlags, MemoryMessage, MemoryRange, MemorySize, Message, Result,
|
CID, Error, MemoryAddress, MemoryFlags, MemoryMessage, MemoryRange, MemorySize, Message, Result,
|
||||||
map_memory, send_message, unmap_memory,
|
map_memory, send_message, try_send_message, unmap_memory,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -173,6 +173,21 @@ impl<'buf> Buffer<'buf> {
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn try_send(mut self, connection: CID, id: u32) -> core::result::Result<Result, Error> {
|
||||||
|
let msg = MemoryMessage {
|
||||||
|
id: id as usize,
|
||||||
|
buf: self.pages,
|
||||||
|
offset: MemoryAddress::new(self.used),
|
||||||
|
valid: MemorySize::new(self.pages.len()),
|
||||||
|
};
|
||||||
|
let result = try_send_message(connection, Message::Move(msg))?;
|
||||||
|
|
||||||
|
// prevents it from being Dropped.
|
||||||
|
self.should_drop = false;
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
|
||||||
fn into_buf_inner<F, T>(src: &T) -> core::result::Result<Self, ()>
|
fn into_buf_inner<F, T>(src: &T) -> core::result::Result<Self, ()>
|
||||||
where
|
where
|
||||||
F: for<'a, 'b> SerializeWith<T, Serializer<'a, 'b>>,
|
F: for<'a, 'b> SerializeWith<T, Serializer<'a, 'b>>,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue