xous: hosted: remove excess debug from network packets

These packets were always printed, which is excessive.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-11-23 16:15:19 +08:00
parent 8c05fa99d2
commit 98fb7f739d

View file

@ -430,8 +430,11 @@ pub fn _xous_syscall(
let call = crate::SysCall::from_args(nr, a1, a2, a3, a4, a5, a6, a7).unwrap(); let call = crate::SysCall::from_args(nr, a1, a2, a3, a4, a5, a6, a7).unwrap();
{ {
CALL_FOR_THREAD.with(|cft| { CALL_FOR_THREAD.with(|cft| {
eprintln!("Inserting TID for {}", *tid.borrow()); let cft_rc = cft.borrow();
cft.borrow().lock().unwrap().insert(*tid.borrow(), call) let mut cft_mtx = cft_rc.lock().unwrap();
let tid = *tid.borrow();
assert!(cft_mtx.get(&tid).is_none());
cft_mtx.insert(tid, call)
}); });
} }
let call = crate::SysCall::from_args(nr, a1, a2, a3, a4, a5, a6, a7).unwrap(); let call = crate::SysCall::from_args(nr, a1, a2, a3, a4, a5, a6, a7).unwrap();
@ -528,9 +531,9 @@ fn _xous_syscall_result(ret: &mut Result, thread_id: TID, server_connection: &Se
} }
// Determine if this thread will have a memory packet following it. // Determine if this thread will have a memory packet following it.
eprintln!("Removing value for TID {}", msg_thread_id);
let call = CALL_FOR_THREAD.with(|cft| { let call = CALL_FOR_THREAD.with(|cft| {
cft.borrow().lock() cft.borrow()
.lock()
.unwrap() .unwrap()
.remove(&msg_thread_id) .remove(&msg_thread_id)
.expect("thread didn't declare whether it has data") .expect("thread didn't declare whether it has data")
@ -570,15 +573,15 @@ fn _xous_syscall_result(ret: &mut Result, thread_id: TID, server_connection: &Se
if call.is_borrow() || call.is_mutableborrow() { if call.is_borrow() || call.is_mutableborrow() {
// Read the buffer back from the remote host. // Read the buffer back from the remote host.
use core::slice; use core::slice;
let data = let mut data = unsafe { slice::from_raw_parts_mut(mem.as_mut_ptr(), mem.len()) };
unsafe { slice::from_raw_parts_mut(mem.addr.get() as _, mem.size.get()) };
// If it's a Borrow, verify the contents haven't changed.
let previous_data = if call.is_borrow() { let previous_data = if call.is_borrow() {
Some(data.to_vec()) Some(data.to_vec())
} else { } else {
None None
}; };
let mut data = vec![0];
data.resize_with(mem.len(), Default::default);
if let Err(e) = stream.read_exact(&mut data) { if let Err(e) = stream.read_exact(&mut data) {
eprintln!("Server shut down: {}", e); eprintln!("Server shut down: {}", e);
std::process::exit(0); std::process::exit(0);
@ -597,6 +600,8 @@ fn _xous_syscall_result(ret: &mut Result, thread_id: TID, server_connection: &Se
mem::unmap_memory_post(mem).unwrap(); mem::unmap_memory_post(mem).unwrap();
} }
// If we're returning memory to the Server, then reconstitute the buffer we just passed,
// and Drop it so it can be freed.
if call.is_return_memory() { if call.is_return_memory() {
let rebuilt = let rebuilt =
unsafe { Vec::from_raw_parts(mem.as_mut_ptr(), mem.len(), mem.len()) }; unsafe { Vec::from_raw_parts(mem.as_mut_ptr(), mem.len(), mem.len()) };
@ -651,7 +656,7 @@ fn _xous_syscall_to(
if let Some(memory) = call.memory() { if let Some(memory) = call.memory() {
use core::slice; use core::slice;
let data: &[u8] = let data: &[u8] =
unsafe { slice::from_raw_parts(memory.addr.get() as _, memory.size.get()) }; unsafe { slice::from_raw_parts(memory.as_ptr(), memory.len()) };
pkt.extend_from_slice(data); pkt.extend_from_slice(data);
} }