2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
5 Desc: Default trap handler
9 #include <exec/alerts.h>
10 #include <exec/tasks.h>
11 #include <proto/exec.h>
13 #include "kernel_cpu.h"
16 #include "exec_intern.h"
17 #include "exec_util.h"
19 /* In original AmigaOS the trap handler is entered in supervisor mode with the
20 * following on the supervisor stack:
22 * 4(sp) Processor dependent exception frame
23 * In our current implementation we use two pointers on stack. Context structure is
24 * currently private because it differs even on the same CPU, however i beleive it
25 * should be changed to some generalized form in order to allow applications (debuggers)
29 void Exec_TrapHandler(ULONG trapNum
, struct AROSCPUContext
*ctx
)
31 struct Task
*task
= SysBase
->ThisTask
;
34 /* Our situation is deadend */
35 trapNum
|= AT_DeadEnd
;
39 /* Get internal task structure */
40 iet
= GetIntETask(task
);
41 /* Protection against double-crash. If the alert code is already specified, we have
42 a second crash during processing the first one. Then we just pick up initial alert code
43 and just call Alert(). */
44 if (iet
->iet_AlertCode
)
45 trapNum
= iet
->iet_AlertCode
;
48 /* Otherwise we can try to send the crash to user level. Set alert information for the task */
50 iet
->iet_AlertLocation
= GET_PC(ctx
);
54 iet
->iet_AlertCode
= trapNum
;
55 /* Make the task to jump to crash handler. We don't care about return address etc because
56 the alert is deadend anyway. */
57 SET_PC(ctx
, Exec_CrashHandler
);