1 /* See COPYRIGHT for copyright information. */
10 #include <arch/console.h>
11 #include <arch/perfmon.h>
12 #include <arch/init.h>
17 struct ancillary_state x86_default_fpu;
20 #define capchar2ctl(x) ((x) - '@')
22 /* irq handler for the console (kb, serial, etc) */
23 static void irq_console(struct hw_trapframe *hw_tf, void *data)
26 struct cons_dev *cdev = (struct cons_dev*)data;
28 if (cons_get_char(cdev, &c))
30 /* Control code intercepts */
32 case capchar2ctl('G'):
33 /* traditional 'ctrl-g', will put you in the monitor gracefully */
34 send_kernel_message(core_id(), __run_mon, 0, 0, 0, KMSG_ROUTINE);
36 case capchar2ctl('Q'):
37 /* force you into the monitor. you might deadlock. */
38 printk("\nForcing entry to the monitor\n");
41 case capchar2ctl('B'):
42 /* backtrace / debugging for the core receiving the irq */
43 printk("\nForced trapframe and backtrace for core %d\n", core_id());
45 printk("(no hw_tf, we probably polled the console)\n");
48 print_trapframe(hw_tf);
49 backtrace_kframe(hw_tf);
52 /* Do our work in an RKM, instead of interrupt context. Note the RKM will
53 * cast 'c' to a char. */
54 send_kernel_message(core_id(), __cons_add_char, (long)&cons_buf, (long)c,
58 static void cons_poller(void *arg)
66 static void cons_irq_init(void)
69 /* Register interrupt handlers for all console devices */
70 SLIST_FOREACH(i, &cdev_list, next) {
71 register_irq(i->irq, irq_console, i, MKBUS(BusISA, 0, 0, 0));
72 #ifdef CONFIG_POLL_CONSOLE
73 ktask("cons_poller", cons_poller, i);
74 #endif /* CONFIG_POLL_CONSOLE */
80 /* need to reinit before saving, in case boot agents used the FPU or it is
81 * o/w dirty. had this happen on c89, which had a full FP stack after
83 asm volatile ("fninit");
84 save_fp_state(&x86_default_fpu); /* used in arch/trap.h for fpu init */
87 // this returns when all other cores are done and ready to receive IPIs
88 #ifdef CONFIG_SINGLE_CORE
99 check_timing_stability();