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>
15 #include <asm/hw_irq.h>
16 #include <asm/system.h>
17 #include <asm/pgtable.h>
18 #include <asm/tlbflush.h>
23 * Power off function, if any
25 void (*pm_power_off
)(void);
26 EXPORT_SYMBOL(pm_power_off
);
28 static long no_idt
[3];
32 } reboot_type
= BOOT_KBD
;
33 static int reboot_mode
= 0;
36 /* reboot=t[riple] | k[bd] [, [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 force Avoid anything that could hang.
43 static int __init
reboot_setup(char *str
)
64 if((str
= strchr(str
,',')) != NULL
)
72 __setup("reboot=", reboot_setup
);
74 static inline void kb_wait(void)
78 for (i
=0; i
<0x10000; i
++)
79 if ((inb_p(0x64) & 0x02) == 0)
83 void machine_shutdown(void)
87 /* Stop the cpus and apics */
91 /* The boot cpu is always logical cpu 0 */
94 /* Make certain the cpu I'm about to reboot on is online */
95 if (!cpu_isset(reboot_cpu_id
, cpu_online_map
)) {
96 reboot_cpu_id
= smp_processor_id();
99 /* Make certain I only run on the appropriate processor */
100 set_cpus_allowed(current
, cpumask_of_cpu(reboot_cpu_id
));
102 /* O.K Now that I'm on the appropriate processor,
103 * stop all of the others.
108 local_irq_save(flags
);
111 disable_local_APIC();
116 local_irq_restore(flags
);
118 pci_iommu_shutdown();
121 void machine_emergency_restart(void)
125 /* Tell the BIOS if we want cold or warm reboot */
126 *((unsigned short *)__va(0x472)) = reboot_mode
;
129 /* Could also try the reset bit in the Hammer NB */
130 switch (reboot_type
) {
132 for (i
=0; i
<10; i
++) {
135 outb(0xfe,0x64); /* pulse reset low */
140 load_idt((const struct desc_ptr
*)&no_idt
);
141 __asm__
__volatile__("int3");
143 reboot_type
= BOOT_KBD
;
149 void machine_restart(char * __unused
)
151 printk("machine restart\n");
156 machine_emergency_restart();
159 void machine_halt(void)
163 void machine_power_off(void)