x86: initializes the LPC
[akaros.git] / kern / arch / x86 / init.c
index fc5dac5..e143cc9 100644 (file)
@@ -12,6 +12,7 @@
 #include <arch/init.h>
 #include <console.h>
 #include <monitor.h>
+#include <arch/usb.h>
 
 struct ancillary_state x86_default_fpu;
 uint32_t kerndate;
@@ -40,6 +41,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 +55,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)
-               register_dev_irq(i->irq, irq_console, i, -1);
+       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()
@@ -76,5 +93,7 @@ void arch_init()
 
        perfmon_init();
        cons_irq_init();
+       intel_lpc_init();
+       usb_disable_legacy();
        check_timing_stability();
 }