2020-06-03 03:01:50 +00:00
|
|
|
#![cfg_attr(baremetal, no_main)]
|
|
|
|
|
#![cfg_attr(baremetal, no_std)]
|
2020-03-10 04:46:05 +00:00
|
|
|
|
2020-06-03 03:01:50 +00:00
|
|
|
#[cfg(baremetal)]
|
2020-03-10 04:46:05 +00:00
|
|
|
#[macro_use]
|
|
|
|
|
mod debug;
|
|
|
|
|
|
2020-06-03 03:01:50 +00:00
|
|
|
#[cfg(baremetal)]
|
|
|
|
|
mod baremetal;
|
2020-03-10 04:46:05 +00:00
|
|
|
|
2020-06-03 03:01:50 +00:00
|
|
|
mod timer;
|
2020-06-15 10:13:10 +00:00
|
|
|
// mod logstr;
|
2020-03-31 10:03:19 +00:00
|
|
|
|
2020-06-03 03:01:50 +00:00
|
|
|
#[cfg(baremetal)]
|
2020-03-31 10:03:19 +00:00
|
|
|
use core::fmt::Write;
|
2020-03-10 04:46:05 +00:00
|
|
|
|
2020-03-31 10:03:19 +00:00
|
|
|
// fn print_and_yield(index: *mut usize) -> ! {
|
|
|
|
|
// let num = index as usize;
|
|
|
|
|
// loop {
|
|
|
|
|
// println!("THREAD {}", num);
|
|
|
|
|
// xous::syscall::yield_slice();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2020-03-30 08:07:58 +00:00
|
|
|
|
2020-06-03 03:01:50 +00:00
|
|
|
#[cfg_attr(baremetal, no_mangle)]
|
2020-03-10 04:46:05 +00:00
|
|
|
fn main() {
|
2020-06-03 03:01:50 +00:00
|
|
|
println!("Starting to initialize the timer");
|
2020-03-10 04:46:05 +00:00
|
|
|
timer::init();
|
|
|
|
|
|
2020-03-19 09:26:16 +00:00
|
|
|
let mut connection = None;
|
|
|
|
|
println!("Attempting to connect to server...");
|
|
|
|
|
while connection.is_none() {
|
2020-06-15 10:13:10 +00:00
|
|
|
if let Ok(cid) = xous::syscall::connect((1, 2_626_920_432, 1, 2_626_920_432)) {
|
2020-03-19 09:26:16 +00:00
|
|
|
connection = Some(cid);
|
|
|
|
|
} else {
|
|
|
|
|
xous::syscall::yield_slice();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let connection = connection.unwrap();
|
|
|
|
|
println!("Connected: {:?}", connection);
|
|
|
|
|
|
2020-06-03 03:01:50 +00:00
|
|
|
let mut counter: usize = 0;
|
|
|
|
|
// let ls = logstr::LogStr::new();
|
2020-03-10 04:46:05 +00:00
|
|
|
loop {
|
2020-06-03 03:01:50 +00:00
|
|
|
println!("Sending a scalar message with id {}...", counter + 4096);
|
|
|
|
|
xous::syscall::send_message(
|
|
|
|
|
connection,
|
|
|
|
|
xous::Message::Scalar(xous::ScalarMessage {
|
|
|
|
|
id: counter + 4096,
|
|
|
|
|
arg1: counter,
|
|
|
|
|
arg2: counter * 2,
|
|
|
|
|
arg3: !counter,
|
|
|
|
|
arg4: counter + 1,
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
.expect("couldn't send scalar message");
|
|
|
|
|
if counter.trailing_zeros() >= 12 {
|
2020-04-06 07:52:07 +00:00
|
|
|
println!("Loop {}", counter);
|
2020-03-30 08:07:58 +00:00
|
|
|
}
|
2020-04-06 07:52:07 +00:00
|
|
|
counter += 1;
|
|
|
|
|
// if counter & 2 == 0 {
|
|
|
|
|
// xous::syscall::yield_slice();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// ls.clear();
|
|
|
|
|
// write!(ls, "Hello, Server! This memory is borrowed from another process. Loop number: {}", counter).expect("couldn't send hello message");
|
|
|
|
|
|
|
|
|
|
// println!("Sending a mutable borrow message");
|
|
|
|
|
// let response = xous::syscall::send_message(
|
|
|
|
|
// connection,
|
|
|
|
|
// xous::Message::MutableBorrow(
|
|
|
|
|
// ls.as_memory_message(0)
|
|
|
|
|
// .expect("couldn't form memory message"),
|
|
|
|
|
// ),
|
|
|
|
|
// )
|
|
|
|
|
// .expect("couldn't send memory message");
|
|
|
|
|
// unsafe { ls.set_len(response.0)};
|
|
|
|
|
// println!("Message came back with args ({}, {}) as: {}", response.0, response.1, ls);
|
2020-03-10 04:46:05 +00:00
|
|
|
}
|
|
|
|
|
}
|