diff --git a/examples/graphics-server/Cargo.toml b/examples/graphics-server/Cargo.toml index 9e2ac4b26..93bf19fc0 100644 --- a/examples/graphics-server/Cargo.toml +++ b/examples/graphics-server/Cargo.toml @@ -14,3 +14,7 @@ utralib = { path = "../../utralib"} [target.'cfg(any(windows,unix))'.dependencies] minifb = "0.17" + +[features] +debugprint = [] +default = [] # "debugprint" diff --git a/examples/graphics-server/src/main.rs b/examples/graphics-server/src/main.rs index 43214d9df..b85028a86 100644 --- a/examples/graphics-server/src/main.rs +++ b/examples/graphics-server/src/main.rs @@ -1,6 +1,9 @@ #![cfg_attr(target_os = "none", no_std)] #![cfg_attr(target_os = "none", no_main)] +#[macro_use] +mod debug; + mod backend; use backend::XousDisplay; diff --git a/examples/shell/Cargo.toml b/examples/shell/Cargo.toml index 43e4242d3..86d4a68b8 100644 --- a/examples/shell/Cargo.toml +++ b/examples/shell/Cargo.toml @@ -16,4 +16,4 @@ utralib = { path = "../../utralib"} [features] debugprint = [] -default = [] # "debugprint" +default = ["debugprint"] # "debugprint" diff --git a/examples/shell/src/main.rs b/examples/shell/src/main.rs index c83ea0013..74003e04a 100644 --- a/examples/shell/src/main.rs +++ b/examples/shell/src/main.rs @@ -80,10 +80,6 @@ fn shell_main() -> ! { gpio.wfo(utra::gpio::UARTSEL_UARTSEL, 0); loop { - //println!("loop"); - println!("ticktimer request"); - let elapsed_time = ticktimer_server::elapsed_ms(ticktimer_conn).unwrap(); - println!("elapsed time: {}ms", elapsed_time); // println!("Sending a scalar message with id {}...", counter + 4096); // match xous::syscall::send_message( @@ -122,6 +118,15 @@ fn shell_main() -> ! { Err(e) => panic!("unable to draw to screen: {:?}", e), } } + println!("ticktimer request"); + /* + ticktimer_server::reset(ticktimer_conn); + */ + if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) { + println!("elapsed time: {}ms", elapsed_time); + } else { + println!("error requesting ticktimer!") + } let x1 = move_lfsr(lfsr); let y1 = move_lfsr(x1); let x2 = move_lfsr(y1); diff --git a/examples/ticktimer-server/Cargo.toml b/examples/ticktimer-server/Cargo.toml index 444dbdf8d..6ffdf22ab 100644 --- a/examples/ticktimer-server/Cargo.toml +++ b/examples/ticktimer-server/Cargo.toml @@ -14,4 +14,4 @@ utralib = { path = "../../utralib"} [features] debugprint = [] -default = ["debugprint"] +default = [] # "debugprint" diff --git a/examples/ticktimer-server/src/api.rs b/examples/ticktimer-server/src/api.rs index 83e8a62ec..3919811f5 100644 --- a/examples/ticktimer-server/src/api.rs +++ b/examples/ticktimer-server/src/api.rs @@ -14,9 +14,12 @@ impl<'a> core::convert::TryFrom<&'a Message> for Opcode { match message { Message::Scalar(m) => match m.id { 1 => Ok(Opcode::Reset), - 2 => Ok(Opcode::ElapsedMs), _ => Err("unrecognized opcode"), }, + Message::BlockingScalar(m) => match m.id { + 4919 => Ok(Opcode::ElapsedMs), + _ => Err("unrecognized opcode"), + } _ => Err("unhandled message type"), } } @@ -33,7 +36,7 @@ impl Into for Opcode { arg4: 0, }), Opcode::ElapsedMs => Message::BlockingScalar(ScalarMessage { - id: 2, + id: 4919, arg1: 0, arg2: 0, arg3: 0, diff --git a/examples/ticktimer-server/src/lib.rs b/examples/ticktimer-server/src/lib.rs index e301aa5bd..9d585271d 100644 --- a/examples/ticktimer-server/src/lib.rs +++ b/examples/ticktimer-server/src/lib.rs @@ -9,9 +9,16 @@ pub fn elapsed_ms(cid: CID) -> Result { if let xous::Result::Scalar2(upper, lower) = response { Ok(upper as u64 | ((lower as u64) << 32)) } else { - panic!("unexpected return value"); // or return Err(xous::Result::InternalError) + panic!("unexpected return value: {:#?}", response); } -} + /* // scalar1 experimental reply to see if this makes it any better. It doesn't. + if let xous::Result::Scalar1(lower) = response { + Ok(lower as u64) + } else { + panic!("unexpected return value: {:#?}", response); + } + */ + } pub fn reset(cid: CID) -> Result<(), xous::Error> { try_send_message(cid, api::Opcode::Reset.into()).map(|_| ()) diff --git a/examples/ticktimer-server/src/main.rs b/examples/ticktimer-server/src/main.rs index 12ea4de54..ae99f4dc8 100644 --- a/examples/ticktimer-server/src/main.rs +++ b/examples/ticktimer-server/src/main.rs @@ -59,12 +59,12 @@ fn xmain() -> ! { loop { println!("TickTimer: waiting for message"); let envelope = xous::receive_message(ticktimer_server).unwrap(); - println!("TickTimer: got message"); - // println!("TickTimer: Message: {:?}", envelope); + println!("TickTimer: Message: {:?}", envelope); if let Ok(opcode) = Opcode::try_from(&envelope.body) { - // println!("TickTimer: Opcode: {:?}", opcode); + println!("TickTimer: Opcode: {:?}", opcode); match opcode { Opcode::Reset => { + println!("TickTimer: reset called"); ticktimer.reset(); }, Opcode::ElapsedMs => { @@ -74,10 +74,11 @@ fn xmain() -> ! { (time & 0xFFFF_FFFFu64) as usize, ((time >> 32) & 0xFFF_FFFFu64) as usize, ).expect("TickTimer: couldn't return time request"); + println!("TickTimer: done returning value"); } } } else { - // println!("Couldn't convert opcode"); + println!("Couldn't convert opcode"); } } } diff --git a/kernel/src/syscall.rs b/kernel/src/syscall.rs index 4b17669c0..77924eee1 100644 --- a/kernel/src/syscall.rs +++ b/kernel/src/syscall.rs @@ -321,13 +321,13 @@ fn return_scalar(pid: PID, _tid: TID, sender: MessageSender, arg: usize) -> SysC ss.ready_thread(client_pid, client_tid)?; ss.switch_to_thread(client_pid, Some(client_tid))?; ss.set_thread_result(client_pid, client_tid, xous_kernel::Result::Scalar1(arg))?; - Ok(xous_kernel::Result::Ok) + Ok(xous_kernel::Result::Scalar1(arg)) }) } fn return_scalar2( - pid: PID, - _tid: TID, + server_pid: PID, + server_tid: TID, sender: MessageSender, arg1: usize, arg2: usize, @@ -341,7 +341,7 @@ fn return_scalar2( let server = ss .server_from_sidx_mut(sidx) .ok_or(xous_kernel::Error::ServerNotFound)?; - if server.pid != pid { + if server.pid != server_pid { return Err(xous_kernel::Error::ServerNotFound); } let result = server.take_waiting_message(sender.idx, None)?; @@ -369,13 +369,21 @@ fn return_scalar2( } }; ss.ready_thread(client_pid, client_tid)?; + ss.ready_thread(server_pid, server_tid)?; + + /* + ss.activate_process_thread(server_tid, client_pid, client_tid, false) + .map(|_| Ok(xous_kernel::Result::Scalar2(arg1, arg2))) + .unwrap_or(Err(xous_kernel::Error::ProcessNotFound))?;*/ + //ss.switch_from_thread(server_pid, server_tid)?; + ss.switch_to_thread(client_pid, Some(client_tid))?; ss.set_thread_result( client_pid, client_tid, xous_kernel::Result::Scalar2(arg1, arg2), )?; - Ok(xous_kernel::Result::Ok) + Ok(xous_kernel::Result::Scalar2(arg1, arg2)) }) } diff --git a/xous-rs/src/lib.rs b/xous-rs/src/lib.rs index ebe70e3ef..795e62f3d 100644 --- a/xous-rs/src/lib.rs +++ b/xous-rs/src/lib.rs @@ -53,9 +53,9 @@ macro_rules! maybe_main { use core::panic::PanicInfo; #[panic_handler] - fn handle_panic(_arg: &PanicInfo) -> ! { - // println!("PANIC!"); - // println!("Details: {:?}", arg); + fn handle_panic(arg: &PanicInfo) -> ! { + println!("PANIC!"); + println!("Details: {:?}", arg); xous::syscall::wait_event(); loop {} }