Indentation fix, cleanup.
[AROS.git] / rom / exec / systemalert.c
blobbe91b2a4f34bffab2d77bb1674bf40a5c34c86a5
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Display an alert in supervisor mode.
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <exec/execbase.h>
11 #include <proto/kernel.h>
13 #include "etask.h"
14 #include "exec_intern.h"
15 #include "exec_util.h"
17 void Alert_DisplayKrnAlert(struct Task * task, ULONG alertNum, APTR location, APTR stack, UBYTE type, APTR data,
18 struct ExecBase *SysBase)
20 char *buf;
22 /* Get the title */
23 buf = Alert_AddString(PrivExecBase(SysBase)->AlertBuffer, Alert_GetTitle(alertNum));
24 *buf++ = '\n';
26 D(bug("[SystemAlert] Got title: %s\n", PrivExecBase(SysBase)->AlertBuffer));
28 /* Get the alert text */
29 buf = FormatAlert(buf, alertNum, task, location, type, SysBase);
30 FormatAlertExtra(buf, stack, type, data, SysBase);
32 /* Task is not available, display an alert via kernel.resource */
33 KrnDisplayAlert(alertNum, PrivExecBase(SysBase)->AlertBuffer);
37 * Display an alert via kernel.resource. This is called in a critical, hardly recoverable condition.
38 * Interrupts and multitasking are disabled here.
40 * Note that we use shared buffer in SysBase for alert text.
42 void Exec_SystemAlert(ULONG alertNum, APTR location, APTR stack, UBYTE type, APTR data, struct ExecBase *SysBase)
44 D(bug("[SystemAlert] Code 0x%08X, type %d, data 0x%p\n", alertNum, type, data));
46 if ((GET_THIS_TASK == PrivExecBase(SysBase)->SAT.sat_Task) &&
47 (PrivExecBase(SysBase)->SAT.sat_Params[1] != (IPTR) NULL))
49 /* SupervisorAlertTask crashed when trying to show crash information for another task */
51 struct Task * t = (struct Task*)PrivExecBase(SysBase)->SAT.sat_Params[1];
52 ULONG alertNum = PrivExecBase(SysBase)->SAT.sat_Params[0];
53 struct IntETask * iet = GetIntETask(t);
55 Alert_DisplayKrnAlert(t, alertNum | AT_DeadEnd, iet->iet_AlertLocation, iet->iet_AlertStack,
56 iet->iet_AlertType, (APTR)&iet->iet_AlertData, SysBase);
58 else if (PrivExecBase(SysBase)->SAT.sat_IsAvailable && !(alertNum & AT_DeadEnd))
60 /* SupervisorAlertTask is available, use it */
62 PrivExecBase(SysBase)->SAT.sat_Params[0] = alertNum;
63 PrivExecBase(SysBase)->SAT.sat_Params[1] = (IPTR)GET_THIS_TASK;
65 Signal(PrivExecBase(SysBase)->SAT.sat_Task, SIGF_SINGLE);
67 else
69 Alert_DisplayKrnAlert(GET_THIS_TASK, alertNum, location, stack, type, data, SysBase);