2 Copyright © 2012-2015, The AROS Development Team. All rights reserved.
5 Desc: Display an alert passed from supervisor mode.
9 #include <aros/debug.h>
10 #include <exec/alerts.h>
11 #include <exec/rawfmt.h>
12 #include <intuition/intuition.h>
13 #include <proto/exec.h>
14 #include <proto/intuition.h>
15 #include <proto/kernel.h>
18 #include "exec_intern.h"
19 #include "exec_util.h"
21 LONG
Alert_AskSuspend(struct Task
*task
, ULONG alertNum
, char * buffer
, struct ExecBase
*SysBase
);
22 void Alert_DisplayKrnAlert(struct Task
* task
, ULONG alertNum
, APTR location
, APTR stack
, UBYTE type
, APTR data
,
23 struct ExecBase
*SysBase
);
26 * This task tries to display alerts that occured in supervisor mode. The task that caused the
27 * problem is available in SAT.sat_Params[1]. The code that raised Alert is responsible for
28 * stopping/sanitizing the task itself. Since the task is already stopped, AT_DeadEnd is added to
29 * when invoking alert functions so that user does not have an option to continue the task.
31 void SupervisorAlertTask(struct ExecBase
*SysBase
)
33 struct IntExecBase
* IntSysBase
= PrivExecBase(SysBase
);
34 char * buffer
= AllocMem(ALERT_BUFFER_SIZE
, MEMF_ANY
);
36 struct Task
* t
= NULL
;
39 IntSysBase
->SAT
.sat_Task
= GET_THIS_TASK
;
40 IntSysBase
->SAT
.sat_IsAvailable
= TRUE
;
47 /* Mark task as in use so that nested crash will use critical error path, see Exec_SystemAlert */
48 IntSysBase
->SAT
.sat_IsAvailable
= FALSE
;
49 t
= (struct Task
*)IntSysBase
->SAT
.sat_Params
[1];
50 alertNum
= IntSysBase
->SAT
.sat_Params
[0];
53 res
= Alert_AskSuspend(t
, alertNum
| AT_DeadEnd
, buffer
, SysBase
);
57 /* It was not possible to report error to user, fallback to critical error path */
58 struct IntETask
* iet
= GetIntETask(t
);
61 Alert_DisplayKrnAlert(t
, alertNum
| AT_DeadEnd
, iet
->iet_AlertLocation
, iet
->iet_AlertStack
,
62 iet
->iet_AlertType
, (APTR
)&iet
->iet_AlertData
, SysBase
);
64 if (alertNum
& AT_DeadEnd
)
66 /* Um, we have to do something here in order to prevent the
67 computer from continuing... */
69 ShutdownA(SD_ACTION_COLDREBOOT
);
78 ShutdownA(SD_ACTION_POWEROFF
);
82 /* Suspend actually should have already happened by code raising Alert */
87 /* In case if ColdReboot() doesn't work */
88 ShutdownA(SD_ACTION_COLDREBOOT
);
94 /* Mark task as available */
95 IntSysBase
->SAT
.sat_IsAvailable
= TRUE
;
96 for (i
= 0; i
< 2; i
++)
97 IntSysBase
->SAT
.sat_Params
[i
] = (IPTR
)NULL
;