6def8dc515351fa0f291480ba0e5b421e9af1349
[AROS.git] / arch / all-unix / exec / shutdowna.c
blob6def8dc515351fa0f291480ba0e5b421e9af1349
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: ShutdownA() - Shut down the operating system.
6 Lang: english
7 */
9 /* Prevent 'timeval redefinition' error */
10 #define _AROS_TYPES_TIMEVAL_S_H_
12 #include <aros/debug.h>
13 #include <proto/exec.h>
15 #include "exec_intern.h"
16 #include "exec_util.h"
18 /*****************************************************************************
20 NAME */
22 AROS_LH1(ULONG, ShutdownA,
24 /* SYNOPSIS */
25 AROS_LHA(ULONG, action, D0),
27 /* LOCATION */
28 struct ExecBase *, SysBase, 173, Exec)
30 /* FUNCTION
31 This function will shut down the operating system.
33 INPUTS
34 action - what to do:
35 * SD_ACTION_POWEROFF - power off the machine.
36 * SD_ACTION_COLDREBOOT - cold reboot the machine (not only AROS).
38 RESULT
39 This function does not return in case of success. Otherwise is returns
40 zero.
42 NOTES
43 It can be quite harmful to call this function. It may be possible that
44 you will lose data from other tasks not having saved, or disk buffers
45 not being flushed. Plus you could annoy the (other) users.
47 EXAMPLE
49 BUGS
51 SEE ALSO
52 ColdReboot()
54 ******************************************************************************/
56 AROS_LIBFUNC_INIT
58 int exitcode;
60 switch(action)
62 case SD_ACTION_POWEROFF:
63 exitcode = 0;
64 break;
66 case SD_ACTION_COLDREBOOT:
67 exitcode = 0x81; /* Magic value for our bootstrap */
68 break;
70 default:
71 return 0; /* Unknown action code */
74 Exec_DoResetCallbacks((struct IntExecBase *)SysBase, action);
76 PD(SysBase).SysIFace->exit(exitcode);
77 AROS_HOST_BARRIER
79 /* Just shut up the compiler, we won't return */
80 return 0;
82 AROS_LIBFUNC_EXIT