1 | /* PowerPC exception handling middleware; consult README for more |
---|
2 | * information. |
---|
3 | * |
---|
4 | * Author: Till Straumann <strauman@slac.stanford.edu>, 2007 |
---|
5 | * |
---|
6 | * The license and distribution terms for this file may be |
---|
7 | * found in found in the file LICENSE in this distribution or at |
---|
8 | * http://www.rtems.com/license/LICENSE. |
---|
9 | * |
---|
10 | * $Id$ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef PPC_EXC_SHARED_H |
---|
14 | #define PPC_EXC_SHARED_H |
---|
15 | |
---|
16 | #ifdef __cplusplus |
---|
17 | extern "C" { |
---|
18 | #endif |
---|
19 | |
---|
20 | /********* C-Exception Handlers *********************/ |
---|
21 | |
---|
22 | /* API to be used by middleware, */ |
---|
23 | /* BSP and application code (if necessary */ |
---|
24 | |
---|
25 | /****************************************************/ |
---|
26 | |
---|
27 | typedef int (*ppc_exc_handler_t)(BSP_Exception_frame *f, int vector); |
---|
28 | |
---|
29 | /* |
---|
30 | * Bits in MSR that are enabled during execution of exception handlers / ISRs |
---|
31 | * (on classic PPC these are DR/IR/RI [default], on bookE-style CPUs they should |
---|
32 | * be set to 0 during initialization) |
---|
33 | * |
---|
34 | * By default, the setting of these bits that is in effect when exception |
---|
35 | * handling is initialized is used. |
---|
36 | */ |
---|
37 | extern uint32_t ppc_exc_msr_bits; |
---|
38 | |
---|
39 | /* |
---|
40 | * Set of MSR bits required to disable all |
---|
41 | * asynchronous exceptions (depends on CPU type; |
---|
42 | * must be set during initialization). |
---|
43 | * Interrupt are disabled by writing the |
---|
44 | * one's complement of this mask to msr: |
---|
45 | * msr &= ~ppc_exc_msr_irq_mask; |
---|
46 | */ |
---|
47 | extern uint32_t ppc_exc_msr_irq_mask; |
---|
48 | |
---|
49 | /* |
---|
50 | * Hook C exception handlers. |
---|
51 | * - handlers for asynchronous exceptions run on the ISR stack |
---|
52 | * with thread-dispatching disabled. |
---|
53 | * - handlers for synchronous exceptions run on the task stack |
---|
54 | * with thread-dispatching enabled. |
---|
55 | * |
---|
56 | * If a particular slot is NULL then the traditional 'globalExcHdl' is used. |
---|
57 | * |
---|
58 | * ppc_exc_set_handler() registers a handler (returning 0 on success, |
---|
59 | * -1 if the vector argument is too big). |
---|
60 | * |
---|
61 | * It is legal to set a NULL handler. This leads to the globalExcHdl |
---|
62 | * being called if an exception for 'vector' occurs. |
---|
63 | */ |
---|
64 | int |
---|
65 | ppc_exc_set_handler(unsigned vector, ppc_exc_handler_t hdl); |
---|
66 | |
---|
67 | /* ppc_exc_get_handler() retrieves the currently active handler. |
---|
68 | */ |
---|
69 | ppc_exc_handler_t |
---|
70 | ppc_exc_get_handler(unsigned vector); |
---|
71 | |
---|
72 | /********* Low-level Exception Handlers *************/ |
---|
73 | |
---|
74 | /* This API is used by middleware code */ |
---|
75 | |
---|
76 | /****************************************************/ |
---|
77 | |
---|
78 | typedef uint32_t ppc_exc_min_prolog_t[4]; |
---|
79 | |
---|
80 | /* Templates are ppc_raw_except_func BUT they must be exactly 16 bytes */ |
---|
81 | typedef rtems_raw_except_func ppc_exc_min_prolog_template_t; |
---|
82 | |
---|
83 | /* |
---|
84 | * Expand a prolog template into 'buf' using vector 'vec' |
---|
85 | */ |
---|
86 | void |
---|
87 | ppc_exc_min_prolog_expand(ppc_exc_min_prolog_t buf, ppc_exc_min_prolog_template_t templ, uint16_t vec); |
---|
88 | |
---|
89 | extern unsigned ppc_exc_min_prolog_size[]; |
---|
90 | /* Symbols are defined by the linker; declare as an array so |
---|
91 | * that gcc doesn't attempt to emit a relocation looking for |
---|
92 | * it in the SDA section |
---|
93 | */ |
---|
94 | extern unsigned ppc_exc_tgpr_clr_prolog_size[]; |
---|
95 | |
---|
96 | /* Templates for ppc_exc_min_prolog_expand() which fills-in the vector information */ |
---|
97 | extern void ppc_exc_min_prolog_async_tmpl_std(); |
---|
98 | extern void ppc_exc_min_prolog_sync_tmpl_std(); |
---|
99 | extern void ppc_exc_min_prolog_async_tmpl_p405_crit(); |
---|
100 | extern void ppc_exc_min_prolog_sync_tmpl_p405_crit(); |
---|
101 | extern void ppc_exc_min_prolog_async_tmpl_bookE_crit(); |
---|
102 | extern void ppc_exc_min_prolog_sync_tmpl_bookE_crit(); |
---|
103 | extern void ppc_exc_min_prolog_sync_tmpl_e500_mchk(); |
---|
104 | extern void ppc_exc_min_prolog_async_tmpl_e500_mchk(); |
---|
105 | |
---|
106 | /* Special prologue for handling register shadowing on 603-style CPUs */ |
---|
107 | extern void ppc_exc_tgpr_clr_prolog(); |
---|
108 | /* Classic prologue which determines the vector dynamically from |
---|
109 | * the offset address. This must only be used for classic, synchronous |
---|
110 | * exceptions with a vector offset aligned on a 256-byte boundary. |
---|
111 | */ |
---|
112 | extern void ppc_exc_min_prolog_auto(); |
---|
113 | |
---|
114 | |
---|
115 | /* CPU support may store the address of a function here |
---|
116 | * that can be used by the default exception handler to |
---|
117 | * obtain fault-address info which is helpful. Unfortunately, |
---|
118 | * the SPR holding this information is not uniform |
---|
119 | * across PPC families so we need assistance from |
---|
120 | * CPU support |
---|
121 | */ |
---|
122 | extern uint32_t (*ppc_exc_get_DAR)(); |
---|
123 | |
---|
124 | #ifdef __cplusplus |
---|
125 | }; |
---|
126 | #endif |
---|
127 | |
---|
128 | #endif |
---|