2df01bc69c4cd0a22a37fde914ec2935ffb82e05
[AROS.git] / arch / m68k-amiga / exec / shutdowna.c
blob2df01bc69c4cd0a22a37fde914ec2935ffb82e05
1 /*
2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: ShutdownA() - Shut down the operating system.
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <proto/exec.h>
12 #include "exec_util.h"
14 /*****************************************************************************
16 NAME */
18 AROS_LH1(ULONG, ShutdownA,
20 /* SYNOPSIS */
21 AROS_LHA(ULONG, action, D0),
23 /* LOCATION */
24 struct ExecBase *, SysBase, 173, Exec)
26 /* FUNCTION
27 This function will shut down the operating system.
29 INPUTS
30 action - what to do:
31 * SD_ACTION_POWEROFF - power off the machine.
32 * SD_ACTION_COLDREBOOT - cold reboot the machine (not only AROS).
34 RESULT
35 This function does not return in case of success. Otherwise is returns
36 zero.
38 NOTES
39 It can be quite harmful to call this function. It may be possible that
40 you will lose data from other tasks not having saved, or disk buffers
41 not being flushed. Plus you could annoy the (other) users.
43 EXAMPLE
45 BUGS
47 SEE ALSO
48 ColdReboot()
50 ******************************************************************************/
52 AROS_LIBFUNC_INIT
54 switch (action) {
55 case SD_ACTION_POWEROFF:
57 /* No stock Amiga hardware is known to support this.
58 * Emulation will support it (unless high compatibility setting enabled). */
59 typedef ULONG (*UAELIBFUNC)(ULONG);
60 UAELIBFUNC uaelibfunc = NULL;
61 APTR uaeres;
63 uaeres = OpenResource("uae.resource");
64 if (uaeres) { /* new method that allows dynamic UAE ROM location */
65 uaelibfunc = AROS_LVO_CALL1(APTR,
66 AROS_LCA(UBYTE*, "uaelib_demux", A0),
67 APTR, uaeres, 1, );
69 if (uaelibfunc == NULL) {
70 /* old-style absolute address */
71 uaelibfunc = (UAELIBFUNC)(0x00F00000 + 0xFF60);
72 if ((((ULONG*)uaelibfunc)[0] & 0xff00ffff) != 0xa0004e75)
73 uaelibfunc = NULL;
75 if (uaelibfunc) {
76 uaelibfunc(13);
77 /* This may return. Quits when next vblank arrives */
78 for(;;)
81 break;
83 case SD_ACTION_COLDREBOOT:
84 ColdReboot();
85 break;
88 return -1;
90 AROS_LIBFUNC_EXIT