add a try_send() routine to buffers

this allows us to send memory messages from an IRQ context
This commit is contained in:
bunnie 2024-12-16 18:00:51 +08:00
parent 9a0bbbd2fb
commit 186534187e

View file

@ -10,7 +10,7 @@ use rkyv::{
};
use xous::{
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)]
@ -173,6 +173,21 @@ impl<'buf> Buffer<'buf> {
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, ()>
where
F: for<'a, 'b> SerializeWith<T, Serializer<'a, 'b>>,