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 <acpi/reboot.h>
14 #include <asm/delay.h>
16 #include <asm/hw_irq.h>
17 #include <asm/system.h>
18 #include <asm/pgtable.h>
19 #include <asm/tlbflush.h>
25 * Power off function, if any
27 void (*pm_power_off)(void);
28 EXPORT_SYMBOL(pm_power_off);
30 static long no_idt[3];
35 } reboot_type = BOOT_KBD;
36 static int reboot_mode = 0;
39 /* reboot=t[riple] | k[bd] [, [w]arm | [c]old]
40 warm Don't set the cold reboot flag
41 cold Set the cold reboot flag
42 triple Force a triple fault (init)
43 kbd Use the keyboard controller. cold reset (default)
44 acpi Use the RESET_REG in the FADT
45 force Avoid anything that could hang.
47 static int __init reboot_setup(char *str)
69 if((str = strchr(str,',')) != NULL)
77 __setup("reboot=", reboot_setup);
79 static inline void kb_wait(void)
83 for (i=0; i<0x10000; i++)
84 if ((inb_p(0x64) & 0x02) == 0)
88 void machine_shutdown(void)
92 /* Stop the cpus and apics */
96 /* The boot cpu is always logical cpu 0 */
99 /* Make certain the cpu I'm about to reboot on is online */
100 if (!cpu_isset(reboot_cpu_id, cpu_online_map)) {
101 reboot_cpu_id = smp_processor_id();
104 /* Make certain I only run on the appropriate processor */
105 set_cpus_allowed(current, cpumask_of_cpu(reboot_cpu_id));
107 /* O.K Now that I'm on the appropriate processor,
108 * stop all of the others.
113 local_irq_save(flags);
116 disable_local_APIC();
121 #ifdef CONFIG_HPET_TIMER
124 local_irq_restore(flags);
126 pci_iommu_shutdown();
129 void machine_emergency_restart(void)
133 /* Tell the BIOS if we want cold or warm reboot */
134 *((unsigned short *)__va(0x472)) = reboot_mode;
137 /* Could also try the reset bit in the Hammer NB */
138 switch (reboot_type) {
140 for (i=0; i<10; i++) {
143 outb(0xfe,0x64); /* pulse reset low */
148 load_idt((const struct desc_ptr *)&no_idt);
149 __asm__ __volatile__("int3");
151 reboot_type = BOOT_KBD;
156 reboot_type = BOOT_KBD;
162 void machine_restart(char * __unused)
164 printk("machine restart\n");
169 machine_emergency_restart();
172 void machine_halt(void)
176 void machine_power_off(void)