mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
xous: definitions: add memory() call to Result
This is used to get attached Memory from a Result, if any. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
8115c2e7cf
commit
39c9ef30b7
1 changed files with 10 additions and 5 deletions
|
|
@ -306,6 +306,15 @@ impl Message {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn memory(&self) -> Option<&MemoryRange> {
|
||||||
|
match self {
|
||||||
|
Message::MutableBorrow(mem) | Message::Borrow(mem) | Message::Move(mem) => {
|
||||||
|
Some(&mem.buf)
|
||||||
|
}
|
||||||
|
Message::BlockingScalar(_) | Message::Scalar(_) => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn message_type(&self) -> usize {
|
pub fn message_type(&self) -> usize {
|
||||||
match *self {
|
match *self {
|
||||||
Message::MutableBorrow(_) => 1,
|
Message::MutableBorrow(_) => 1,
|
||||||
|
|
@ -369,10 +378,7 @@ impl MemoryRange {
|
||||||
addr != 0,
|
addr != 0,
|
||||||
"tried to construct a memory range with a null pointer"
|
"tried to construct a memory range with a null pointer"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(size != 0, "tried to construct a zero-length memory range");
|
||||||
size != 0,
|
|
||||||
"tried to construct a zero-length memory range"
|
|
||||||
);
|
|
||||||
Ok(MemoryRange {
|
Ok(MemoryRange {
|
||||||
addr: MemoryAddress::new(addr).ok_or(Error::BadAddress)?,
|
addr: MemoryAddress::new(addr).ok_or(Error::BadAddress)?,
|
||||||
size: MemorySize::new(size).ok_or(Error::BadAddress)?,
|
size: MemorySize::new(size).ok_or(Error::BadAddress)?,
|
||||||
|
|
@ -580,7 +586,6 @@ impl Result {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// If the Result has memory attached to it, return the memory
|
/// If the Result has memory attached to it, return the memory
|
||||||
pub fn memory(&self) -> Option<MemoryRange> {
|
pub fn memory(&self) -> Option<MemoryRange> {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue