Patch adds support of USB keyboard attached to UHCI in KDB.
Whole UHCI irq handler(uhci_irq) is called
periodically by KDB poll code when irqs are disabled.
I've tested patch with em64t pentiumd. USB keyboard attached to UHCI
works OK except there is 1 issue: auto reply of pressed key doesn't
work, but I don't think that is a critical issue.

Patch against 2.6.23-rc8.

Signed-off-by: Konstantin Baydarov <[EMAIL PROTECTED]>

 arch/i386/Kconfig.debug     |    4 ++--
 drivers/char/keyboard.c     |   11 +++++++++++
 drivers/usb/host/uhci-hcd.c |   36 ++++++++++++++++++++++++++++++++++++
 include/linux/kdb.h         |    1 +
 kdb/kdbmain.c               |    1 +
 5 files changed, 51 insertions(+), 2 deletions(-)

Index: linux-2.6.23-rc8/drivers/usb/host/uhci-hcd.c
===================================================================
--- linux-2.6.23-rc8.orig/drivers/usb/host/uhci-hcd.c
+++ linux-2.6.23-rc8/drivers/usb/host/uhci-hcd.c
@@ -41,6 +41,10 @@
 #include <linux/bitops.h>
 #include <linux/dmi.h>
 
+#ifdef CONFIG_KDB_USB
+#include <linux/kdb.h>
+#endif
+
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -427,9 +431,37 @@ static irqreturn_t uhci_irq(struct usb_h
                spin_unlock_irqrestore(&uhci->lock, flags);
        }
 
+#ifdef CONFIG_KDB_USB
+       if (kdb_kbd_delay_enter){
+               kdb_kbd_delay_enter = 0;
+#ifndef CONFIG_PREEMPT_HARDIRQS
+               kdb(KDB_REASON_KEYBOARD, 0, get_irq_regs());
+#else
+               KDB_ENTER();
+#endif
+       }
+#endif
+
        return IRQ_HANDLED;
 }
 
+#ifdef CONFIG_KDB_USB
+void
+uhci_kdb_poll (void * __uhci, struct urb *urb)
+{
+       /*
+        * NOTE - we use the uhci_hcd from the urb rather than the
+        * __uhci parameter (which is NULL anyway). This ensures
+        * that we will process the proper controller for the urb.
+        */
+
+       if (!urb) /* can happen if no keyboard attached */
+               return;
+
+       uhci_irq(bus_to_hcd(urb->dev->bus));
+}
+#endif /* CONFIG_KDB_USB */
+
 /*
  * Store the current frame number in uhci->frame_number if the controller
  * is runnning.  Expand from 11 bits (of which we use only 10) to a
@@ -661,6 +693,10 @@ static int uhci_start(struct usb_hcd *hc
        configure_hc(uhci);
        uhci->is_initialized = 1;
        start_rh(uhci);
+#ifdef CONFIG_KDB_USB
+       kdb_usb_infos.poll_func = uhci_kdb_poll;
+       kdb_usb_infos.uhci = NULL; /* not used */
+#endif
        return 0;
 
 /*
Index: linux-2.6.23-rc8/drivers/char/keyboard.c
===================================================================
--- linux-2.6.23-rc8.orig/drivers/char/keyboard.c
+++ linux-2.6.23-rc8/drivers/char/keyboard.c
@@ -43,6 +43,7 @@
 #include <linux/reboot.h>
 #ifdef CONFIG_KDB
 #include <linux/kdb.h>
+void uhci_kdb_poll (void * __uhci, struct urb *urb);
 #endif /* CONFIG_KDB */
 
 extern void ctrl_alt_del(void);
@@ -1149,6 +1150,16 @@ static void kbd_keycode(unsigned int key
 
 #ifdef CONFIG_KDB
        if (down && !rep && keycode == KEY_PAUSE && kdb_on == 1) {
+#ifdef CONFIG_KDB_USB
+               /* Is this USB keyboard attached to UHCI ? */
+               if ((kdb_usb_infos.poll_func == uhci_kdb_poll)
+                               && kdb_usb_infos.urb)
+                       /* uhci_irq should be completed before kernel
+                        * enters KDB
+                        */
+                       kdb_kbd_delay_enter = 1;
+               else
+#endif
                kdb(KDB_REASON_KEYBOARD, 0, get_irq_regs());
                return;
        }
Index: linux-2.6.23-rc8/include/linux/kdb.h
===================================================================
--- linux-2.6.23-rc8.orig/include/linux/kdb.h
+++ linux-2.6.23-rc8/include/linux/kdb.h
@@ -162,5 +162,6 @@ int kdb_process_cpu(const struct task_st
 }
 
 extern const char kdb_serial_str[];
+extern int kdb_kbd_delay_enter;
 
 #endif /* !_KDB_H */
Index: linux-2.6.23-rc8/kdb/kdbmain.c
===================================================================
--- linux-2.6.23-rc8.orig/kdb/kdbmain.c
+++ linux-2.6.23-rc8/kdb/kdbmain.c
@@ -53,6 +53,7 @@
 volatile int kdb_flags;
 atomic_t kdb_event;
 atomic_t kdb_8250;
+int kdb_kbd_delay_enter = 0;
 
 /*
  * kdb_lock protects updates to kdb_initial_cpu.  Used to
Index: linux-2.6.23-rc8/arch/i386/Kconfig.debug
===================================================================
--- linux-2.6.23-rc8.orig/arch/i386/Kconfig.debug
+++ linux-2.6.23-rc8/arch/i386/Kconfig.debug
@@ -156,8 +156,8 @@ config KDB_CONTINUE_CATASTROPHIC
          setting to 2.
 
 config KDB_USB
-       bool "Support for USB Keyboard in KDB (OHCI only)"
-       depends on KDB && USB_OHCI_HCD
+       bool "Support for USB Keyboard in KDB (OHCI and UHCI only)"
+       depends on KDB && (USB_OHCI_HCD || USB_UHCI_HCD)
        help
          If you want to use kdb from a OHCI USB keyboard then say Y here.  If 
you
          say N then kdb can only be used from a PC (AT) keyboard or a serial
---------------------------
Use http://oss.sgi.com/ecartis to modify your settings or to unsubscribe.

Reply via email to