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>
11 #include <asm/kdebug.h>
12 #include <asm/delay.h>
13 #include <asm/hw_irq.h>
14 #include <asm/system.h>
15 #include <asm/pgtable.h>
16 #include <asm/tlbflush.h>
20 * Power off function, if any
22 void (*pm_power_off
)(void);
24 static long no_idt
[3];
28 } reboot_type
= BOOT_KBD
;
29 static int reboot_mode
= 0;
32 /* reboot=t[riple] | k[bd] [, [w]arm | [c]old]
33 warm Don't set the cold reboot flag
34 cold Set the cold reboot flag
35 triple Force a triple fault (init)
36 kbd Use the keyboard controller. cold reset (default)
37 force Avoid anything that could hang.
39 static int __init
reboot_setup(char *str
)
60 if((str
= strchr(str
,',')) != NULL
)
68 __setup("reboot=", reboot_setup
);
70 static inline void kb_wait(void)
74 for (i
=0; i
<0x10000; i
++)
75 if ((inb_p(0x64) & 0x02) == 0)
79 void machine_shutdown(void)
82 /* Stop the cpus and apics */
86 /* The boot cpu is always logical cpu 0 */
89 /* Make certain the cpu I'm about to reboot on is online */
90 if (!cpu_isset(reboot_cpu_id
, cpu_online_map
)) {
91 reboot_cpu_id
= smp_processor_id();
94 /* Make certain I only run on the appropriate processor */
95 set_cpus_allowed(current
, cpumask_of_cpu(reboot_cpu_id
));
97 /* O.K Now that I'm on the appropriate processor,
98 * stop all of the others.
103 local_irq_save(flags
);
106 disable_local_APIC();
111 local_irq_restore(flags
);
114 void machine_emergency_restart(void)
118 /* Tell the BIOS if we want cold or warm reboot */
119 *((unsigned short *)__va(0x472)) = reboot_mode
;
122 /* Could also try the reset bit in the Hammer NB */
123 switch (reboot_type
) {
125 for (i
=0; i
<10; i
++) {
128 outb(0xfe,0x64); /* pulse reset low */
133 __asm__
__volatile__("lidt (%0)": :"r" (&no_idt
));
134 __asm__
__volatile__("int3");
136 reboot_type
= BOOT_KBD
;
142 void machine_restart(char * __unused
)
144 printk("machine restart\n");
149 machine_emergency_restart();
152 void machine_halt(void)
156 void machine_power_off(void)