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>
13 #include <asm/delay.h>
14 #include <asm/hw_irq.h>
15 #include <asm/system.h>
16 #include <asm/pgtable.h>
17 #include <asm/tlbflush.h>
19 #include <asm/iommu.h>
22 * Power off function, if any
24 void (*pm_power_off)(void);
25 EXPORT_SYMBOL(pm_power_off);
27 static long no_idt[3];
31 } reboot_type = BOOT_KBD;
32 static int reboot_mode = 0;
35 /* reboot=t[riple] | k[bd] [, [w]arm | [c]old]
36 warm Don't set the cold reboot flag
37 cold Set the cold reboot flag
38 triple Force a triple fault (init)
39 kbd Use the keyboard controller. cold reset (default)
40 force Avoid anything that could hang.
42 static int __init reboot_setup(char *str)
63 if((str = strchr(str,',')) != NULL)
71 __setup("reboot=", reboot_setup);
73 static inline void kb_wait(void)
77 for (i=0; i<0x10000; i++)
78 if ((inb_p(0x64) & 0x02) == 0)
82 void machine_shutdown(void)
86 /* Stop the cpus and apics */
90 /* The boot cpu is always logical cpu 0 */
93 /* Make certain the cpu I'm about to reboot on is online */
94 if (!cpu_isset(reboot_cpu_id, cpu_online_map)) {
95 reboot_cpu_id = smp_processor_id();
98 /* Make certain I only run on the appropriate processor */
99 set_cpus_allowed(current, cpumask_of_cpu(reboot_cpu_id));
101 /* O.K Now that I'm on the appropriate processor,
102 * stop all of the others.
107 local_irq_save(flags);
110 disable_local_APIC();
115 local_irq_restore(flags);
117 pci_iommu_shutdown();
120 void machine_emergency_restart(void)
124 /* Tell the BIOS if we want cold or warm reboot */
125 *((unsigned short *)__va(0x472)) = reboot_mode;
128 /* Could also try the reset bit in the Hammer NB */
129 switch (reboot_type) {
131 for (i=0; i<10; i++) {
134 outb(0xfe,0x64); /* pulse reset low */
139 __asm__ __volatile__("lidt (%0)": :"r" (&no_idt));
140 __asm__ __volatile__("int3");
142 reboot_type = BOOT_KBD;
148 void machine_restart(char * __unused)
150 printk("machine restart\n");
155 machine_emergency_restart();
158 void machine_halt(void)
162 void machine_power_off(void)