source: trunk/packages/xen-3.1/xen-3.1/xen/common/shutdown.c @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 1.3 KB
Line 
1#include <xen/config.h>
2#include <xen/init.h>
3#include <xen/lib.h>
4#include <xen/sched.h>
5#include <xen/domain.h>
6#include <xen/delay.h>
7#include <xen/shutdown.h>
8#include <asm/debugger.h>
9#include <public/sched.h>
10
11/* opt_noreboot: If true, machine will need manual reset on error. */
12int opt_noreboot;
13boolean_param("noreboot", opt_noreboot);
14
15static void maybe_reboot(void)
16{
17    if ( opt_noreboot )
18    {
19        printk("'noreboot' set - not rebooting.\n");
20        machine_halt();
21    }
22    else
23    {
24        printk("rebooting machine in 5 seconds.\n");
25        watchdog_disable();
26        mdelay(5000);
27        machine_restart(NULL);
28    }
29}
30
31void dom0_shutdown(u8 reason)
32{
33    switch ( reason )
34    {
35    case SHUTDOWN_poweroff:
36    {
37        printk("Domain 0 halted: halting machine.\n");
38        machine_halt();
39        break; /* not reached */
40    }
41
42    case SHUTDOWN_crash:
43    {
44        debugger_trap_immediate();
45        printk("Domain 0 crashed: ");
46        maybe_reboot();
47        break; /* not reached */
48    }
49
50    case SHUTDOWN_reboot:
51    {
52        printk("Domain 0 shutdown: rebooting machine.\n");
53        machine_restart(NULL);
54        break; /* not reached */
55    }
56
57    default:
58    {
59        printk("Domain 0 shutdown (unknown reason %u): ", reason);
60        maybe_reboot();
61        break; /* not reached */
62    }
63    }
64} 
65
Note: See TracBrowser for help on using the repository browser.