2 Copyright © 2012-2017, 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>
17 #include "exec_intern.h"
18 #include "exec_util.h"
20 LONG
Alert_AskSuspend(struct Task
*task
, ULONG alertNum
, char * buffer
, struct ExecBase
*SysBase
);
21 void Alert_DisplayKrnAlert(struct Task
* task
, ULONG alertNum
, APTR location
, APTR stack
, UBYTE type
, APTR data
,
22 struct ExecBase
*SysBase
);
25 * This task tries to display alerts that occured in supervisor mode. The task that caused the
26 * problem is available in SAT.sat_Params[1]. The code that raised Alert is responsible for
27 * stopping/sanitizing the task itself. Since the task is already stopped, AT_DeadEnd is added to
28 * when invoking alert functions so that user does not have an option to continue the task.
30 void SupervisorAlertTask(struct ExecBase
*SysBase
)
32 struct IntExecBase
* IntSysBase
= PrivExecBase(SysBase
);
33 char * buffer
= AllocMem(ALERT_BUFFER_SIZE
, MEMF_ANY
);
35 struct Task
* t
= NULL
;
38 IntSysBase
->SAT
.sat_Task
= GET_THIS_TASK
;
39 IntSysBase
->SAT
.sat_IsAvailable
= TRUE
;
46 /* Mark task as in use so that nested crash will use critical error path, see Exec_SystemAlert */
47 IntSysBase
->SAT
.sat_IsAvailable
= FALSE
;
48 t
= (struct Task
*)IntSysBase
->SAT
.sat_Params
[1];
49 alertNum
= IntSysBase
->SAT
.sat_Params
[0];
52 res
= Alert_AskSuspend(t
, alertNum
| AT_DeadEnd
, buffer
, SysBase
);
56 /* It was not possible to report error to user, fallback to critical error path */
57 struct IntETask
* iet
= GetIntETask(t
);
60 Alert_DisplayKrnAlert(t
, alertNum
| AT_DeadEnd
, iet
->iet_AlertLocation
, iet
->iet_AlertStack
,
61 iet
->iet_AlertType
, (APTR
)&iet
->iet_AlertData
, SysBase
);
63 if (alertNum
& AT_DeadEnd
)
65 /* Um, we have to do something here in order to prevent the
66 computer from continuing... */
68 ShutdownA(SD_ACTION_COLDREBOOT
);
77 ShutdownA(SD_ACTION_POWEROFF
);
81 /* Suspend actually should have already happened by code raising Alert */
86 /* In case if ColdReboot() doesn't work */
87 ShutdownA(SD_ACTION_COLDREBOOT
);
93 /* Mark task as available */
94 IntSysBase
->SAT
.sat_IsAvailable
= TRUE
;
95 for (i
= 0; i
< 2; i
++)
96 IntSysBase
->SAT
.sat_Params
[i
] = (IPTR
)NULL
;