add debug telemetry for keyboard connect error

sometimes on boot, a process tries to send keyboard an incorrectly
formatted message. I think this might be the IOX interrupt handler
firing due to random noise. Corrective action towards debugging
includes instrumenting the keyboard call with debug info, and also
ensuring that the iox interrupt handler banks are initialized to 0.
This commit is contained in:
bunnie 2025-11-29 15:49:40 +08:00
parent 18dd921cb8
commit 7d7fa75e7d
2 changed files with 28 additions and 12 deletions

View file

@ -244,6 +244,13 @@ fn main() {
.expect("couldn't claim IRQ control page");
let irq_csr = CSR::new(irq_page.as_mut_ptr() as *mut u32);
let mut irq = IrqHandler { irq_csr, cid: self_cid };
// ensure that iox interrupts are gated off by default
for index in 0..8 {
unsafe {
iox.csr.base().add(utralib::utra::iox::SFR_INTCR_CRINT0.offset()).add(index).write_volatile(0);
}
}
iox.csr.wo(utra::iox::SFR_INTFR, 0);
xous::claim_interrupt(
utralib::utra::irqarray10::IRQARRAY10_IRQ,
iox_irq_handler,

View file

@ -306,20 +306,29 @@ fn keyboard_service() {
}
}
Some(KeyboardOpcode::RegisterKeyObserver) => {
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
let kr = buffer.as_flat::<KeyboardRegistration, _>().unwrap();
if observer_conn.is_none() {
match xns.request_connection_blocking(kr.server_name.as_str()) {
Ok(cid) => {
observer_conn = Some(cid);
observer_op = Some(<u32 as From<u32>>::from(kr.listener_op_id.into()) as usize);
}
Err(e) => {
log::error!("couldn't connect to observer: {:?}", e);
observer_conn = None;
observer_op = None;
if msg.body.has_memory() {
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
let kr = buffer.as_flat::<KeyboardRegistration, _>().unwrap();
if observer_conn.is_none() {
match xns.request_connection_blocking(kr.server_name.as_str()) {
Ok(cid) => {
observer_conn = Some(cid);
observer_op =
Some(<u32 as From<u32>>::from(kr.listener_op_id.into()) as usize);
}
Err(e) => {
log::error!("couldn't connect to observer: {:?}", e);
observer_conn = None;
observer_op = None;
}
}
}
} else {
log::error!(
"RegisterKeyObserver got incorrect argument; ignoring! From PID {:?}: {:?}",
msg.sender.pid(),
msg
);
}
}
Some(KeyboardOpcode::SelectKeyMap) => {