/** System shutdown thread. * @param _action Action to perform once the system has been shut down. * @param arg2 Unused. */ static void shutdown_thread_entry(void *_action, void *arg2) { int action = (int)((ptr_t)_action); thread_wire(curr_thread); thread_disable_preempt(); kprintf(LOG_NOTICE, "system: terminating all processes...\n"); process_shutdown(); kprintf(LOG_NOTICE, "system: unmounting filesystems...\n"); fs_shutdown(); #if CONFIG_SMP kprintf(LOG_NOTICE, "system: shutting down other CPUs...\n"); smp_call_broadcast(shutdown_call_func, NULL, 0); #endif switch(action) { case SHUTDOWN_REBOOT: kprintf(LOG_NOTICE, "system: rebooting...\n"); platform_reboot(); break; case SHUTDOWN_POWEROFF: kprintf(LOG_NOTICE, "system: powering off...\n"); platform_poweroff(); break; } kprintf(LOG_NOTICE, "system: halted.\n"); arch_cpu_halt(); }
void machine_halt(void) { int timeout = 10; watchdog_disable(); console_start_sync(); local_irq_enable(); smp_call_function(halt_this_cpu, NULL, 0); local_irq_disable(); /* Wait at most another 10ms for all other CPUs to go offline. */ while ( (num_online_cpus() > 1) && (timeout-- > 0) ) mdelay(1); /* This is mainly for PSCI-0.2, which does not return if success. */ call_psci_system_off(); /* Alternative halt procedure */ platform_poweroff(); halt_this_cpu(NULL); }
void otapi_poweroff() { platform_poweroff(); }