kernel: add debug command to print interrupts

This can be used to ensure the interrupt handlers are where we think
they are.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-10-29 14:57:05 +08:00 committed by bunnie
parent 2962d4ffc3
commit 75116d36cd
2 changed files with 30 additions and 0 deletions

View file

@ -167,6 +167,21 @@ fn process_irq_character(b: u8) {
}
match b {
b'i' => {
println!("Interrupt handlers:");
println!(" IRQ | Process | Handler | Argument");
crate::services::SystemServices::with(|system_services| {
crate::irq::for_each_irq(|irq, pid, address, arg| {
println!(
" {}: {} @ {:x?} {:x?}",
irq,
system_services.process_name(*pid).unwrap_or(""),
address,
arg
);
});
});
}
b'm' => {
println!("Printing memory page tables");
crate::services::SystemServices::with(|system_services| {
@ -268,6 +283,7 @@ fn process_irq_character(b: u8) {
println!("--- + -----------------------");
#[cfg(all(feature = "gdbserver", baremetal))]
println!(" g | enter the gdb server");
println!(" i | print irq handlers");
println!(" m | print MMU page tables of all processes");
println!(" p | print all processes");
println!(" P | print all processes and threads");

View file

@ -44,6 +44,20 @@ pub fn handle(irqs_pending: usize) -> Result<xous_kernel::Result, xous_kernel::E
Ok(xous_kernel::Result::ResumeProcess)
}
pub fn for_each_irq<F>(op: F)
where
F: Fn(usize, &PID, MemoryAddress, Option<MemoryAddress>),
{
unsafe {
for (idx, handler) in IRQ_HANDLERS.iter().enumerate() {
// Ignore threads that have no PC, and ignore the ISR thread
if let Some(handler) = handler {
op(idx, &handler.0, handler.1, handler.2);
}
}
}
}
pub fn interrupt_claim(
irq: usize,
pid: PID,