mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
kernel: change some println!s to klog!s
Even when the print-debug feature isn't turned on, println! macro is still able to output some critical non-debug info to the console such as panics, process crashes and violations, etc. Debugging messages are printed with klog! macro that's disabled when debug-print feature is not set.
This commit is contained in:
parent
89a1447df4
commit
7f5656445a
4 changed files with 19 additions and 19 deletions
|
|
@ -22,7 +22,7 @@ pub fn handle(irqs_pending: usize) -> Result<xous_kernel::Result, xous_kernel::E
|
||||||
return SystemServices::with_mut(|ss| {
|
return SystemServices::with_mut(|ss| {
|
||||||
// Disable all other IRQs and redirect into userspace
|
// Disable all other IRQs and redirect into userspace
|
||||||
arch::irq::disable_all_irqs();
|
arch::irq::disable_all_irqs();
|
||||||
// println!("Making a callback to PID{}: {:x?} ({:08x}, {:x?})", pid, f, irq_no as usize, arg);
|
klog!("Making a callback to PID{}: {:x?} ({:08x}, {:x?})", pid, f, irq_no as usize, arg);
|
||||||
ss.make_callback_to(
|
ss.make_callback_to(
|
||||||
*pid,
|
*pid,
|
||||||
f.get() as *mut usize,
|
f.get() as *mut usize,
|
||||||
|
|
@ -33,6 +33,7 @@ pub fn handle(irqs_pending: usize) -> Result<xous_kernel::Result, xous_kernel::E
|
||||||
.map(|_| xous_kernel::Result::ResumeProcess)
|
.map(|_| xous_kernel::Result::ResumeProcess)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
klog!("[!] Masked an unhandled IRQ #{:?}", irq_no);
|
||||||
// If there is no handler, mask this interrupt
|
// If there is no handler, mask this interrupt
|
||||||
// to prevent an IRQ storm. This is considered
|
// to prevent an IRQ storm. This is considered
|
||||||
// an error.
|
// an error.
|
||||||
|
|
|
||||||
|
|
@ -126,13 +126,13 @@ pub extern "C" fn kmain() {
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
#[cfg(feature = "debug-print")]
|
#[cfg(feature = "debug-print")]
|
||||||
println!("NO RUNNABLE TASKS FOUND, entering idle state");
|
klog!("NO RUNNABLE TASKS FOUND, entering idle state");
|
||||||
|
|
||||||
#[cfg(feature = "debug-print")]
|
#[cfg(feature = "debug-print")]
|
||||||
SystemServices::with(|system_services| {
|
SystemServices::with(|system_services| {
|
||||||
for (test_idx, process) in system_services.processes.iter().enumerate() {
|
for (test_idx, process) in system_services.processes.iter().enumerate() {
|
||||||
if !process.free() {
|
if !process.free() {
|
||||||
println!("PID {}: {:?}", test_idx + 1, process);
|
klog!("PID {}: {:?}", test_idx + 1, process);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -491,7 +491,7 @@ impl SystemServices {
|
||||||
// PID0 doesn't exist -- process IDs are offset by 1.
|
// PID0 doesn't exist -- process IDs are offset by 1.
|
||||||
let pid_idx = pid.get() as usize - 1;
|
let pid_idx = pid.get() as usize - 1;
|
||||||
if cfg!(baremetal) && self.processes[pid_idx].mapping.get_pid() != pid {
|
if cfg!(baremetal) && self.processes[pid_idx].mapping.get_pid() != pid {
|
||||||
println!(
|
klog!(
|
||||||
"Process doesn't match ({} vs {})",
|
"Process doesn't match ({} vs {})",
|
||||||
self.processes[pid_idx].mapping.get_pid(),
|
self.processes[pid_idx].mapping.get_pid(),
|
||||||
pid
|
pid
|
||||||
|
|
@ -1049,7 +1049,7 @@ impl SystemServices {
|
||||||
// Ensure the new process can be run.
|
// Ensure the new process can be run.
|
||||||
match new.state {
|
match new.state {
|
||||||
ProcessState::Free => {
|
ProcessState::Free => {
|
||||||
println!("PID {} was free", new_pid);
|
klog!("PID {} was free", new_pid);
|
||||||
return Err(xous_kernel::Error::ProcessNotFound);
|
return Err(xous_kernel::Error::ProcessNotFound);
|
||||||
}
|
}
|
||||||
ProcessState::Setup(_) | ProcessState::Allocated => new_tid = INITIAL_TID,
|
ProcessState::Setup(_) | ProcessState::Allocated => new_tid = INITIAL_TID,
|
||||||
|
|
|
||||||
|
|
@ -367,11 +367,11 @@ fn return_memory(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
WaitingMessage::ScalarMessage(_pid, _tid) => {
|
WaitingMessage::ScalarMessage(_pid, _tid) => {
|
||||||
println!("WARNING: Tried to wait on a message that was a scalar");
|
klog!("WARNING: Tried to wait on a message that was a scalar");
|
||||||
return Err(xous_kernel::Error::DoubleFree);
|
return Err(xous_kernel::Error::DoubleFree);
|
||||||
}
|
}
|
||||||
WaitingMessage::None => {
|
WaitingMessage::None => {
|
||||||
println!("WARNING: Tried to wait on a message that didn't exist -- return memory");
|
klog!("WARNING: Tried to wait on a message that didn't exist -- return memory");
|
||||||
return Err(xous_kernel::Error::DoubleFree);
|
return Err(xous_kernel::Error::DoubleFree);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -463,25 +463,25 @@ fn return_result(
|
||||||
let (client_pid, client_tid) = match result {
|
let (client_pid, client_tid) = match result {
|
||||||
WaitingMessage::ScalarMessage(pid, tid) => (pid, tid),
|
WaitingMessage::ScalarMessage(pid, tid) => (pid, tid),
|
||||||
WaitingMessage::ForgetMemory(_) => {
|
WaitingMessage::ForgetMemory(_) => {
|
||||||
println!(
|
klog!(
|
||||||
"WARNING: Tried to wait on a scalar message that was actually forgettingmemory"
|
"WARNING: Tried to wait on a scalar message that was actually forgettingmemory"
|
||||||
);
|
);
|
||||||
return Err(xous_kernel::Error::DoubleFree);
|
return Err(xous_kernel::Error::DoubleFree);
|
||||||
}
|
}
|
||||||
WaitingMessage::BorrowedMemory(_, _, _, _, _) => {
|
WaitingMessage::BorrowedMemory(_, _, _, _, _) => {
|
||||||
println!(
|
klog!(
|
||||||
"WARNING: Tried to wait on a scalar message that was actually borrowed memory"
|
"WARNING: Tried to wait on a scalar message that was actually borrowed memory"
|
||||||
);
|
);
|
||||||
return Err(xous_kernel::Error::DoubleFree);
|
return Err(xous_kernel::Error::DoubleFree);
|
||||||
}
|
}
|
||||||
WaitingMessage::MovedMemory => {
|
WaitingMessage::MovedMemory => {
|
||||||
println!(
|
klog!(
|
||||||
"WARNING: Tried to wait on a scalar message that was actually moved memory"
|
"WARNING: Tried to wait on a scalar message that was actually moved memory"
|
||||||
);
|
);
|
||||||
return Err(xous_kernel::Error::DoubleFree);
|
return Err(xous_kernel::Error::DoubleFree);
|
||||||
}
|
}
|
||||||
WaitingMessage::None => {
|
WaitingMessage::None => {
|
||||||
println!("WARNING ({}:{}): Tried to wait on a message that didn't exist (irq? {}) -- return {:?}", server_pid.get(), server_tid, if in_irq { "yes"} else {"no"}, result);
|
klog!("WARNING ({}:{}): Tried to wait on a message that didn't exist (irq? {}) -- return {:?}", server_pid.get(), server_tid, if in_irq { "yes"} else {"no"}, result);
|
||||||
return Err(xous_kernel::Error::DoubleFree);
|
return Err(xous_kernel::Error::DoubleFree);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -581,7 +581,7 @@ fn reply_and_receive_next(
|
||||||
MessageResponse { pid, tid, result }
|
MessageResponse { pid, tid, result }
|
||||||
}
|
}
|
||||||
WaitingMessage::ForgetMemory(_) => {
|
WaitingMessage::ForgetMemory(_) => {
|
||||||
println!(
|
klog!(
|
||||||
"WARNING: Tried to wait on a scalar message that was actually forgetting memory"
|
"WARNING: Tried to wait on a scalar message that was actually forgetting memory"
|
||||||
);
|
);
|
||||||
return Err(xous_kernel::Error::DoubleFree);
|
return Err(xous_kernel::Error::DoubleFree);
|
||||||
|
|
@ -605,13 +605,13 @@ fn reply_and_receive_next(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WaitingMessage::MovedMemory => {
|
WaitingMessage::MovedMemory => {
|
||||||
println!(
|
klog!(
|
||||||
"WARNING: Tried to wait on a scalar message that was actually moved memory"
|
"WARNING: Tried to wait on a scalar message that was actually moved memory"
|
||||||
);
|
);
|
||||||
return Err(xous_kernel::Error::DoubleFree);
|
return Err(xous_kernel::Error::DoubleFree);
|
||||||
}
|
}
|
||||||
WaitingMessage::None => {
|
WaitingMessage::None => {
|
||||||
println!("WARNING: Tried to wait on a message that didn't exist -- receive and return scalar");
|
klog!("WARNING: Tried to wait on a message that didn't exist -- receive and return scalar");
|
||||||
return Err(xous_kernel::Error::DoubleFree);
|
return Err(xous_kernel::Error::DoubleFree);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -745,12 +745,12 @@ fn receive_message(pid: PID, tid: TID, sid: SID, blocking: ExecutionType) -> Sys
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallResult {
|
pub fn handle(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallResult {
|
||||||
#[cfg(feature = "debug-print")]
|
klog!("KERNEL({}:{}): Syscall {:x?}, in_irq={}", pid, tid, call, in_irq);
|
||||||
print!("KERNEL({}:{}): Syscall {:x?}", pid, tid, call);
|
|
||||||
// let call_string = format!("{:x?}", call);
|
// let call_string = format!("{:x?}", call);
|
||||||
// let start_time = std::time::Instant::now();
|
// let start_time = std::time::Instant::now();
|
||||||
#[allow(clippy::let_and_return)]
|
#[allow(clippy::let_and_return)]
|
||||||
let result = if in_irq && !call.can_call_from_interrupt() {
|
let result = if in_irq && !call.can_call_from_interrupt() {
|
||||||
|
klog!("[!] Called {:?} that's cannot be called from the interrupt handler!", call);
|
||||||
Err(xous_kernel::Error::InvalidSyscall)
|
Err(xous_kernel::Error::InvalidSyscall)
|
||||||
} else {
|
} else {
|
||||||
handle_inner(pid, tid, in_irq, call)
|
handle_inner(pid, tid, in_irq, call)
|
||||||
|
|
@ -758,8 +758,7 @@ pub fn handle(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallResult
|
||||||
|
|
||||||
// println!("KERNEL [{:2}:{:2}] Syscall took {:7} usec: {}", pid, tid, start_time.elapsed().as_micros(), call_string);
|
// println!("KERNEL [{:2}:{:2}] Syscall took {:7} usec: {}", pid, tid, start_time.elapsed().as_micros(), call_string);
|
||||||
|
|
||||||
#[cfg(feature = "debug-print")]
|
klog!(
|
||||||
println!(
|
|
||||||
" -> ({}:{}) {:x?}",
|
" -> ({}:{}) {:x?}",
|
||||||
crate::arch::current_pid(),
|
crate::arch::current_pid(),
|
||||||
crate::arch::process::Process::current().current_tid(),
|
crate::arch::process::Process::current().current_tid(),
|
||||||
|
|
@ -785,7 +784,7 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
|
||||||
.map(|x| x.get() >= arch::mem::USER_AREA_END)
|
.map(|x| x.get() >= arch::mem::USER_AREA_END)
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
{
|
{
|
||||||
println!("Exceeded user area");
|
klog!("Exceeded user area");
|
||||||
return Err(xous_kernel::Error::BadAddress);
|
return Err(xous_kernel::Error::BadAddress);
|
||||||
|
|
||||||
// Don't allow mapping non-page values
|
// Don't allow mapping non-page values
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue