3 * Architecture specific main startup/shutdown code
6 IMPLEMENTATION[ia32,amd64]:
15 #include "kernel_console.h"
18 #include "processor.h"
21 #include "terminate.h"
23 int exit_question_active;
26 extern "C" void __attribute__ ((noreturn))
29 if (exit_question_active)
45 exit_question_active = 1;
47 Pic::Status irqs = Pic::disable_all_save();
48 if (Config::getchar_does_hlt && Config::getchar_does_hlt_works_ok)
50 Idt::set_vectors_stop();
55 // make sure that we don't acknowledg the exit question automatically
56 Kconsole::console()->change_state(Console::PUSH, 0, ~Console::INENABLED, 0);
57 puts("\nReturn reboots, \"k\" enters L4 kernel debugger...");
59 char c = Kconsole::console()->getchar();
61 if (c == 'k' || c == 'K')
63 Pic::restore_all(irqs);
68 // It may be better to not call all the destruction stuff because of
69 // unresolved static destructor dependency problems. So just do the
70 // reset at this point.
71 puts("\033[1mRebooting.\033[m");
78 // console initialization
79 set_exit_question(&exit_question);
81 //Pic::disable_all_save();
85 //------------------------------------------------------------------------
86 IMPLEMENTATION[(ia32,amd64) && mp]:
90 #include "app_cpu_thread.h"
97 #include "kernel_task.h"
98 #include "processor.h"
99 #include "per_cpu_data_alloc.h"
100 #include "perf_cnt.h"
101 #include "spin_lock.h"
102 #include "utcb_init.h"
104 int FIASCO_FASTCALL boot_ap_cpu(unsigned _cpu) __asm__("BOOT_AP_CPU");
106 int boot_ap_cpu(unsigned _cpu)
108 if (!Per_cpu_data_alloc::alloc(_cpu))
110 extern Spin_lock<Mword> _tramp_mp_spinlock;
111 printf("CPU allocation failed for CPU%u, disabling CPU.\n", _cpu);
112 _tramp_mp_spinlock.clear();
116 Per_cpu_data::run_ctors(_cpu);
117 Cpu &cpu = Cpu::cpus.cpu(_cpu);
121 Utcb_init::init_ap(cpu);
124 Ipi::cpu(_cpu).init();
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);