clean up log messages now that we can identify the logging source

This commit is contained in:
bunnie 2021-04-02 03:10:13 +08:00
parent 68b9addd45
commit 5a6ce66d7e
3 changed files with 42 additions and 42 deletions

View file

@ -192,7 +192,7 @@ mod implementation {
#[cfg(feature = "debug-print")]
{
log::info!(
"TickTimer: Stopping currently-running timer sr.msec: {} elapsed_ms: {}",
"Stopping currently-running timer sr.msec: {} elapsed_ms: {}",
sr.msec,
self.elapsed_ms()
);
@ -207,7 +207,7 @@ mod implementation {
let irq_target = request.msec;
#[cfg(feature = "debug-print")]
log::info!(
"TickTimer: setting a response at {} ms (current time: {} ms)",
"setting a response at {} ms (current time: {} ms)",
irq_target,
self.elapsed_ms()
);
@ -386,35 +386,35 @@ fn recalculate_sleep(
// If there's a sleep request ongoing now, grab it.
if let Some(current) = ticktimer.stop_interrupt() {
#[cfg(feature = "debug-print")]
info!("TickTimer: Existing request was {:?}", current);
info!("Existing request was {:?}", current);
sleep_heap.push(current).expect("couldn't push to heap")
} else {
#[cfg(feature = "debug-print")]
info!("TickTimer: There was no existing request");
info!("There was no existing request");
}
// If we have a new sleep request, add it to the heap.
if let Some(mut request) = new {
#[cfg(feature = "debug-print")]
info!("TickTimer: New sleep request was: {:?}", request);
info!("New sleep request was: {:?}", request);
request.msec += ticktimer.elapsed_ms() as i64;
#[cfg(feature = "debug-print")]
info!("TickTimer: Modified, the request was: {:?}", request);
info!("Modified, the request was: {:?}", request);
sleep_heap
.push(request)
.expect("couldn't push new sleep to heap");
} else {
#[cfg(feature = "debug-print")]
info!("TickTimer: No new sleep request");
info!("No new sleep request");
}
// If there are items in the sleep heap, take the next item that will expire.
if let Some(next_response) = sleep_heap.pop() {
#[cfg(feature = "debug-print")]
info!(
"TickTimer: scheduling a response at {} to {} (heap: {:?})",
"scheduling a response at {} to {} (heap: {:?})",
next_response.msec, next_response.sender, sleep_heap
);
ticktimer.schedule_response(next_response);
@ -429,11 +429,11 @@ fn xmain() -> ! {
let mut sleep_heap: BinaryHeap<SleepRequest, U32, Min> = BinaryHeap::new();
log_server::init_wait().unwrap();
info!("TICKTIMER: my PID is {}", xous::process::id());
info!("my PID is {}", xous::process::id());
let ticktimer_server = xous::create_server_with_address(b"ticktimer-server")
.expect("Couldn't create Ticktimer server");
info!("TICKTIMER: Server started with SID {:?}", ticktimer_server);
info!("Server started with SID {:?}", ticktimer_server);
// Connect to our own server so we can send the "Recalculate" message
let ticktimer_client = xous::connect(xous::SID::from_bytes(b"ticktimer-server").unwrap())
@ -456,7 +456,7 @@ fn xmain() -> ! {
(time & 0xFFFF_FFFFi64) as usize,
((time >> 32) & 0xFFF_FFFFi64) as usize,
)
.expect("TICKTIMER: couldn't return time request");
.expect("couldn't return time request");
}
Some(api::Opcode::SleepMs) => {
if let xous::Message::BlockingScalar(xous::ScalarMessage {
@ -475,7 +475,7 @@ fn xmain() -> ! {
recalculate_sleep(&mut ticktimer, &mut sleep_heap, None);
}
None => {
error!("TICTKIMER: couldn't convert opcode");
error!("couldn't convert opcode");
}
}
}

View file

@ -61,7 +61,7 @@ mod implementation {
| trng.csr.ms(utra::trng_server::RO_CONFIG_OVERSAMPLING, 3)
);
info!("TRNG: hardware initialized");
info!("hardware initialized");
trng
}
@ -133,7 +133,7 @@ mod implementation {
pub fn wait_full(&self) { }
pub fn get_trng(&mut self, _count: usize) -> [u32; 2] {
info!("TRNG: hosted mode TRNG is *not* random, it is an LFSR");
info!("hosted mode TRNG is *not* random, it is an LFSR");
let mut ret: [u32; 2] = [0; 2];
self.seed = self.move_lfsr(self.seed);
ret[0] = self.seed;
@ -150,11 +150,11 @@ fn xmain() -> ! {
use crate::implementation::Trng;
log_server::init_wait().unwrap();
info!("TRNG: my PID is {}", xous::process::id());
info!("my PID is {}", xous::process::id());
let xns = xous_names::XousNames::new().unwrap();
let trng_sid = xns.register_name(api::SERVER_NAME_TRNG).expect("TRNG: can't register server");
info!("TRNG: registered with NS -- {:?}", trng_sid);
let trng_sid = xns.register_name(api::SERVER_NAME_TRNG).expect("can't register server");
info!("registered with NS -- {:?}", trng_sid);
#[cfg(target_os = "none")]
let trng = Trng::new();
@ -162,7 +162,7 @@ fn xmain() -> ! {
#[cfg(not(target_os = "none"))]
let mut trng = Trng::new();
info!("TRNG: ready to accept requests");
info!("ready to accept requests");
loop {
let msg = xous::receive_message(trng_sid).unwrap();
@ -173,11 +173,11 @@ fn xmain() -> ! {
}) = msg.body {
let val: [u32; 2] = trng.get_trng(count);
xous::return_scalar2(msg.sender, val[0] as _, val[1] as _)
.expect("TRNG: couldn't return GetTrng request");
} else { log::error!("TRNG: GetTrng malformed message"); }
.expect("couldn't return GetTrng request");
} else { log::error!("GetTrng malformed message"); }
}
None => {
log::error!("TRNG: couldn't convert opcode")
log::error!("couldn't convert opcode")
}
}
}

View file

@ -22,7 +22,7 @@ const FAIL_TIMEOUT_MS: u64 = 100;
fn xmain() -> ! {
let debug1 = false;
log_server::init_wait().unwrap();
info!("NS: my PID is {}", xous::process::id());
info!("my PID is {}", xous::process::id());
let name_server = xous::create_server_with_address(b"xous-name-server")
.expect("Couldn't create xousnames-server");
@ -32,10 +32,10 @@ fn xmain() -> ! {
// this limits the number of available servers to be requested to 128...!
let mut name_table = FnvIndexMap::<_, _, U128>::new();
info!("NS: started");
info!("started");
loop {
let mut msg = xous::receive_message(name_server).unwrap();
if debug1{info!("NS: received message");}
if debug1{info!("received message");}
match FromPrimitive::from_usize(msg.body.id()) {
Some(api::Opcode::Register) => {
let mem = msg.body.memory_message_mut().unwrap();
@ -45,14 +45,14 @@ fn xmain() -> ! {
let response: api::Return;
if debug1{info!("NS: registration request for '{}'", name);}
if debug1{info!("registration request for '{}'", name);}
if !name_table.contains_key(&name) {
let new_sid =
xous::create_server_id().expect("NS: create server failed, maybe OOM?");
xous::create_server_id().expect("create server failed, maybe OOM?");
name_table
.insert(name, new_sid)
.expect("NS: register name failure, maybe out of HashMap capacity?");
if debug1{info!("NS: request successful, SID is {:?}", new_sid);}
.expect("register name failure, maybe out of HashMap capacity?");
if debug1{info!("request successful, SID is {:?}", new_sid);}
response = api::Return::SID(new_sid.into());
} else {
@ -61,11 +61,11 @@ fn xmain() -> ! {
/ FAIL_TIMEOUT_MS)
+ 1)
* FAIL_TIMEOUT_MS;
info!("NS: request failed, waiting for deterministic timeout");
info!("request failed, waiting for deterministic timeout");
while ticktimer.elapsed_ms() < target_time {
xous::yield_slice();
}
info!("NS: deterministic timeout done");
info!("deterministic timeout done");
response = api::Return::Failure
}
buffer.replace(response).unwrap();
@ -75,38 +75,38 @@ fn xmain() -> ! {
let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) };
let name_string = buffer.as_flat::<String::<64>, _>().unwrap();
let name = XousServerName::from_str(name_string.as_str());
if debug1{info!("NS: Lookup request for '{}'", name);}
if debug1{info!("Lookup request for '{}'", name);}
let response: api::Return;
if let Some(server_sid) = name_table.get(&name) {
let sender_pid = msg
.sender
.pid()
.expect("NS: can't extract sender PID on Lookup");
.expect("can't extract sender PID on Lookup");
match xous::connect_for_process(sender_pid, *server_sid)
.expect("NS: can't broker connection")
.expect("can't broker connection")
{
xous::Result::ConnectionID(connection_id) => {
if debug1{info!("NS: lookup success, returning connection {}", connection_id);}
if debug1{info!("lookup success, returning connection {}", connection_id);}
response = api::Return::CID(connection_id)
}
_ => {
info!(
"NS: Can't find request '{}' in table, dumping table:",
"Can't find request '{}' in table, dumping table:",
name
);
for (key, val) in name_table.iter() {
info!("NS: name: '{}', sid: '{:?}'", key, val);
info!("name: '{}', sid: '{:?}'", key, val);
}
response = api::Return::Failure
}
}
} else {
info!(
"NS: Can't find request '{}' in table, dumping table:",
"Can't find request '{}' in table, dumping table:",
name
);
for (key, val) in name_table.iter() {
info!("NS: name: '{}', sid: '{:?}'", key, val);
info!("name: '{}', sid: '{:?}'", key, val);
}
// no authenticate remedy currently supported, but we'd put that code somewhere around here eventually.
let (c1, c2, c3, c4) = xous::create_server_id().unwrap().to_u32();
@ -123,11 +123,11 @@ fn xmain() -> ! {
let mem = msg.body.memory_message_mut().unwrap();
let buffer = unsafe { Buffer::from_memory_message_mut(mem) };
let auth_lookup: AuthenticatedLookup = buffer.to_original().unwrap();
info!("NS: AuthenticatedLookup request {:?}", auth_lookup);
error!("NS: AuthenticatedLookup not yet implemented");
unimplemented!("NS: AuthenticatedLookup not yet implemented");
info!("AuthenticatedLookup request {:?}", auth_lookup);
error!("AuthenticatedLookup not yet implemented");
unimplemented!("AuthenticatedLookup not yet implemented");
}
None => error!("NS: couldn't decode message: {:?}", msg)
None => error!("couldn't decode message: {:?}", msg)
}
}
}