1 /* See COPYRIGHT for copyright information. */
9 #include <arch/mptables.h>
11 #include <arch/ioapic.h>
12 #include <arch/console.h>
13 #include <arch/perfmon.h>
14 #include <arch/init.h>
18 struct ancillary_state x86_default_fpu;
21 #define capchar2ctl(x) ((x) - '@')
23 /* irq handler for the console (kb, serial, etc) */
24 static void irq_console(struct hw_trapframe *hw_tf, void *data)
27 struct cons_dev *cdev = (struct cons_dev*)data;
29 if (cons_get_char(cdev, &c))
31 /* Control code intercepts */
33 case capchar2ctl('G'):
34 /* traditional 'shift-g', will put you in the monitor gracefully */
35 send_kernel_message(core_id(), __run_mon, 0, 0, 0, KMSG_ROUTINE);
37 case capchar2ctl('Q'):
38 /* force you into the monitor. you might deadlock. */
39 printk("\nForcing entry to the monitor\n");
42 case capchar2ctl('B'):
43 /* backtrace / debugging for the core receiving the irq */
44 printk("\nForced trapframe and backtrace for core %d\n", core_id());
45 print_trapframe(hw_tf);
46 backtrace_kframe(hw_tf);
49 /* Do our work in an RKM, instead of interrupt context. Note the RKM will
50 * cast 'c' to a char. */
52 send_kernel_message(core_id(), __run_mon, 0, 0, 0, KMSG_ROUTINE);
54 send_kernel_message(core_id(), __cons_add_char, (long)&cons_buf,
55 (long)c, 0, KMSG_ROUTINE);
58 static void cons_irq_init(void)
61 /* Register interrupt handlers for all console devices */
62 SLIST_FOREACH(i, &cdev_list, next)
63 register_dev_irq(i->irq, irq_console, i);
68 /* need to reinit before saving, in case boot agents used the FPU or it is
69 * o/w dirty. had this happen on c89, which had a full FP stack after
71 asm volatile ("fninit");
72 save_fp_state(&x86_default_fpu); /* used in arch/trap.h for fpu init */
74 #ifdef CONFIG_ENABLE_MPTABLES
76 ioapic_init(); // MUST BE AFTER PCI/ISA INIT!
77 // TODO: move these back to regular init. requires fixing the
78 // CONFIG_NETWORKING inits to not need multiple cores running.
80 // this returns when all other cores are done and ready to receive IPIs
81 #ifdef CONFIG_SINGLE_CORE
88 /* EXPERIMENTAL NETWORK FUNCTIONALITY
89 * To enable, define CONFIG_NETWORKING in your Makelocal
90 * If enabled, will load the rl8168 driver (if device exists)
91 * and will a boot into userland matrix, so remote syscalls can be performed.
92 * If in simulation, will do some debugging information with the ne2k device
94 * Note: If you use this, you should also define the mac address of the
95 * teathered machine via USER_MAC_ADDRESS in Makelocal.
97 * Additionally, you should have a look at the syscall server in the tools directory
99 #ifdef CONFIG_NETWORKING
100 #ifdef CONFIG_SINGLE_CORE
101 warn("You currently can't have networking if you boot into single core mode!!\n");
103 /* TODO: use something like linux's device_init() to call these. */
105 extern void rl8168_init(void);
109 extern void ne2k_init(void);
113 extern void e1000_init(void);
116 #endif // CONFIG_SINGLE_CORE
117 #endif // CONFIG_NETWORKING
121 check_timing_stability();