static long sys_exit(int status) { const std::string msg = "Service exited with status " + std::to_string(status) + "\n"; OS::print(msg.data(), msg.size()); __arch_poweroff(); __builtin_unreachable(); }
void panic_epilogue(const char* why) { // Call custom on panic handler (if present). if (panic_handler != nullptr) { // Avoid recursion if the panic handler results in panic auto final_action = panic_handler; panic_handler = nullptr; final_action(why); } #if defined(ARCH_x86) SMP::global_lock(); // Signal End-Of-Transmission kprint("\x04"); SMP::global_unlock(); #else #warning "panic() handler not implemented for selected arch" #endif switch (OS::panic_action()) { case OS::Panic_action::halt: while (1) OS::halt(); case OS::Panic_action::shutdown: extern void __arch_poweroff(); __arch_poweroff(); case OS::Panic_action::reboot: default: OS::reboot(); } __builtin_unreachable(); }
void OS::event_loop() { Events::get(0).process_events(); do { OS::halt(); Events::get(0).process_events(); } while (power_); MYINFO("Stopping service"); Service::stop(); MYINFO("Powering off"); extern void __arch_poweroff(); __arch_poweroff(); }
// Shutdown the machine when one of the exit functions are called void default_exit() { __arch_poweroff(); __builtin_unreachable(); }