Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / i386-darwin / exec / exception.c
blobff5533eabbe9cfcdd050fc48d7716a0cf02a225d
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Exception - Perform a task exception.
6 Lang: english
7 */
8 #include <exec/execbase.h>
9 #include <aros/asmcall.h>
10 #include <proto/kernel.h>
11 #include <aros/kernel.h>
12 #include <proto/arossupport.h>
14 #include <signal.h>
15 #include <unistd.h>
17 /*****i*************************************************************************
19 NAME */
20 #include <proto/exec.h>
22 AROS_LH0(void, Exception,
24 /* LOCATION */
25 struct ExecBase *, SysBase, 11, Exec)
27 /* FUNCTION
28 Exception handler. This function is called by the kernel if
29 a task exception has occured. It is called in the Disable()'d
30 state so that all signals are still unchanged.
32 TF_EXCEPT is still set and must be reset by this routine.
34 The user supplied exception code is called with the
35 following parameters:
37 D0 - Mask of Flags which caused this exception.
38 A1 - Task->tc_ExceptData
39 A6 - SysBase
41 INPUTS
43 RESULT
45 NOTES
46 Exec internal function.
48 EXAMPLE
50 BUGS
52 SEE ALSO
53 Dispatch()
55 INTERNALS
56 At the end of this routine we set task->tc_State to TS_EXCEPT so the
57 the kernel knows it can restore the signaled task context and set it
58 to TS_RUN again.
60 ******************************************************************************/
62 AROS_LIBFUNC_INIT
64 KRNWireImpl(SoftEnable);
65 KRNWireImpl(SoftCause);
67 struct Task * task = FindTask(NULL);
68 BYTE nestCnt;
69 ULONG flags;
71 task->tc_Flags &= ~TF_EXCEPT;
73 nestCnt = SysBase->IDNestCnt;
74 SysBase->IDNestCnt = 0;
76 if ((flags = (task->tc_SigExcept & task->tc_SigRecvd)))
78 /* Call the Exception with the new AROS ASMCALL macros */
79 if (task->tc_ExceptCode != NULL)
81 /* Block the signals we are handling now. The exception handler
82 we are calling shall restore them.
84 task->tc_SigExcept ^= flags;
86 Enable();
87 task->tc_SigExcept |= AROS_UFC3(ULONG, task->tc_ExceptCode,
88 AROS_UFCA(ULONG, flags, D0),
89 AROS_UFCA(APTR, task->tc_ExceptData, A1),
90 AROS_UFCA(struct ExecBase *, SysBase, A6)
92 Disable();
94 else
96 /* We don't have an exception handler, we shouldn't have
97 any exceptions. Clear them.
100 task->tc_SigExcept = 0;
104 task->tc_State = TS_EXCEPT;
106 SysBase->IDNestCnt = nestCnt;
108 /* Enter the kernel. We use an endless loop just in case the
109 signal handler returns us to this point for whatever reason.
111 while (TRUE)
113 CALLHOOKPKT(krnSoftEnableImpl,0,0);
114 CALLHOOKPKT(krnSoftCauseImpl,0,0);
117 AROS_LIBFUNC_EXIT
118 } /* Exception */