3 * Architecture specific main startup/shutdown code
6 IMPLEMENTATION[ia32,amd64]:
15 #include "kernel_console.h"
18 #include "processor.h"
21 #include "timer_tick.h"
22 #include "terminate.h"
24 static int exit_question_active;
27 extern "C" void __attribute__ ((noreturn))
30 if (exit_question_active)
46 exit_question_active = 1;
48 Pic::Status irqs = Pic::disable_all_save();
49 if (Config::getchar_does_hlt_works_ok)
51 Timer_tick::set_vectors_stop();
52 Timer_tick::enable(0); // hmexit alway on CPU 0
56 // make sure that we don't acknowledg the exit question automatically
57 Kconsole::console()->change_state(Console::PUSH, 0, ~Console::INENABLED, 0);
58 puts("\nReturn reboots, \"k\" enters L4 kernel debugger...");
60 char c = Kconsole::console()->getchar();
62 if (c == 'k' || c == 'K')
64 Pic::restore_all(irqs);
69 // It may be better to not call all the destruction stuff because of
70 // unresolved static destructor dependency problems. So just do the
71 // reset at this point.
72 puts("\033[1mRebooting.\033[m");
79 // console initialization
80 set_exit_question(&exit_question);
82 //Pic::disable_all_save();
86 //------------------------------------------------------------------------
87 IMPLEMENTATION[(ia32,amd64) && mp]:
91 #include "app_cpu_thread.h"
98 #include "kernel_task.h"
99 #include "processor.h"
100 #include "per_cpu_data_alloc.h"
101 #include "perf_cnt.h"
102 #include "spin_lock.h"
103 #include "utcb_init.h"
105 int FIASCO_FASTCALL boot_ap_cpu(unsigned _cpu) __asm__("BOOT_AP_CPU");
107 int FIASCO_FASTCALL boot_ap_cpu(unsigned _cpu)
109 if (!Per_cpu_data_alloc::alloc(_cpu))
111 extern Spin_lock<Mword> _tramp_mp_spinlock;
112 printf("CPU allocation failed for CPU%u, disabling CPU.\n", _cpu);
113 _tramp_mp_spinlock.clear();
117 Per_cpu_data::run_ctors(_cpu);
118 Cpu &cpu = Cpu::cpus.cpu(_cpu);
126 Apic::check_still_getting_interrupts();
129 // caution: no stack variables in this function because we're going
130 // to change the stack pointer!
132 cpu.show_cache_tlb_info("");
134 if (Koptions::o()->opt(Koptions::F_loadcnt))
139 // create kernel thread
140 App_cpu_thread *kernel = new (Ram_quota::root) App_cpu_thread();
141 set_cpu_of(kernel, _cpu);
142 check(kernel->bind(Kernel_task::kernel_task(), User<Utcb>::Ptr(0)));
144 main_switch_ap_cpu_stack(kernel);