x86: console polling ktasks
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 1 Apr 2014 17:57:05 +0000 (10:57 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 1 Apr 2014 17:57:05 +0000 (10:57 -0700)
For the AMD boards from which we can't get IRQs.  Turn on via Kconfig.

kern/arch/x86/Kconfig
kern/arch/x86/init.c

index d55bdca..a5ea74d 100644 (file)
@@ -37,6 +37,13 @@ endmenu
 
 menu "x86 Hacks"
 
+config POLL_CONSOLE
+       bool "Poll Console Devices"
+       default n
+       help
+               On some boards, we have trouble getting the serial IRQ.  This will
+               spawn ktasks for all console devices that poll every 10ms.  
+
 config LOUSY_LAPIC_TIMER
        bool "Lousy Local APIC Timer"
        default n
index 3eb9ced..583ddde 100644 (file)
@@ -40,6 +40,10 @@ static void irq_console(struct hw_trapframe *hw_tf, void *data)
                case capchar2ctl('B'):
                        /* backtrace / debugging for the core receiving the irq */
                        printk("\nForced trapframe and backtrace for core %d\n", core_id());
+                       if (!hw_tf) {
+                               printk("(no hw_tf, we probably polled the console)\n");
+                               return;
+                       }
                        print_trapframe(hw_tf);
                        backtrace_kframe(hw_tf);
                        return;
@@ -50,12 +54,24 @@ static void irq_console(struct hw_trapframe *hw_tf, void *data)
                            0, KMSG_ROUTINE);
 }
 
+static void cons_poller(void *arg)
+{
+       while (1) {
+               udelay_sched(10000);
+               irq_console(0, arg);
+       }
+}
+
 static void cons_irq_init(void)
 {
        struct cons_dev *i;
        /* Register interrupt handlers for all console devices */
-       SLIST_FOREACH(i, &cdev_list, next)
+       SLIST_FOREACH(i, &cdev_list, next) {
                register_irq(i->irq, irq_console, i, MKBUS(BusISA, 0, 0, 0));
+#ifdef CONFIG_POLL_CONSOLE
+               ktask("cons_poller", cons_poller, i);
+#endif /* CONFIG_POLL_CONSOLE */
+       }
 }
 
 void arch_init()