1 /* Various gunk just to reboot the machine. */
2 #include <linux/module.h>
3 #include <linux/reboot.h>
4 #include <linux/init.h>
6 #include <linux/kernel.h>
7 #include <linux/ctype.h>
8 #include <linux/string.h>
10 #include <linux/kdebug.h>
11 #include <linux/sched.h>
12 #include <linux/efi.h>
13 #include <acpi/reboot.h>
15 #include <asm/delay.h>
17 #include <asm/hw_irq.h>
18 #include <asm/system.h>
19 #include <asm/pgtable.h>
20 #include <asm/tlbflush.h>
26 * Power off function, if any
28 void (*pm_power_off)(void);
29 EXPORT_SYMBOL(pm_power_off);
31 static long no_idt[3];
32 enum reboot_type reboot_type = BOOT_KBD;
33 static int reboot_mode = 0;
36 /* reboot=t[riple] | k[bd] | e[fi] [, [w]arm | [c]old]
37 warm Don't set the cold reboot flag
38 cold Set the cold reboot flag
39 triple Force a triple fault (init)
40 kbd Use the keyboard controller. cold reset (default)
41 acpi Use the RESET_REG in the FADT
42 efi Use efi reset_system runtime service
43 force Avoid anything that could hang.
45 static int __init reboot_setup(char *str)
68 if((str = strchr(str,',')) != NULL)
76 __setup("reboot=", reboot_setup);
78 static inline void kb_wait(void)
82 for (i=0; i<0x10000; i++)
83 if ((inb_p(0x64) & 0x02) == 0)
87 void machine_shutdown(void)
91 /* Stop the cpus and apics */
95 /* The boot cpu is always logical cpu 0 */
98 /* Make certain the cpu I'm about to reboot on is online */
99 if (!cpu_isset(reboot_cpu_id, cpu_online_map)) {
100 reboot_cpu_id = smp_processor_id();
103 /* Make certain I only run on the appropriate processor */
104 set_cpus_allowed(current, cpumask_of_cpu(reboot_cpu_id));
106 /* O.K Now that I'm on the appropriate processor,
107 * stop all of the others.
112 local_irq_save(flags);
115 disable_local_APIC();
120 #ifdef CONFIG_HPET_TIMER
123 local_irq_restore(flags);
125 pci_iommu_shutdown();
128 void machine_emergency_restart(void)
132 /* Tell the BIOS if we want cold or warm reboot */
133 *((unsigned short *)__va(0x472)) = reboot_mode;
136 /* Could also try the reset bit in the Hammer NB */
137 switch (reboot_type) {
139 for (i=0; i<10; i++) {
142 outb(0xfe,0x64); /* pulse reset low */
147 load_idt((const struct desc_ptr *)&no_idt);
148 __asm__ __volatile__("int3");
150 reboot_type = BOOT_KBD;
155 reboot_type = BOOT_KBD;
160 efi.reset_system(reboot_mode ? EFI_RESET_WARM : EFI_RESET_COLD,
161 EFI_SUCCESS, 0, NULL);
162 reboot_type = BOOT_KBD;
168 void machine_restart(char * __unused)
170 printk("machine restart\n");
175 machine_emergency_restart();
178 void machine_halt(void)
182 void machine_power_off(void)