/* * This function gets called by ctrl-alt-del - ie the keyboard interrupt. * As it's called within an interrupt, it may NOT sync: the only choice * is whether to reboot at once, or just ignore the ctrl-alt-del. */ void ctrl_alt_del(void) { static DECLARE_WORK(cad_work, deferred_cad); if (C_A_D) schedule_work(&cad_work); else kill_cad_pid(SIGINT, 1); }
static void button_sequence_finished (unsigned long parameters) { if (IS_ENABLED(CONFIG_NWBUTTON_REBOOT) && button_press_count == reboot_count) kill_cad_pid(SIGINT, 1); /* Ask init to reboot us */ button_consume_callbacks (button_press_count); bcount = sprintf (button_output_buffer, "%d\n", button_press_count); button_press_count = 0; /* Reset the button press counter */ wake_up_interruptible (&button_wait_queue); }
static void button_sequence_finished (unsigned long parameters) { #ifdef CONFIG_NWBUTTON_REBOOT if (button_press_count == reboot_count) kill_cad_pid(SIGINT, 1); #endif button_consume_callbacks (button_press_count); bcount = sprintf (button_output_buffer, "%d\n", button_press_count); button_press_count = 0; wake_up_interruptible (&button_wait_queue); }
static inline void ip32_power_button(void) { if (has_panicked) return; if (shuting_down || kill_cad_pid(SIGINT, 1)) { /* No init process or button pressed twice. */ ip32_machine_power_off(); } shuting_down = 1; blink_timer.data = POWERDOWN_FREQ; blink_timeout(POWERDOWN_FREQ); init_timer(&power_timer); power_timer.function = power_timeout; power_timer.expires = jiffies + POWERDOWN_TIMEOUT * HZ; add_timer(&power_timer); }
static inline void power_button(void) { if (machine_state & MACHINE_PANICED) return; if ((machine_state & MACHINE_SHUTTING_DOWN) || kill_cad_pid(SIGINT, 1)) { /* No init process or button pressed twice. */ sgi_machine_power_off(); } machine_state |= MACHINE_SHUTTING_DOWN; blink_timer.data = POWERDOWN_FREQ; blink_timeout(POWERDOWN_FREQ); init_timer(&power_timer); power_timer.function = power_timeout; power_timer.expires = jiffies + POWERDOWN_TIMEOUT * HZ; add_timer(&power_timer); }
/* check, give feedback and start shutdown after one second */ static void process_shutdown(void) { if (shutdown_timer == 0) printk(KERN_ALERT KTHREAD_NAME ": Shutdown requested...\n"); shutdown_timer++; /* wait until the button was pressed for 1 second */ if (shutdown_timer == (POWERSWITCH_DOWN_SEC*POWERSWITCH_POLL_PER_SEC)) { static const char msg[] = "Shutting down..."; printk(KERN_INFO KTHREAD_NAME ": %s\n", msg); lcd_print(msg); /* send kill signal */ if (kill_cad_pid(SIGINT, 1)) { /* just in case killing init process failed */ if (pm_power_off) pm_power_off(); } } }
static void process_shutdown(void) { if (shutdown_timer == 0) printk(KERN_ALERT KTHREAD_NAME ": Shutdown requested...\n"); shutdown_timer++; /* */ if (shutdown_timer == (POWERSWITCH_DOWN_SEC*POWERSWITCH_POLL_PER_SEC)) { static const char msg[] = "Shutting down..."; printk(KERN_INFO KTHREAD_NAME ": %s\n", msg); lcd_print(msg); /* */ if (kill_cad_pid(SIGINT, 1)) { /* */ if (pm_power_off) pm_power_off(); } } }
static int ps3_sys_manager_handle_event(struct ps3_system_bus_device *dev) { int result; struct { u8 version; u8 type; u8 reserved_1[2]; u32 value; u8 reserved_2[8]; } event; BUILD_BUG_ON(sizeof(event) != 16); result = ps3_vuart_read(dev, &event, sizeof(event)); BUG_ON(result && "need to retry here"); if (event.version != 1) { dev_dbg(&dev->core, "%s:%d: unsupported event version (%u)\n", __func__, __LINE__, event.version); return -EIO; } switch (event.type) { case PS3_SM_EVENT_POWER_PRESSED: dev_dbg(&dev->core, "%s:%d: POWER_PRESSED\n", __func__, __LINE__); ps3_sm_force_power_off = 1; /* * A memory barrier is use here to sync memory since * ps3_sys_manager_final_restart() could be called on * another cpu. */ wmb(); kill_cad_pid(SIGINT, 1); /* ctrl_alt_del */ break; case PS3_SM_EVENT_POWER_RELEASED: dev_dbg(&dev->core, "%s:%d: POWER_RELEASED (%u ms)\n", __func__, __LINE__, event.value); break; case PS3_SM_EVENT_RESET_PRESSED: dev_dbg(&dev->core, "%s:%d: RESET_PRESSED\n", __func__, __LINE__); ps3_sm_force_power_off = 0; /* * A memory barrier is use here to sync memory since * ps3_sys_manager_final_restart() could be called on * another cpu. */ wmb(); kill_cad_pid(SIGINT, 1); /* ctrl_alt_del */ break; case PS3_SM_EVENT_RESET_RELEASED: dev_dbg(&dev->core, "%s:%d: RESET_RELEASED (%u ms)\n", __func__, __LINE__, event.value); break; case PS3_SM_EVENT_THERMAL_ALERT: dev_dbg(&dev->core, "%s:%d: THERMAL_ALERT (zone %u)\n", __func__, __LINE__, event.value); printk(KERN_INFO "PS3 Thermal Alert Zone %u\n", event.value); break; case PS3_SM_EVENT_THERMAL_CLEARED: dev_dbg(&dev->core, "%s:%d: THERMAL_CLEARED (zone %u)\n", __func__, __LINE__, event.value); break; default: dev_dbg(&dev->core, "%s:%d: unknown event (%u)\n", __func__, __LINE__, event.type); return -EIO; } return 0; }
static int ps3_sys_manager_handle_event(struct ps3_system_bus_device *dev) { int result; struct { u8 version; u8 type; u8 reserved_1[2]; u32 value; u8 reserved_2[8]; } event; BUILD_BUG_ON(sizeof(event) != 16); result = ps3_vuart_read(dev, &event, sizeof(event)); BUG_ON(result && "need to retry here"); if (event.version != 1) { dev_dbg(&dev->core, "%s:%d: unsupported event version (%u)\n", __func__, __LINE__, event.version); return -EIO; } switch (event.type) { case PS3_SM_EVENT_POWER_PRESSED: dev_dbg(&dev->core, "%s:%d: POWER_PRESSED (%s)\n", __func__, __LINE__, (event.value == PS3_SM_BUTTON_EVENT_SOFT ? "soft" : "hard")); ps3_sm_force_power_off = 1; wmb(); kill_cad_pid(SIGINT, 1); break; case PS3_SM_EVENT_POWER_RELEASED: dev_dbg(&dev->core, "%s:%d: POWER_RELEASED (%u ms)\n", __func__, __LINE__, event.value); break; case PS3_SM_EVENT_RESET_PRESSED: dev_dbg(&dev->core, "%s:%d: RESET_PRESSED (%s)\n", __func__, __LINE__, (event.value == PS3_SM_BUTTON_EVENT_SOFT ? "soft" : "hard")); ps3_sm_force_power_off = 0; wmb(); kill_cad_pid(SIGINT, 1); break; case PS3_SM_EVENT_RESET_RELEASED: dev_dbg(&dev->core, "%s:%d: RESET_RELEASED (%u ms)\n", __func__, __LINE__, event.value); break; case PS3_SM_EVENT_THERMAL_ALERT: dev_dbg(&dev->core, "%s:%d: THERMAL_ALERT (zone %u)\n", __func__, __LINE__, event.value); pr_info("PS3 Thermal Alert Zone %u\n", event.value); break; case PS3_SM_EVENT_THERMAL_CLEARED: dev_dbg(&dev->core, "%s:%d: THERMAL_CLEARED (zone %u)\n", __func__, __LINE__, event.value); break; default: dev_dbg(&dev->core, "%s:%d: unknown event (%u)\n", __func__, __LINE__, event.type); return -EIO; } return 0; }