2021-01-21 20:11:02 +00:00
|
|
|
#![cfg_attr(target_os = "none", no_std)]
|
|
|
|
|
|
|
|
|
|
pub mod api;
|
2021-01-21 20:19:21 +00:00
|
|
|
use api::*;
|
|
|
|
|
|
2021-01-21 20:11:02 +00:00
|
|
|
use xous::{CID, send_message};
|
|
|
|
|
use xous_names::api::Lookup;
|
|
|
|
|
use xous::ipc::Sendable;
|
|
|
|
|
|
|
|
|
|
pub fn test_scalar(cid: CID, testvar: u32) -> Result<u32, xous::Error> {
|
|
|
|
|
let response = send_message(cid, api::Opcode::TestScalar(testvar).into())?;
|
|
|
|
|
if let xous::Result::Scalar1(r) = response {
|
|
|
|
|
Ok(r as u32)
|
|
|
|
|
} else {
|
|
|
|
|
panic!("unexpected return value: {:#?}", response);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn test_memory(cid: CID, testvar: u32) -> Result<u32, xous::Error> {
|
2021-01-21 20:19:21 +00:00
|
|
|
//let reg = Lookup::new();
|
|
|
|
|
let reg = TestStruct::new();
|
2021-01-21 20:11:02 +00:00
|
|
|
let mut sendable_reg = Sendable::new(reg).expect("can't create test structure");
|
|
|
|
|
sendable_reg.challenge[0] = testvar;
|
|
|
|
|
sendable_reg.lend_mut(cid, 0).expect("test failure");
|
|
|
|
|
Ok(sendable_reg.challenge[0])
|
|
|
|
|
}
|