2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Display an alert.
9 #include <aros/debug.h>
10 #include <exec/alerts.h>
11 #include <exec/execbase.h>
12 #include <exec/rawfmt.h>
13 #include <proto/exec.h>
14 #include <proto/kernel.h>
17 #include "exec_intern.h"
18 #include "exec_util.h"
21 /* x86/64 kernel.resource doesn't have KrnIsSuper() */
23 #define KrnIsSuper() 0
26 /*****************************************************************************
33 AROS_LHA(ULONG
, alertNum
, D7
),
36 struct ExecBase
*, SysBase
, 18, Exec
)
39 Alerts the user of a serious system problem.
42 alertNum - This is a number which contains information about
43 the reason for the call.
46 This routine may return, if the alert is not a dead-end one.
49 You should not call this routine because it halts the machine,
50 displays the message and then may reboot it.
53 // Dead-End alert: 680x0 Access To Odd Address
62 ******************************************************************************/
66 struct Task
*task
= SysBase
->ThisTask
;
67 struct IntETask
*iet
= NULL
;
68 int supervisor
= KrnIsSuper();
70 D(bug("[exec] Alert 0x%08X\n", alertNum
));
74 iet
= GetIntETask(task
);
76 /* Do we already have location set? */
77 if (!(iet
->iet_AlertFlags
& AF_Location
))
79 /* If no, the location is where we were called from */
80 iet
->iet_AlertFlags
|= AF_Location
;
82 if (supervisor
&& ((alertNum
& ~AT_DeadEnd
) == AN_StackProbe
))
85 * Special case: AN_StackProbe issued by kernel's task dispatcher.
86 * Pick up data from task's context.
88 struct ExceptionContext
*ctx
= iet
->iet_Context
;
90 iet
->iet_AlertLocation
= (APTR
)ctx
->PC
;
91 iet
->iet_AlertStack
= (APTR
)ctx
->FP
;
95 iet
->iet_AlertLocation
= __builtin_return_address(0);
97 * And backtrace starts at caller's frame.
98 * On ARM we don't have frame pointer so we can't do backtrace.
99 * __builtin_frame_address(1) will return garbage, so don't do this.
102 iet
->iet_AlertStack
= NULL
;
104 iet
->iet_AlertStack
= __builtin_frame_address(1);
106 D(bug("[Alert] Previous frame 0x%p, caller 0x%p\n", iet
->iet_AlertStack
, iet
->iet_AlertLocation
));
112 * If we are running in user mode we should first try to report a problem
113 * using Intuition display.
117 alertNum
= Exec_UserAlert(alertNum
, SysBase
);
123 * We're here if Intuition failed. Use safe (but not so
124 * system and user-friendly) way to post alerts.
127 Exec_SystemAlert(alertNum
, SysBase
);
131 * We succesfully displayed an alert in supervisor mode.
132 * Clear alert status by clearing respective fields in ETask.
139 if (alertNum
& AT_DeadEnd
)
141 /* Um, we have to do something here in order to prevent the
142 computer from continuing... */
144 ShutdownA(SD_ACTION_COLDREBOOT
);