1 |
786 |
skrzyp |
#ifndef CYGONCE_HAL_INTR_H
|
2 |
|
|
#define CYGONCE_HAL_INTR_H
|
3 |
|
|
|
4 |
|
|
//==========================================================================
|
5 |
|
|
//
|
6 |
|
|
// hal_intr.h
|
7 |
|
|
//
|
8 |
|
|
// HAL Interrupt and clock support
|
9 |
|
|
//
|
10 |
|
|
//==========================================================================
|
11 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
12 |
|
|
// -------------------------------------------
|
13 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
14 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2007 Free Software Foundation, Inc.
|
15 |
|
|
//
|
16 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
17 |
|
|
// the terms of the GNU General Public License as published by the Free
|
18 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
19 |
|
|
// version.
|
20 |
|
|
//
|
21 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
22 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
23 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
24 |
|
|
// for more details.
|
25 |
|
|
//
|
26 |
|
|
// You should have received a copy of the GNU General Public License
|
27 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
28 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
29 |
|
|
//
|
30 |
|
|
// As a special exception, if other files instantiate templates or use
|
31 |
|
|
// macros or inline functions from this file, or you compile this file
|
32 |
|
|
// and link it with other works to produce a work based on this file,
|
33 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
34 |
|
|
// the GNU General Public License. However the source code for this file
|
35 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
36 |
|
|
// General Public License v2.
|
37 |
|
|
//
|
38 |
|
|
// This exception does not invalidate any other reasons why a work based
|
39 |
|
|
// on this file might be covered by the GNU General Public License.
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
//==========================================================================
|
43 |
|
|
//#####DESCRIPTIONBEGIN####
|
44 |
|
|
//
|
45 |
|
|
// Author(s): nickg
|
46 |
|
|
// Contributors: nickg, jskov,
|
47 |
|
|
// jlarmour
|
48 |
|
|
// Date: 1999-02-19
|
49 |
|
|
// Purpose: Define Interrupt support
|
50 |
|
|
// Description: The macros defined here provide the HAL APIs for handling
|
51 |
|
|
// interrupts and the clock.
|
52 |
|
|
//
|
53 |
|
|
// Usage:
|
54 |
|
|
// #include <cyg/hal/hal_intr.h>
|
55 |
|
|
// ...
|
56 |
|
|
//
|
57 |
|
|
//
|
58 |
|
|
//####DESCRIPTIONEND####
|
59 |
|
|
//
|
60 |
|
|
//==========================================================================
|
61 |
|
|
|
62 |
|
|
#include <pkgconf/hal.h>
|
63 |
|
|
|
64 |
|
|
#include <cyg/infra/cyg_type.h> // types
|
65 |
|
|
|
66 |
|
|
#include <cyg/hal/ppc_regs.h> // register definitions
|
67 |
|
|
|
68 |
|
|
#include <cyg/hal/var_intr.h> // variant extensions
|
69 |
|
|
|
70 |
|
|
//--------------------------------------------------------------------------
|
71 |
|
|
// PowerPC exception vectors. These correspond to VSRs and are the values
|
72 |
|
|
// to use for HAL_VSR_GET/SET
|
73 |
|
|
|
74 |
|
|
#define CYGNUM_HAL_VECTOR_RESERVED_0 0
|
75 |
|
|
#define CYGNUM_HAL_VECTOR_RESET 1
|
76 |
|
|
#define CYGNUM_HAL_VECTOR_MACHINE_CHECK 2
|
77 |
|
|
#define CYGNUM_HAL_VECTOR_DSI 3
|
78 |
|
|
#define CYGNUM_HAL_VECTOR_ISI 4
|
79 |
|
|
#define CYGNUM_HAL_VECTOR_INTERRUPT 5
|
80 |
|
|
#define CYGNUM_HAL_VECTOR_ALIGNMENT 6
|
81 |
|
|
#define CYGNUM_HAL_VECTOR_PROGRAM 7
|
82 |
|
|
#define CYGNUM_HAL_VECTOR_FP_UNAVAILABLE 8
|
83 |
|
|
#define CYGNUM_HAL_VECTOR_DECREMENTER 9
|
84 |
|
|
#define CYGNUM_HAL_VECTOR_RESERVED_A 10
|
85 |
|
|
#define CYGNUM_HAL_VECTOR_RESERVED_B 11
|
86 |
|
|
#define CYGNUM_HAL_VECTOR_SYSTEM_CALL 12
|
87 |
|
|
#define CYGNUM_HAL_VECTOR_TRACE 13
|
88 |
|
|
#define CYGNUM_HAL_VECTOR_FP_ASSIST 14
|
89 |
|
|
|
90 |
|
|
#ifdef CYGHWR_HAL_POWERPC_BOOK_E
|
91 |
|
|
|
92 |
|
|
// Additional exceptions on Book E CPUs. The numbers here do not
|
93 |
|
|
// necessarily correspond to the IVOR register number for the
|
94 |
|
|
// exception, but they must correspond to the table position in the
|
95 |
|
|
// rom_vectors table defined in vectors.S.
|
96 |
|
|
|
97 |
|
|
#define CYGNUM_HAL_VECTOR_RESERVED_F 15
|
98 |
|
|
#define CYGNUM_HAL_VECTOR_CRITICAL_INPUT 16
|
99 |
|
|
#define CYGNUM_HAL_VECTOR_AP_UNAVAILABLE 17
|
100 |
|
|
#define CYGNUM_HAL_VECTOR_FIT 18
|
101 |
|
|
#define CYGNUM_HAL_VECTOR_WATCHDOG 19
|
102 |
|
|
#define CYGNUM_HAL_VECTOR_DTLB_MISS 20
|
103 |
|
|
#define CYGNUM_HAL_VECTOR_ITLB_MISS 21
|
104 |
|
|
#define CYGNUM_HAL_VECTOR_DEBUG 22
|
105 |
|
|
#define CYGNUM_HAL_VECTOR_SPE_UNAVAILABLE 23
|
106 |
|
|
#define CYGNUM_HAL_VECTOR_SPE_FP_DATA 24
|
107 |
|
|
#define CYGNUM_HAL_VECTOR_SPE_FP_ROUND 25
|
108 |
|
|
|
109 |
|
|
#ifndef CYGNUM_HAL_VSR_MAX
|
110 |
|
|
#define CYGNUM_HAL_VSR_MAX CYGNUM_HAL_VECTOR_SPE_FP_ROUND
|
111 |
|
|
#endif
|
112 |
|
|
|
113 |
|
|
#endif
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
#define CYGNUM_HAL_VSR_MIN CYGNUM_HAL_VECTOR_RESERVED_0
|
117 |
|
|
#ifndef CYGNUM_HAL_VSR_MAX
|
118 |
|
|
# define CYGNUM_HAL_VSR_MAX CYGNUM_HAL_VECTOR_FP_ASSIST
|
119 |
|
|
#endif
|
120 |
|
|
#define CYGNUM_HAL_VSR_COUNT ( CYGNUM_HAL_VSR_MAX + 1 )
|
121 |
|
|
|
122 |
|
|
#ifndef CYG_VECTOR_IS_INTERRUPT
|
123 |
|
|
# define CYG_VECTOR_IS_INTERRUPT(v) \
|
124 |
|
|
(CYGNUM_HAL_VECTOR_INTERRUPT == (v) \
|
125 |
|
|
|| CYGNUM_HAL_VECTOR_DECREMENTER == (v))
|
126 |
|
|
#endif
|
127 |
|
|
|
128 |
|
|
// The decoded interrupts.
|
129 |
|
|
// Define decrementer as the first interrupt since it is guaranteed to
|
130 |
|
|
// be defined on all PowerPCs. External may expand into several interrupts
|
131 |
|
|
// depending on interrupt controller capabilities.
|
132 |
|
|
|
133 |
|
|
#ifndef CYGHWR_HAL_POWERPC_BOOK_E
|
134 |
|
|
|
135 |
|
|
#define CYGNUM_HAL_INTERRUPT_DECREMENTER 0
|
136 |
|
|
#define CYGNUM_HAL_INTERRUPT_EXTERNAL 1
|
137 |
|
|
|
138 |
|
|
#else
|
139 |
|
|
|
140 |
|
|
// For Book E processors, in addition the the decrementer, there are
|
141 |
|
|
// also a fixed interval timer and a watchdog which can generate
|
142 |
|
|
// asynchronous interrupts.
|
143 |
|
|
|
144 |
|
|
#define CYGNUM_HAL_INTERRUPT_DECREMENTER 0
|
145 |
|
|
#define CYGNUM_HAL_INTERRUPT_INTERVAL 1
|
146 |
|
|
#define CYGNUM_HAL_INTERRUPT_WATCHDOG 2
|
147 |
|
|
#define CYGNUM_HAL_INTERRUPT_EXTERNAL 3
|
148 |
|
|
|
149 |
|
|
#endif
|
150 |
|
|
|
151 |
|
|
#define CYGNUM_HAL_ISR_MIN CYGNUM_HAL_INTERRUPT_DECREMENTER
|
152 |
|
|
#ifndef CYGNUM_HAL_ISR_MAX
|
153 |
|
|
# define CYGNUM_HAL_ISR_MAX CYGNUM_HAL_INTERRUPT_EXTERNAL
|
154 |
|
|
#endif
|
155 |
|
|
#define CYGNUM_HAL_ISR_COUNT ( CYGNUM_HAL_ISR_MAX + 1 )
|
156 |
|
|
|
157 |
|
|
#ifndef CYGHWR_HAL_EXCEPTION_VECTORS_DEFINED
|
158 |
|
|
// Exception vectors. These are the values used when passed out to an
|
159 |
|
|
// external exception handler using cyg_hal_deliver_exception()
|
160 |
|
|
|
161 |
|
|
#define CYGNUM_HAL_EXCEPTION_RESERVED_0 CYGNUM_HAL_VECTOR_RESERVED_0
|
162 |
|
|
#define CYGNUM_HAL_EXCEPTION_MACHINE_CHECK CYGNUM_HAL_VECTOR_MACHINE_CHECK
|
163 |
|
|
#define CYGNUM_HAL_EXCEPTION_DATA_ACCESS CYGNUM_HAL_VECTOR_DSI
|
164 |
|
|
#define CYGNUM_HAL_EXCEPTION_CODE_ACCESS CYGNUM_HAL_VECTOR_ISI
|
165 |
|
|
#define CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS CYGNUM_HAL_VECTOR_ALIGNMENT
|
166 |
|
|
#define CYGNUM_HAL_EXCEPTION_FPU_NOT_AVAIL CYGNUM_HAL_VECTOR_FP_UNAVAILABLE
|
167 |
|
|
#define CYGNUM_HAL_EXCEPTION_RESERVED_A CYGNUM_HAL_VECTOR_RESERVED_A
|
168 |
|
|
#define CYGNUM_HAL_EXCEPTION_RESERVED_B CYGNUM_HAL_VECTOR_RESERVED_B
|
169 |
|
|
#define CYGNUM_HAL_EXCEPTION_SYSTEM_CALL CYGNUM_HAL_VECTOR_SYSTEM_CALL
|
170 |
|
|
#define CYGNUM_HAL_EXCEPTION_TRACE CYGNUM_HAL_VECTOR_TRACE
|
171 |
|
|
#define CYGNUM_HAL_EXCEPTION_FP_ASSIST CYGNUM_HAL_VECTOR_FP_ASSIST
|
172 |
|
|
|
173 |
|
|
#ifdef CYGHWR_HAL_POWERPC_BOOK_E
|
174 |
|
|
|
175 |
|
|
#define CYGNUM_HAL_EXCEPTION_RESERVED_F CYGNUM_HAL_VECTOR_RESERVED_F
|
176 |
|
|
#define CYGNUM_HAL_EXCEPTION_CRITICAL_INPUT CYGNUM_HAL_VECTOR_CRITICAL_INPUT
|
177 |
|
|
#define CYGNUM_HAL_EXCEPTION_AP_UNAVAILABLE CYGNUM_HAL_VECTOR_AP_UNAVAILABLE
|
178 |
|
|
#define CYGNUM_HAL_EXCEPTION_FIT CYGNUM_HAL_VECTOR_FIT
|
179 |
|
|
#define CYGNUM_HAL_EXCEPTION_WATCHDOG CYGNUM_HAL_VECTOR_WATCHDOG
|
180 |
|
|
#define CYGNUM_HAL_EXCEPTION_DTLB_MISS CYGNUM_HAL_VECTOR_DTLB_MISS
|
181 |
|
|
#define CYGNUM_HAL_EXCEPTION_ITLB_MISS CYGNUM_HAL_VECTOR_ITLB_MISS
|
182 |
|
|
#define CYGNUM_HAL_EXCEPTION_DEBUG CYGNUM_HAL_VECTOR_DEBUG
|
183 |
|
|
#define CYGNUM_HAL_EXCEPTION_SPE_UNAVAILABLE CYGNUM_HAL_VECTOR_SPE_UNAVAILABLE
|
184 |
|
|
#define CYGNUM_HAL_EXCEPTION_SPE_FP_DATA CYGNUM_HAL_VECTOR_SPE_FP_DATA
|
185 |
|
|
#define CYGNUM_HAL_EXCEPTION_SPE_FP_ROUND CYGNUM_HAL_VECTOR_SPE_FP_ROUND
|
186 |
|
|
|
187 |
|
|
#endif
|
188 |
|
|
|
189 |
|
|
#define CYGNUM_HAL_EXCEPTION_MIN CYGNUM_HAL_EXCEPTION_RESERVED_0
|
190 |
|
|
#ifndef CYGNUM_HAL_EXCEPTION_MAX
|
191 |
|
|
#define CYGNUM_HAL_EXCEPTION_MAX CYGNUM_HAL_VSR_MAX
|
192 |
|
|
#endif
|
193 |
|
|
|
194 |
|
|
#define CYGHWR_HAL_EXCEPTION_VECTORS_DEFINED
|
195 |
|
|
|
196 |
|
|
#endif // CYGHWR_HAL_EXCEPTION_VECTORS_DEFINED
|
197 |
|
|
|
198 |
|
|
#ifndef CYGHWR_HAL_POWERPC_BOOK_E
|
199 |
|
|
// FIXME: This is still rather ugly. Should probably be made variant
|
200 |
|
|
// specific using a decode_hal_exception macro or somesuch.
|
201 |
|
|
// decoded exception vectors
|
202 |
|
|
#define CYGNUM_HAL_EXCEPTION_TRAP (-1)
|
203 |
|
|
#define CYGNUM_HAL_EXCEPTION_PRIVILEGED_INSTRUCTION (-2)
|
204 |
|
|
#define CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION (-3)
|
205 |
|
|
#define CYGNUM_HAL_EXCEPTION_FPU (-4)
|
206 |
|
|
|
207 |
|
|
#undef CYGNUM_HAL_EXCEPTION_MIN
|
208 |
|
|
#define CYGNUM_HAL_EXCEPTION_MIN CYGNUM_HAL_EXCEPTION_FPU
|
209 |
|
|
#endif
|
210 |
|
|
|
211 |
|
|
#define CYGNUM_HAL_EXCEPTION_COUNT \
|
212 |
|
|
( CYGNUM_HAL_EXCEPTION_MAX - CYGNUM_HAL_EXCEPTION_MIN + 1 )
|
213 |
|
|
|
214 |
|
|
//--------------------------------------------------------------------------
|
215 |
|
|
// Static data used by HAL
|
216 |
|
|
|
217 |
|
|
// ISR tables
|
218 |
|
|
externC volatile CYG_ADDRESS hal_interrupt_handlers[CYGNUM_HAL_ISR_COUNT];
|
219 |
|
|
externC volatile CYG_ADDRWORD hal_interrupt_data[CYGNUM_HAL_ISR_COUNT];
|
220 |
|
|
externC volatile CYG_ADDRESS hal_interrupt_objects[CYGNUM_HAL_ISR_COUNT];
|
221 |
|
|
// VSR table
|
222 |
|
|
externC volatile CYG_ADDRESS hal_vsr_table[CYGNUM_HAL_VSR_COUNT];
|
223 |
|
|
|
224 |
|
|
//--------------------------------------------------------------------------
|
225 |
|
|
// Default ISRs
|
226 |
|
|
// The #define is used to test whether this routine exists, and to allow
|
227 |
|
|
// us to call it.
|
228 |
|
|
|
229 |
|
|
externC cyg_uint32 hal_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
|
230 |
|
|
externC cyg_uint32 hal_default_decrementer_isr(CYG_ADDRWORD vector,
|
231 |
|
|
CYG_ADDRWORD data);
|
232 |
|
|
|
233 |
|
|
#define HAL_DEFAULT_ISR hal_default_isr
|
234 |
|
|
|
235 |
|
|
//--------------------------------------------------------------------------
|
236 |
|
|
// Interrupt state storage
|
237 |
|
|
|
238 |
|
|
typedef cyg_uint32 CYG_INTERRUPT_STATE;
|
239 |
|
|
|
240 |
|
|
//--------------------------------------------------------------------------
|
241 |
|
|
// Interrupt control macros
|
242 |
|
|
|
243 |
|
|
#if !defined(CYGHWR_HAL_POWERPC_BOOK_E)
|
244 |
|
|
#define CYGARC_REG_MSR_INTBITS CYGARC_REG_MSR_EE
|
245 |
|
|
#else
|
246 |
|
|
#define CYGARC_REG_MSR_INTBITS (CYGARC_REG_MSR_EE|CYGARC_REG_MSR_CE)
|
247 |
|
|
#endif
|
248 |
|
|
|
249 |
|
|
#define HAL_DISABLE_INTERRUPTS(_old_) \
|
250 |
|
|
CYG_MACRO_START \
|
251 |
|
|
cyg_uint32 tmp1 = ~CYGARC_REG_MSR_INTBITS; \
|
252 |
|
|
cyg_uint32 tmp2; \
|
253 |
|
|
asm volatile ( \
|
254 |
|
|
"mfmsr %0;" \
|
255 |
|
|
"mr %2,%0;" \
|
256 |
|
|
"and %2,%2,%1;" \
|
257 |
|
|
"mtmsr %2;" \
|
258 |
|
|
: "=r"(_old_), "+r" (tmp1), "=r" (tmp2)); \
|
259 |
|
|
CYG_MACRO_END
|
260 |
|
|
|
261 |
|
|
#define HAL_ENABLE_INTERRUPTS() \
|
262 |
|
|
CYG_MACRO_START \
|
263 |
|
|
cyg_uint32 tmp1; \
|
264 |
|
|
cyg_uint32 tmp2 = CYGARC_REG_MSR_INTBITS; \
|
265 |
|
|
asm volatile ( \
|
266 |
|
|
"mfmsr %0;" \
|
267 |
|
|
"or %0,%0,%1;" \
|
268 |
|
|
"mtmsr %0;" \
|
269 |
|
|
: "=r" (tmp1), "+r" (tmp2)); \
|
270 |
|
|
CYG_MACRO_END
|
271 |
|
|
|
272 |
|
|
#define HAL_RESTORE_INTERRUPTS(_old_) \
|
273 |
|
|
CYG_MACRO_START \
|
274 |
|
|
cyg_uint32 tmp1; \
|
275 |
|
|
cyg_uint32 tmp2 = ~CYGARC_REG_MSR_INTBITS; \
|
276 |
|
|
asm volatile ( \
|
277 |
|
|
"mfmsr %0;" \
|
278 |
|
|
"and %0,%0,%1;" \
|
279 |
|
|
"not %1,%1;" \
|
280 |
|
|
"and %1,%1,%2;" \
|
281 |
|
|
"or %0,%0,%1;" \
|
282 |
|
|
"mtmsr %0;" \
|
283 |
|
|
: "=&r" (tmp1), "+r" (tmp2) \
|
284 |
|
|
: "r" (_old_)); \
|
285 |
|
|
CYG_MACRO_END
|
286 |
|
|
|
287 |
|
|
#define HAL_QUERY_INTERRUPTS(_old_) \
|
288 |
|
|
CYG_MACRO_START \
|
289 |
|
|
cyg_uint32 tmp = CYGARC_REG_MSR_INTBITS; \
|
290 |
|
|
asm volatile ( \
|
291 |
|
|
"mfmsr %0;" \
|
292 |
|
|
"and %0,%0,%1;" \
|
293 |
|
|
: "=&r"(_old_) \
|
294 |
|
|
: "r" (tmp)); \
|
295 |
|
|
CYG_MACRO_END
|
296 |
|
|
|
297 |
|
|
//--------------------------------------------------------------------------
|
298 |
|
|
// Machine check manipulation
|
299 |
|
|
#define HAL_DISABLE_MACHINE_CHECK(_old_) \
|
300 |
|
|
CYG_MACRO_START \
|
301 |
|
|
cyg_uint32 tmp1, tmp2; \
|
302 |
|
|
asm volatile ( \
|
303 |
|
|
"mfmsr %0;" \
|
304 |
|
|
"mr %2,%0;" \
|
305 |
|
|
"li %1,0;" \
|
306 |
|
|
"rlwimi %2,%1,0,19,19;" \
|
307 |
|
|
"mtmsr %2;" \
|
308 |
|
|
: "=r"(_old_), "=r" (tmp1), "=r" (tmp2)); \
|
309 |
|
|
CYG_MACRO_END
|
310 |
|
|
|
311 |
|
|
#define HAL_ENABLE_MACHINE_CHECK() \
|
312 |
|
|
CYG_MACRO_START \
|
313 |
|
|
cyg_uint32 tmp1, tmp2; \
|
314 |
|
|
asm volatile ( \
|
315 |
|
|
"mfmsr %0;" \
|
316 |
|
|
"lis %1,%1,0x0001;" \
|
317 |
|
|
"rlwimi %0,%1,0,19,19;" \
|
318 |
|
|
"mtmsr %0;" \
|
319 |
|
|
: "=r" (tmp1), "=r" (tmp2)); \
|
320 |
|
|
CYG_MACRO_END
|
321 |
|
|
|
322 |
|
|
#define HAL_QUERY_MACHINE_CHECK(_old_) \
|
323 |
|
|
CYG_MACRO_START \
|
324 |
|
|
cyg_uint32 tmp; \
|
325 |
|
|
asm volatile ( \
|
326 |
|
|
"mfmsr %0;" \
|
327 |
|
|
"lis %1,0x0001;" \
|
328 |
|
|
"and %0,%0,%1;" \
|
329 |
|
|
: "=&r"(_old_), "=r" (tmp)); \
|
330 |
|
|
CYG_MACRO_END
|
331 |
|
|
|
332 |
|
|
//--------------------------------------------------------------------------
|
333 |
|
|
// Vector translation.
|
334 |
|
|
|
335 |
|
|
#ifndef HAL_TRANSLATE_VECTOR
|
336 |
|
|
// Basic PowerPC configuration only has two vectors; decrementer and
|
337 |
|
|
// external. Isr tables/chaining use same vector decoder.
|
338 |
|
|
#define HAL_TRANSLATE_VECTOR(_vector_,_index_) \
|
339 |
|
|
(_index_) = (_vector_)
|
340 |
|
|
#endif
|
341 |
|
|
|
342 |
|
|
//--------------------------------------------------------------------------
|
343 |
|
|
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
|
344 |
|
|
|
345 |
|
|
externC void hal_interrupt_stack_call_pending_DSRs(void);
|
346 |
|
|
#define HAL_INTERRUPT_STACK_CALL_PENDING_DSRS() \
|
347 |
|
|
hal_interrupt_stack_call_pending_DSRs()
|
348 |
|
|
|
349 |
|
|
// these are offered solely for stack usage testing
|
350 |
|
|
// if they are not defined, then there is no interrupt stack.
|
351 |
|
|
#define HAL_INTERRUPT_STACK_BASE cyg_interrupt_stack_base
|
352 |
|
|
#define HAL_INTERRUPT_STACK_TOP cyg_interrupt_stack
|
353 |
|
|
// use them to declare these extern however you want:
|
354 |
|
|
// extern char HAL_INTERRUPT_STACK_BASE[];
|
355 |
|
|
// extern char HAL_INTERRUPT_STACK_TOP[];
|
356 |
|
|
// is recommended
|
357 |
|
|
#endif
|
358 |
|
|
|
359 |
|
|
//--------------------------------------------------------------------------
|
360 |
|
|
// Interrupt and VSR attachment macros
|
361 |
|
|
|
362 |
|
|
#define HAL_INTERRUPT_IN_USE( _vector_, _state_) \
|
363 |
|
|
CYG_MACRO_START \
|
364 |
|
|
cyg_uint32 _index_; \
|
365 |
|
|
HAL_TRANSLATE_VECTOR ((_vector_), _index_); \
|
366 |
|
|
\
|
367 |
|
|
if((hal_interrupt_handlers[_index_] \
|
368 |
|
|
== (CYG_ADDRESS)hal_default_decrementer_isr) \
|
369 |
|
|
|| (hal_interrupt_handlers[_index_] == (CYG_ADDRESS)hal_default_isr)) \
|
370 |
|
|
(_state_) = 0; \
|
371 |
|
|
else \
|
372 |
|
|
(_state_) = 1; \
|
373 |
|
|
CYG_MACRO_END
|
374 |
|
|
|
375 |
|
|
#define HAL_INTERRUPT_ATTACH( _vector_, _isr_, _data_, _object_ ) \
|
376 |
|
|
CYG_MACRO_START \
|
377 |
|
|
cyg_uint32 _index_; \
|
378 |
|
|
HAL_TRANSLATE_VECTOR ((_vector_), _index_); \
|
379 |
|
|
\
|
380 |
|
|
if((hal_interrupt_handlers[_index_] \
|
381 |
|
|
== (CYG_ADDRESS)hal_default_decrementer_isr) \
|
382 |
|
|
|| (hal_interrupt_handlers[_index_] == (CYG_ADDRESS)hal_default_isr)) \
|
383 |
|
|
{ \
|
384 |
|
|
hal_interrupt_handlers[_index_] = (CYG_ADDRESS)_isr_; \
|
385 |
|
|
hal_interrupt_data[_index_] = (CYG_ADDRWORD) _data_; \
|
386 |
|
|
hal_interrupt_objects[_index_] = (CYG_ADDRESS)_object_; \
|
387 |
|
|
} \
|
388 |
|
|
CYG_MACRO_END
|
389 |
|
|
|
390 |
|
|
#define HAL_INTERRUPT_DETACH( _vector_, _isr_ ) \
|
391 |
|
|
CYG_MACRO_START \
|
392 |
|
|
cyg_uint32 _index_; \
|
393 |
|
|
HAL_TRANSLATE_VECTOR ((_vector_), _index_); \
|
394 |
|
|
\
|
395 |
|
|
if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)_isr_ ) \
|
396 |
|
|
{ \
|
397 |
|
|
if (CYGNUM_HAL_INTERRUPT_DECREMENTER == (_vector_)) \
|
398 |
|
|
hal_interrupt_handlers[_index_] = \
|
399 |
|
|
(CYG_ADDRESS)hal_default_decrementer_isr; \
|
400 |
|
|
else \
|
401 |
|
|
hal_interrupt_handlers[_index_] = (CYG_ADDRESS)hal_default_isr; \
|
402 |
|
|
hal_interrupt_data[_index_] = 0; \
|
403 |
|
|
hal_interrupt_objects[_index_] = 0; \
|
404 |
|
|
} \
|
405 |
|
|
CYG_MACRO_END
|
406 |
|
|
|
407 |
|
|
#define HAL_VSR_GET( _vector_, _pvsr_ ) \
|
408 |
|
|
*(CYG_ADDRESS *)(_pvsr_) = hal_vsr_table[_vector_];
|
409 |
|
|
|
410 |
|
|
|
411 |
|
|
#define HAL_VSR_SET( _vector_, _vsr_, _poldvsr_ ) \
|
412 |
|
|
CYG_MACRO_START \
|
413 |
|
|
if( _poldvsr_ != NULL ) \
|
414 |
|
|
*(CYG_ADDRESS *)_poldvsr_ = hal_vsr_table[_vector_]; \
|
415 |
|
|
hal_vsr_table[_vector_] = (CYG_ADDRESS)_vsr_; \
|
416 |
|
|
CYG_MACRO_END
|
417 |
|
|
|
418 |
|
|
// This is an ugly name, but what it means is: grab the VSR back to eCos
|
419 |
|
|
// internal handling, or if you like, the default handler. But if
|
420 |
|
|
// cooperating with GDB and CygMon, the default behaviour is to pass most
|
421 |
|
|
// exceptions to CygMon. This macro undoes that so that eCos handles the
|
422 |
|
|
// exception. So use it with care.
|
423 |
|
|
externC void cyg_hal_default_interrupt_vsr( void );
|
424 |
|
|
externC void cyg_hal_default_exception_vsr( void );
|
425 |
|
|
#define HAL_VSR_SET_TO_ECOS_HANDLER( _vector_, _poldvsr_ ) \
|
426 |
|
|
CYG_MACRO_START \
|
427 |
|
|
if( (void*)_poldvsr_ != (void*)NULL ) \
|
428 |
|
|
*(CYG_ADDRESS *)_poldvsr_ = hal_vsr_table[_vector_]; \
|
429 |
|
|
hal_vsr_table[_vector_] = ( CYG_VECTOR_IS_INTERRUPT( _vector_ ) \
|
430 |
|
|
? (CYG_ADDRESS)cyg_hal_default_interrupt_vsr \
|
431 |
|
|
: (CYG_ADDRESS)cyg_hal_default_exception_vsr ); \
|
432 |
|
|
CYG_MACRO_END
|
433 |
|
|
|
434 |
|
|
|
435 |
|
|
#ifndef CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
|
436 |
|
|
|
437 |
|
|
#define HAL_INTERRUPT_MASK( _vector_ )
|
438 |
|
|
|
439 |
|
|
#define HAL_INTERRUPT_UNMASK( _vector_ )
|
440 |
|
|
|
441 |
|
|
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )
|
442 |
|
|
|
443 |
|
|
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ )
|
444 |
|
|
|
445 |
|
|
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )
|
446 |
|
|
|
447 |
|
|
#endif
|
448 |
|
|
|
449 |
|
|
//--------------------------------------------------------------------------
|
450 |
|
|
// Clock control
|
451 |
|
|
|
452 |
|
|
#ifndef CYGHWR_HAL_CLOCK_DEFINED
|
453 |
|
|
// Note: variant or platform allowed to override these definitions
|
454 |
|
|
|
455 |
|
|
#define HAL_CLOCK_INITIALIZE( _period_ ) \
|
456 |
|
|
CYG_MACRO_START \
|
457 |
|
|
asm volatile ( \
|
458 |
|
|
"mtdec %0;" \
|
459 |
|
|
: \
|
460 |
|
|
: "r"(_period_) \
|
461 |
|
|
); \
|
462 |
|
|
CYG_MACRO_END
|
463 |
|
|
|
464 |
|
|
#define HAL_CLOCK_RESET( _vector_, _period_ ) \
|
465 |
|
|
CYG_MACRO_START \
|
466 |
|
|
cyg_uint32 tmp; \
|
467 |
|
|
asm volatile ( \
|
468 |
|
|
"mfdec %0;" \
|
469 |
|
|
"add. %0,%0,%1;" \
|
470 |
|
|
"bgt 1f;" \
|
471 |
|
|
"mr %0,%1;" \
|
472 |
|
|
"1: mtdec %0;" \
|
473 |
|
|
: "=&r" (tmp) \
|
474 |
|
|
: "r"(_period_) \
|
475 |
|
|
: "cc" \
|
476 |
|
|
); \
|
477 |
|
|
CYG_MACRO_END
|
478 |
|
|
|
479 |
|
|
#define HAL_CLOCK_READ( _pvalue_ ) \
|
480 |
|
|
CYG_MACRO_START \
|
481 |
|
|
register cyg_uint32 result; \
|
482 |
|
|
asm volatile( \
|
483 |
|
|
"mfdec %0;" \
|
484 |
|
|
: "=r"(result) \
|
485 |
|
|
); \
|
486 |
|
|
*(_pvalue_) = CYGNUM_HAL_RTC_PERIOD-result; \
|
487 |
|
|
CYG_MACRO_END
|
488 |
|
|
|
489 |
|
|
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY
|
490 |
|
|
#define HAL_CLOCK_LATENCY( _pvalue_ ) \
|
491 |
|
|
CYG_MACRO_START \
|
492 |
|
|
register cyg_int32 result; \
|
493 |
|
|
asm volatile( \
|
494 |
|
|
"mfdec %0;" \
|
495 |
|
|
: "=r"(result) \
|
496 |
|
|
); \
|
497 |
|
|
/* Pending DEC interrupts cannot be discarded. If dec is */ \
|
498 |
|
|
/* positive it''s because a DEC interrupt occured while */ \
|
499 |
|
|
/* eCos was getting ready to run. Just return 0 in that */ \
|
500 |
|
|
/* case. */ \
|
501 |
|
|
if (result > 0) \
|
502 |
|
|
result = 0; \
|
503 |
|
|
*(_pvalue_) = -result; \
|
504 |
|
|
CYG_MACRO_END
|
505 |
|
|
#endif
|
506 |
|
|
|
507 |
|
|
#ifndef HAL_DELAY_US
|
508 |
|
|
externC void hal_delay_us(int);
|
509 |
|
|
#define HAL_DELAY_US(n) hal_delay_us(n)
|
510 |
|
|
#endif
|
511 |
|
|
|
512 |
|
|
// The vector used by the Real time clock
|
513 |
|
|
#ifndef CYGNUM_HAL_INTERRUPT_RTC
|
514 |
|
|
#define CYGNUM_HAL_INTERRUPT_RTC CYGNUM_HAL_INTERRUPT_DECREMENTER
|
515 |
|
|
#endif // CYGNUM_HAL_INTERRUPT_RTC
|
516 |
|
|
|
517 |
|
|
#endif // CYGHWR_HAL_CLOCK_DEFINED
|
518 |
|
|
|
519 |
|
|
//--------------------------------------------------------------------------
|
520 |
|
|
// Variant functions
|
521 |
|
|
externC void hal_variant_IRQ_init(void);
|
522 |
|
|
|
523 |
|
|
//--------------------------------------------------------------------------
|
524 |
|
|
#endif // ifndef CYGONCE_HAL_INTR_H
|
525 |
|
|
// End of hal_intr.h
|