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() __asm__("BOOT_AP_CPU");
107 int FIASCO_FASTCALL boot_ap_cpu()
109 unsigned _cpu = Apic::find_cpu(Apic::get_id());
110 bool cpu_is_new = false;
111 static unsigned last_cpu; // keep track of the last cpu ever appeared
114 _cpu = ++last_cpu; // 0 is the boot cpu, so pre increment
118 if (cpu_is_new && !Per_cpu_data_alloc::alloc(_cpu))
120 extern Spin_lock<Mword> _tramp_mp_spinlock;
121 printf("CPU allocation failed for CPU%u, disabling CPU.\n", _cpu);
122 _tramp_mp_spinlock.clear();
126 Per_cpu_data::run_ctors(_cpu);
127 Cpu &cpu = Cpu::cpus.cpu(_cpu);
133 Apic::apic.cpu(_cpu).construct();
136 Apic::check_still_getting_interrupts();
139 // caution: no stack variables in this function because we're going
140 // to change the stack pointer!
142 cpu.show_cache_tlb_info("");
144 if (Koptions::o()->opt(Koptions::F_loadcnt))
149 // create kernel thread
150 Kernel_thread *kernel = App_cpu_thread::may_be_create(_cpu, cpu_is_new);
152 main_switch_ap_cpu_stack(kernel);