static void power_down(suspend_disk_method_t mode) { unsigned long flags; int error = 0; local_irq_save(flags); switch(mode) { case PM_DISK_PLATFORM: device_power_down(PM_SUSPEND_DISK); error = pm_ops->enter(PM_SUSPEND_DISK); break; case PM_DISK_SHUTDOWN: printk("Powering off system\n"); device_shutdown(); machine_power_off(); break; case PM_DISK_REBOOT: device_shutdown(); machine_restart(NULL); break; } machine_halt(); /* Valid image is on the disk, if we continue we risk serious data corruption after resume. */ printk(KERN_CRIT "Please power me down manually\n"); while(1); }
void __bug () { printk (KERN_CRIT "kernel BUG at PC 0x%x (SP ~0x%x)!\n", ret_addr() - 4, /* - 4 for `jarl' */ stack_addr()); machine_halt (); }
/* * Called by secondaries to update state and initialize CPU registers. */ static void __init smp_cpu_init(int cpunum) { extern int init_per_cpu(int); /* arch/parisc/kernel/setup.c */ extern void init_IRQ(void); /* arch/parisc/kernel/irq.c */ /* Set modes and Enable floating point coprocessor */ (void) init_per_cpu(cpunum); disable_sr_hashing(); mb(); /* Well, support 2.4 linux scheme as well. */ if (cpu_test_and_set(cpunum, cpu_online_map)) { extern void machine_halt(void); /* arch/parisc.../process.c */ printk(KERN_CRIT "CPU#%d already initialized!\n", cpunum); machine_halt(); } /* Initialise the idle task for this CPU */ atomic_inc(&init_mm.mm_count); current->active_mm = &init_mm; if(current->mm) BUG(); enter_lazy_tlb(&init_mm, current); init_IRQ(); /* make sure no IRQ's are enabled or pending */ }
/** * kernel_halt - halt the system * * Shutdown everything and perform a clean system halt. */ void kernel_halt(void) { kernel_shutdown_prepare(SYSTEM_HALT); sysdev_shutdown(); printk(KERN_EMERG "System halted.\n"); machine_halt(); }
void dom0_shutdown(u8 reason) { switch ( reason ) { case SHUTDOWN_poweroff: { printk("Domain 0 halted: halting machine.\n"); machine_halt(); break; /* not reached */ } case SHUTDOWN_crash: { debugger_trap_immediate(); printk("Domain 0 crashed: "); maybe_reboot(); break; /* not reached */ } case SHUTDOWN_reboot: { printk("Domain 0 shutdown: rebooting machine.\n"); machine_restart(0); break; /* not reached */ } default: { printk("Domain 0 shutdown (unknown reason %u): ", reason); maybe_reboot(); break; /* not reached */ } } }
void machine_power_off(void) { #ifdef CONFIG_SUN_AUXIO if (auxio_power_register && !serial_console) *auxio_power_register |= AUXIO_POWER_OFF; #endif machine_halt(); }
/** * kernel_halt - halt the system * * Shutdown everything and perform a clean system halt. */ void kernel_halt(void) { kernel_shutdown_prepare(SYSTEM_HALT); migrate_to_reboot_cpu(); syscore_shutdown(); pr_emerg("System halted\n"); kmsg_dump(KMSG_DUMP_HALT); machine_halt(); }
void __bug(const char *file, int line, void *data) { if (data) printk(KERN_CRIT "kernel BUG at %s:%d (data = %p)!\n", file, line, data); else printk(KERN_CRIT "kernel BUG at %s:%d!\n", file, line); machine_halt(); }
static int panic_exit(struct notifier_block *self, unsigned long unused1, void *unused2) { bust_spinlocks(1); show_regs(&(current->thread.regs)); bust_spinlocks(0); uml_exitcode = 1; machine_halt(); return(0); }
void unexpected_reset (unsigned long ret_addr, unsigned long kmode, struct task_struct *task, unsigned long sp) { printk (KERN_CRIT "unexpected reset in %s mode, pid %d" " (ret_addr = 0x%lx, sp = 0x%lx)\n", kmode ? "kernel" : "user", task ? task->pid : -1, ret_addr, sp); machine_halt (); }
void machine_power_off(void) { #ifdef CONFIG_PCI if (power_reg != 0UL && !serial_console) { /* Both register bits seem to have the * same effect, so until I figure out * what the difference is... */ writel(POWER_COURTESY_OFF | POWER_SYSTEM_OFF, power_reg); } #endif /* CONFIG_PCI */ machine_halt(); }
static void maybe_reboot(void) { if ( opt_noreboot ) { printk("'noreboot' set - not rebooting.\n"); machine_halt(); } else { printk("rebooting machine in 5 seconds.\n"); watchdog_disable(); machine_restart(5000); } }
/** * setup_machine_fdt - Machine setup when an dtb was passed to the kernel * @dt: virtual address pointer to dt blob * * If a dtb was passed to the kernel, then use it to choose the correct * machine_desc and to setup the system. */ const struct machine_desc * __init setup_machine_fdt(void *dt) { const struct machine_desc *mdesc; unsigned long dt_root; if (!early_init_dt_scan(dt)) return NULL; mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach); if (!mdesc) machine_halt(); dt_root = of_get_flat_dt_root(); arc_set_early_base_baud(dt_root); return mdesc; }
void machine_power_off(void) { if (!serial_console || scons_pwroff) { #ifdef CONFIG_PCI if (power_reg) { /* Both register bits seem to have the * same effect, so until I figure out * what the difference is... */ writel(AUXIO_PCIO_CPWR_OFF | AUXIO_PCIO_SPWR_OFF, power_reg); } else #endif /* CONFIG_PCI */ if (poweroff_method != NULL) { poweroff_method(); /* not reached */ } } machine_halt(); }
void machine_power_off(void) { sstate_poweroff(); if (strcmp(of_console_device->type, "serial") || scons_pwroff) { if (power_reg) { /* Both register bits seem to have the * same effect, so until I figure out * what the difference is... */ writel(AUXIO_PCIO_CPWR_OFF | AUXIO_PCIO_SPWR_OFF, power_reg); } else { if (poweroff_method != NULL) { poweroff_method(); /* not reached */ } } } machine_halt(); }
static void __init jailhouse_get_smp_config(unsigned int early) { struct ioapic_domain_cfg ioapic_cfg = { .type = IOAPIC_DOMAIN_STRICT, .ops = &mp_ioapic_irqdomain_ops, }; struct mpc_intsrc mp_irq = { .type = MP_INTSRC, .irqtype = mp_INT, .irqflag = MP_IRQPOL_ACTIVE_HIGH | MP_IRQTRIG_EDGE, }; unsigned int cpu; jailhouse_x2apic_init(); register_lapic_address(0xfee00000); for (cpu = 0; cpu < setup_data.num_cpus; cpu++) { generic_processor_info(setup_data.cpu_ids[cpu], boot_cpu_apic_version); } smp_found_config = 1; if (setup_data.standard_ioapic) { mp_register_ioapic(0, 0xfec00000, gsi_top, &ioapic_cfg); /* Register 1:1 mapping for legacy UART IRQs 3 and 4 */ mp_irq.srcbusirq = mp_irq.dstirq = 3; mp_save_irq(&mp_irq); mp_irq.srcbusirq = mp_irq.dstirq = 4; mp_save_irq(&mp_irq); } } static void jailhouse_no_restart(void) { pr_notice("Jailhouse: Restart not supported, halting\n"); machine_halt(); }
void hwdom_shutdown(u8 reason) { switch ( reason ) { case SHUTDOWN_poweroff: printk("Hardware Dom%u halted: halting machine\n", hardware_domain->domain_id); machine_halt(); break; /* not reached */ case SHUTDOWN_crash: debugger_trap_immediate(); printk("Hardware Dom%u crashed: ", hardware_domain->domain_id); #ifdef CONFIG_KEXEC kexec_crash(); #endif maybe_reboot(); break; /* not reached */ case SHUTDOWN_reboot: printk("Hardware Dom%u shutdown: rebooting machine\n", hardware_domain->domain_id); machine_restart(0); break; /* not reached */ case SHUTDOWN_watchdog: printk("Hardware Dom%u shutdown: watchdog rebooting machine\n", hardware_domain->domain_id); #ifdef CONFIG_KEXEC kexec_crash(); #endif machine_restart(0); break; /* not reached */ default: printk("Hardware Dom%u shutdown (unknown reason %u): ", hardware_domain->domain_id, reason); maybe_reboot(); break; /* not reached */ } }
/** * setup_machine_fdt - Machine setup when an dtb was passed to the kernel * @dt: virtual address pointer to dt blob * * If a dtb was passed to the kernel, then use it to choose the correct * machine_desc and to setup the system. */ const struct machine_desc * __init setup_machine_fdt(void *dt) { const struct machine_desc *mdesc; unsigned long dt_root; const void *clk; int len; if (!early_init_dt_scan(dt)) return NULL; mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach); if (!mdesc) machine_halt(); dt_root = of_get_flat_dt_root(); clk = of_get_flat_dt_prop(dt_root, "clock-frequency", &len); if (clk) arc_set_core_freq(of_read_ulong(clk, len/4)); return mdesc; }
static void suspend_power_down(void) { extern int C_A_D; C_A_D = 0; printk(KERN_EMERG "%s%s Trying to power down.\n", name_suspend, TEST_SWSUSP ? "Disable TEST_SWSUSP. NOT ": ""); #ifdef CONFIG_VT PRINTK(KERN_EMERG "shift_state: %04x\n", shift_state); mdelay(1000); if (TEST_SWSUSP ^ (!!(shift_state & (1 << KG_CTRL)))) machine_restart(NULL); else #endif { device_shutdown(); machine_power_off(); } printk(KERN_EMERG "%sProbably not capable for powerdown. System halted.\n", name_suspend); machine_halt(); while (1); /* NOTREACHED */ }
static void jz4740_rtc_power_off(void) { struct jz4740_rtc *rtc = dev_get_drvdata(dev_for_power_off); unsigned long rtc_rate; unsigned long wakeup_filter_ticks; unsigned long reset_counter_ticks; clk_prepare_enable(rtc->clk); rtc_rate = clk_get_rate(rtc->clk); /* * Set minimum wakeup pin assertion time: 100 ms. * Range is 0 to 2 sec if RTC is clocked at 32 kHz. */ wakeup_filter_ticks = (rtc->min_wakeup_pin_assert_time * rtc_rate) / 1000; if (wakeup_filter_ticks < JZ_RTC_WAKEUP_FILTER_MASK) wakeup_filter_ticks &= JZ_RTC_WAKEUP_FILTER_MASK; else wakeup_filter_ticks = JZ_RTC_WAKEUP_FILTER_MASK; jz4740_rtc_reg_write(rtc, JZ_REG_RTC_WAKEUP_FILTER, wakeup_filter_ticks); /* * Set reset pin low-level assertion time after wakeup: 60 ms. * Range is 0 to 125 ms if RTC is clocked at 32 kHz. */ reset_counter_ticks = (rtc->reset_pin_assert_time * rtc_rate) / 1000; if (reset_counter_ticks < JZ_RTC_RESET_COUNTER_MASK) reset_counter_ticks &= JZ_RTC_RESET_COUNTER_MASK; else reset_counter_ticks = JZ_RTC_RESET_COUNTER_MASK; jz4740_rtc_reg_write(rtc, JZ_REG_RTC_RESET_COUNTER, reset_counter_ticks); jz4740_rtc_poweroff(dev_for_power_off); machine_halt(); }
void domain_shutdown(struct domain *d, u8 reason) { struct vcpu *v; if ( d->domain_id == 0 ) { extern void machine_restart(char *); extern void machine_halt(void); debugger_trap_immediate(); if ( reason == SHUTDOWN_poweroff ) { printk("Domain 0 halted: halting machine.\n"); machine_halt(); } else if ( reason == SHUTDOWN_crash ) { printk("Domain 0 crashed: rebooting machine in 5 seconds.\n"); watchdog_disable(); //mdelay(5000); machine_restart(0); } else { printk("Domain 0 shutdown: rebooting machine.\n"); machine_restart(0); } } /* Mark the domain as shutting down. */ d->shutdown_code = reason; /* Put every vcpu to sleep, but don't wait (avoids inter-vcpu deadlock). */ for_each_vcpu ( d, v ) { atomic_inc(&v->pausecnt); vcpu_sleep_nosync(v); }
/* * Called by secondaries to update state and initialize CPU registers. */ static void __init smp_cpu_init(int cpunum) { extern int init_per_cpu(int); /* arch/parisc/kernel/processor.c */ extern void init_IRQ(void); /* arch/parisc/kernel/irq.c */ extern void start_cpu_itimer(void); /* arch/parisc/kernel/time.c */ /* Set modes and Enable floating point coprocessor */ (void) init_per_cpu(cpunum); disable_sr_hashing(); mb(); /* Well, support 2.4 linux scheme as well. */ if (cpu_online(cpunum)) { extern void machine_halt(void); /* arch/parisc.../process.c */ printk(KERN_CRIT "CPU#%d already initialized!\n", cpunum); machine_halt(); } notify_cpu_starting(cpunum); ipi_call_lock(); set_cpu_online(cpunum, true); ipi_call_unlock(); /* Initialise the idle task for this CPU */ atomic_inc(&init_mm.mm_count); current->active_mm = &init_mm; BUG_ON(current->mm); enter_lazy_tlb(&init_mm, current); init_IRQ(); /* make sure no IRQs are enabled or pending */ start_cpu_itimer(); }
static int power_down(u32 mode) { unsigned long flags; int error = 0; local_irq_save(flags); device_power_down(PM_SUSPEND_DISK); switch(mode) { case PM_DISK_PLATFORM: error = pm_ops->enter(PM_SUSPEND_DISK); break; case PM_DISK_SHUTDOWN: printk("Powering off system\n"); machine_power_off(); break; case PM_DISK_REBOOT: machine_restart(NULL); break; } machine_halt(); device_power_up(); local_irq_restore(flags); return 0; }
void machine_restart (char *__unused) { machine_halt (); }
void machine_power_off (void) { machine_halt (); }
NORET_TYPE void panic(const char * fmt, ...) { static char buf[1024]; va_list args; #if defined(CONFIG_ARCH_S390) unsigned long caller = (unsigned long) __builtin_return_address(0); #endif #ifdef CONFIG_VT disable_console_blank(); #endif machine_paniced = 1; bust_spinlocks(1); va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); printk(KERN_EMERG "Kernel panic: %s\n",buf); if (in_interrupt()) printk(KERN_EMERG "In interrupt handler - not syncing\n"); else if (!current->pid) printk(KERN_EMERG "In idle task - not syncing\n"); else sys_sync(); bust_spinlocks(0); #ifdef CONFIG_SMP smp_send_stop(); #endif notifier_call_chain(&panic_notifier_list, 0, NULL); if (panic_timeout < 0) { machine_halt(); } else if (panic_timeout > 0) { /* * Delay timeout seconds before rebooting the machine. * We can't use the "normal" timers since we just panicked.. */ printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout); mdelay(panic_timeout*1000); /* * Should we run the reboot notifier. For the moment Im * choosing not too. It might crash, be corrupt or do * more harm than good for other reasons. */ machine_restart(NULL); } #ifdef __sparc__ { extern int stop_a_enabled; /* Make sure the user can actually press L1-A */ stop_a_enabled = 1; printk("Press L1-A to return to the boot prom\n"); } #endif #if defined(CONFIG_ARCH_S390) disabled_wait(caller); #endif sti(); for(;;) { #if defined(CONFIG_X86) && defined(CONFIG_VT) extern void panic_blink(void); panic_blink(); #endif CHECK_EMERGENCY_SYNC } }
/* * Reboot system call: for obvious reasons only root may call it, * and even root needs to set up some magic numbers in the registers * so that some mistake won't make this reboot the whole machine. * You can also set the meaning of the ctrl-alt-del-key here. * * reboot doesn't sync: do that yourself before calling this. */ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void * arg) { char buffer[256]; /* We only trust the superuser with rebooting the system. */ if (!capable(CAP_SYS_BOOT)) return -EPERM; /* For safety, we require "magic" arguments. */ if (magic1 != LINUX_REBOOT_MAGIC1 || (magic2 != LINUX_REBOOT_MAGIC2 && magic2 != LINUX_REBOOT_MAGIC2A && magic2 != LINUX_REBOOT_MAGIC2B)) return -EINVAL; #ifdef CONFIG_ARCH_EZXBASE /* must be sync with include/linux/moto_accy.h */ #define ACCS_REBOOT (1 << MOTO_ACCY_TYPE_CHARGER_MID | \ 1 << MOTO_ACCY_TYPE_CHARGER_MID_MPX | \ 1 << MOTO_ACCY_TYPE_CHARGER_FAST | \ 1 << MOTO_ACCY_TYPE_CHARGER_FAST_MPX | \ 1 << MOTO_ACCY_TYPE_CHARGER_FAST_3G | \ 1 << MOTO_ACCY_TYPE_CARKIT_MID | \ 1 << MOTO_ACCY_TYPE_CARKIT_FAST | \ 1 << MOTO_ACCY_TYPE_CARKIT_SMART) #define FACTORY_REBOOT (1 << MOTO_ACCY_TYPE_CABLE_FACTORY) MOTO_ACCY_MASK_T mask = (MOTO_ACCY_MASK_T)moto_accy_get_all_devices(); if (LINUX_REBOOT_CMD_RESTART == cmd) { if (mask & FACTORY_REBOOT) { *(unsigned long *)(phys_to_virt(FLAG_ADDR)) = FACTORY_REBOOT_FLAG; } else { *(unsigned long *)(phys_to_virt(FLAG_ADDR)) = APP_REBOOT_FLAG; } } if (LINUX_REBOOT_CMD_POWER_OFF == cmd) { if (mask & ACCS_REBOOT) { *(unsigned long *)(phys_to_virt(FLAG_ADDR)) = CHARGE_FLAG; cmd = LINUX_REBOOT_CMD_RESTART; printk(KERN_EMERG "Change to reboot mode.\n"); } } #endif lock_kernel(); switch (cmd) { case LINUX_REBOOT_CMD_RESTART: notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL); #ifdef CONFIG_KFI kfi_dump_log(NULL); #endif printk(KERN_EMERG "Restarting system.\n"); machine_restart(NULL); break; case LINUX_REBOOT_CMD_CAD_ON: C_A_D = 1; break; case LINUX_REBOOT_CMD_CAD_OFF: C_A_D = 0; break; case LINUX_REBOOT_CMD_HALT: notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); #ifdef CONFIG_KFI kfi_dump_log(NULL); #endif printk(KERN_EMERG "System halted.\n"); machine_halt(); do_exit(0); break; case LINUX_REBOOT_CMD_POWER_OFF: notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); #ifdef CONFIG_KFI kfi_dump_log(NULL); #endif printk(KERN_EMERG "Power down.\n"); machine_power_off(); do_exit(0); break; case LINUX_REBOOT_CMD_RESTART2: if (strncpy_from_user(&buffer[0], (char *)arg, sizeof(buffer) - 1) < 0) { unlock_kernel(); return -EFAULT; } buffer[sizeof(buffer) - 1] = '\0'; notifier_call_chain(&reboot_notifier_list, SYS_RESTART, buffer); printk(KERN_EMERG "Restarting system with command '%s'.\n", buffer); #ifdef CONFIG_KFI kfi_dump_log(NULL); #endif machine_restart(buffer); break; default: unlock_kernel(); return -EINVAL; } unlock_kernel(); return 0; }
void meson_power_off_prepare(void) { printk("meson prepare power off \n"); machine_halt(); }
/* * Reboot system call: for obvious reasons only root may call it, * and even root needs to set up some magic numbers in the registers * so that some mistake won't make this reboot the whole machine. * You can also set the meaning of the ctrl-alt-del-key here. * * reboot doesn't sync: do that yourself before calling this. */ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void * arg) { char buffer[256]; /* We only trust the superuser with rebooting the system. */ if (!capable(CAP_SYS_BOOT)) return -EPERM; /* For safety, we require "magic" arguments. */ if (magic1 != LINUX_REBOOT_MAGIC1 || (magic2 != LINUX_REBOOT_MAGIC2 && magic2 != LINUX_REBOOT_MAGIC2A && magic2 != LINUX_REBOOT_MAGIC2B)) return -EINVAL; lock_kernel(); switch (cmd) { case LINUX_REBOOT_CMD_RESTART: notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL); printk(KERN_EMERG "Restarting system.\n"); machine_restart(NULL); break; case LINUX_REBOOT_CMD_CAD_ON: C_A_D = 1; break; case LINUX_REBOOT_CMD_CAD_OFF: C_A_D = 0; break; case LINUX_REBOOT_CMD_HALT: notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); printk(KERN_EMERG "System halted.\n"); machine_halt(); do_exit(0); break; case LINUX_REBOOT_CMD_POWER_OFF: notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); printk(KERN_EMERG "Power down.\n"); machine_power_off(); do_exit(0); break; case LINUX_REBOOT_CMD_RESTART2: if (strncpy_from_user(&buffer[0], (char *)arg, sizeof(buffer) - 1) < 0) { unlock_kernel(); return -EFAULT; } buffer[sizeof(buffer) - 1] = '\0'; notifier_call_chain(&reboot_notifier_list, SYS_RESTART, buffer); printk(KERN_EMERG "Restarting system with command '%s'.\n", buffer); machine_restart(buffer); break; default: unlock_kernel(); return -EINVAL; } unlock_kernel(); return 0; }
static irqreturn_t nb0916_overheat_handler(int irq, void *dev_id) { machine_halt(); /* SYSTEM HALT, NO RETURN */ return IRQ_HANDLED; }