mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
use macro expansion for argument extraction of scalars
This commit is contained in:
parent
e3733fa64c
commit
da255cc1ab
3 changed files with 11 additions and 21 deletions
|
|
@ -12,7 +12,7 @@ use log::{error, info, trace};
|
|||
use com_rs_ref as com_rs;
|
||||
use com_rs::*;
|
||||
|
||||
use xous::CID;
|
||||
use xous::{CID, msg_scalar_unpack, msg_blocking_scalar_unpack};
|
||||
use xous_ipc::{Buffer, String};
|
||||
|
||||
const STD_TIMEOUT: u32 = 100;
|
||||
|
|
@ -255,10 +255,7 @@ fn xmain() -> ! {
|
|||
let msg = xous::receive_message(com_sid).unwrap();
|
||||
trace!("Message: {:?}", msg);
|
||||
match FromPrimitive::from_usize(msg.body.id()) {
|
||||
Some(Opcode::RegisterBattStatsListener) => {
|
||||
if let xous::Message::Scalar(xous::ScalarMessage {
|
||||
id: _id, arg1: sid0, arg2: sid1, arg3: sid2, arg4: sid3
|
||||
}) = msg.body {
|
||||
Some(Opcode::RegisterBattStatsListener) => msg_scalar_unpack!(msg, sid0, sid1, sid2, sid3, {
|
||||
let sid = xous::SID::from_u32(sid0 as _, sid1 as _, sid2 as _, sid3 as _);
|
||||
let cid = Some(xous::connect(sid).unwrap());
|
||||
let mut found = false;
|
||||
|
|
@ -273,7 +270,7 @@ fn xmain() -> ! {
|
|||
error!("RegisterBattStatsListener ran out of space registering callback");
|
||||
}
|
||||
}
|
||||
}
|
||||
),
|
||||
Some(Opcode::Wf200PdsLine) => {
|
||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let l = buffer.to_original::<String::<512>, _>().unwrap();
|
||||
|
|
|
|||
|
|
@ -458,9 +458,7 @@ fn xmain() -> ! {
|
|||
)
|
||||
.expect("couldn't return time request");
|
||||
}
|
||||
Some(api::Opcode::SleepMs) => {
|
||||
if let xous::Message::BlockingScalar(xous::ScalarMessage {
|
||||
id: _, arg1: ms, arg2: _, arg3: _, arg4: _}) = msg.body {
|
||||
Some(api::Opcode::SleepMs) => xous::msg_blocking_scalar_unpack!(msg, ms, _, _, _, {
|
||||
recalculate_sleep(
|
||||
&mut ticktimer,
|
||||
&mut sleep_heap,
|
||||
|
|
@ -468,9 +466,8 @@ fn xmain() -> ! {
|
|||
msec: ms as i64,
|
||||
sender: msg.sender,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
}),
|
||||
Some(api::Opcode::RecalculateSleep) => {
|
||||
recalculate_sleep(&mut ticktimer, &mut sleep_heap, None);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,15 +167,11 @@ fn xmain() -> ! {
|
|||
loop {
|
||||
let msg = xous::receive_message(trng_sid).unwrap();
|
||||
match FromPrimitive::from_usize(msg.body.id()) {
|
||||
Some(api::Opcode::GetTrng) => {
|
||||
if let xous::Message::BlockingScalar(xous::ScalarMessage {
|
||||
id: _, arg1: count, arg2: _, arg3: _, arg4: _
|
||||
}) = msg.body {
|
||||
let val: [u32; 2] = trng.get_trng(count);
|
||||
xous::return_scalar2(msg.sender, val[0] as _, val[1] as _)
|
||||
.expect("couldn't return GetTrng request");
|
||||
} else { log::error!("GetTrng malformed message"); }
|
||||
}
|
||||
Some(api::Opcode::GetTrng) => xous::msg_scalar_unpack!(msg, count, _, _, _, {
|
||||
let val: [u32; 2] = trng.get_trng(count);
|
||||
xous::return_scalar2(msg.sender, val[0] as _, val[1] as _)
|
||||
.expect("couldn't return GetTrng request");
|
||||
}),
|
||||
None => {
|
||||
log::error!("couldn't convert opcode")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue