1 | #ifndef BSP_EXCEPTION_HANDLER_H |
---|
2 | #define BSP_EXCEPTION_HANDLER_H |
---|
3 | /* $Id$ */ |
---|
4 | |
---|
5 | /* A slightly improved exception 'default' exception handler for RTEMS / SVGM */ |
---|
6 | |
---|
7 | /* Author: Till Straumann <strauman@slac.stanford.edu>, 2002/5 */ |
---|
8 | |
---|
9 | #include <bsp/vectors.h> |
---|
10 | |
---|
11 | /* Two types of exception intercepting / catching is supported: |
---|
12 | * |
---|
13 | * - lowlevel handling (runs at IRQ level, before restoring any |
---|
14 | * task context). |
---|
15 | * - highlevel handling. |
---|
16 | * |
---|
17 | * A lowlevel user hook is invoked twice, before and after processing |
---|
18 | * (printing) the exception. |
---|
19 | * If the user hook returns a nonzero value, normal processing |
---|
20 | * is skipped (including the second call to the hook) |
---|
21 | * |
---|
22 | * If the hook returns nonzero to the second call, no default |
---|
23 | * 'panic' occurs. |
---|
24 | * |
---|
25 | * Default 'panic': |
---|
26 | * - if a task context is available: |
---|
27 | * - if a highlevel handler is installed, pass control |
---|
28 | * to the highlevel handler when returning from the |
---|
29 | * exception (the highlevel handler should probably |
---|
30 | * do a longjmp()). Otherwise: |
---|
31 | * - try to suspend interrupted task. |
---|
32 | * - hang if no task context is available. |
---|
33 | * |
---|
34 | */ |
---|
35 | |
---|
36 | typedef struct BSP_ExceptionExtensionRec_ *BSP_ExceptionExtension; |
---|
37 | |
---|
38 | typedef int (*BSP_ExceptionHookProc)(BSP_Exception_frame *frame, BSP_ExceptionExtension ext, int after); |
---|
39 | |
---|
40 | typedef struct BSP_ExceptionExtensionRec_ { |
---|
41 | BSP_ExceptionHookProc lowlevelHook; |
---|
42 | int quiet; /* silence the exception handler */ |
---|
43 | void (*highlevelHook)(BSP_ExceptionExtension); |
---|
44 | /* user fields may be added after this */ |
---|
45 | } BSP_ExceptionExtensionRec; |
---|
46 | |
---|
47 | #define SRR1_TEA_EXC (1<<(31-13)) |
---|
48 | #define SRR1_MCP_EXC (1<<(31-12)) |
---|
49 | |
---|
50 | void |
---|
51 | BSP_exceptionHandler(BSP_Exception_frame* excPtr); |
---|
52 | |
---|
53 | /* install an exception handler to the current task context */ |
---|
54 | BSP_ExceptionExtension |
---|
55 | BSP_exceptionHandlerInstall(BSP_ExceptionExtension e); |
---|
56 | |
---|
57 | #endif |
---|