source: rtems/c/src/lib/libcpu/powerpc/mpc5xx/irq/irq.h @ 297d99b1

4.104.114.84.95
Last change on this file since 297d99b1 was 8430205, checked in by Joel Sherrill <joel.sherrill@…>, on 04/12/04 at 22:04:28

2004-04-12 David Querbach <querbach@…>

  • README, configure.ac, mpc5xx/Makefile.am, mpc5xx/exceptions/raw_exception.c, mpc5xx/exceptions/raw_exception.h, mpc5xx/timer/timer.c, shared/include/cpuIdent.h: addition of a significant amount of MPC5xx support as part of the addition of the SS555 BSP.
  • mpc5xx/README, mpc5xx/clock/clock.c, mpc5xx/console-generic/console-generic.c, mpc5xx/include/console.h, mpc5xx/include/mpc5xx.h, mpc5xx/irq/irq.c, mpc5xx/irq/irq.h, mpc5xx/irq/irq_asm.S, mpc5xx/irq/irq_init.c, mpc5xx/vectors/vectors.S, mpc5xx/vectors/vectors.h, mpc5xx/vectors/vectors_init.c: New files.
  • mpc5xx/exceptions/asm_utils.S: Removed.
  • Property mode set to 100644
File size: 10.9 KB
Line 
1/*
2 * irq.h
3 *
4 *  This include file describe the data structure and the functions implemented
5 *  by rtems to write interrupt handlers.
6 *
7 *
8 *  MPC5xx port sponsored by Defence Research and Development Canada - Suffield
9 *  Copyright (C) 2004, Real-Time Systems Inc. (querbach@realtime.bc.ca)
10 *
11 *  Derived from libbsp/powerpc/mbx8xx/irq/irq.h:
12 *
13 *  CopyRight (C) 1999 valette@crf.canon.fr
14 *
15 *  This code is heavilly inspired by the public specification of STREAM V2
16 *  that can be found at :
17 *
18 *      <http://www.chorus.com/Documentation/index.html> by following
19 *  the STREAM API Specification Document link.
20 *
21 *  The license and distribution terms for this file may be
22 *  found in found in the file LICENSE in this distribution or at
23 *  http://www.rtems.com/license/LICENSE.
24 *
25 *  $Id$
26 */
27
28#ifndef LIBCPU_POWERPC_MBX8XX_IRQ_IRQ_H
29#define LIBCPU_POWERPC_MBX8XX_IRQ_IRQ_H
30
31
32#define CPU_ASM_IRQ_VECTOR_BASE 0x0
33
34#ifndef ASM
35
36extern volatile unsigned int ppc_cached_irq_mask;
37
38/*
39 * Symblolic IRQ names and related definitions.
40 */
41
42typedef enum {
43  /*
44   * Base vector for our USIU IRQ handlers.
45   */
46  CPU_USIU_VECTOR_BASE          = CPU_ASM_IRQ_VECTOR_BASE,
47  /*
48   * USIU IRQ handler related definitions
49   */
50  CPU_USIU_IRQ_COUNT            = 16, /* 16 reserved but in the future... */
51  CPU_USIU_IRQ_MIN_OFFSET       = 0,
52  CPU_USIU_IRQ_MAX_OFFSET       = CPU_USIU_IRQ_MIN_OFFSET + CPU_USIU_IRQ_COUNT - 1,
53  /*
54   * UIMB IRQ handlers related definitions
55   */
56  CPU_UIMB_IRQ_COUNT            = 32 - 8, /* first 8 overlap USIU */
57  CPU_UIMB_IRQ_MIN_OFFSET       = CPU_USIU_IRQ_COUNT + CPU_USIU_VECTOR_BASE,
58  CPU_UIMB_IRQ_MAX_OFFSET       = CPU_UIMB_IRQ_MIN_OFFSET + CPU_UIMB_IRQ_COUNT - 1,
59  /*
60   * PowerPc exceptions handled as interrupt where a rtems managed interrupt
61   * handler might be connected
62   */
63  CPU_PROC_IRQ_COUNT            = 1,
64  CPU_PROC_IRQ_MIN_OFFSET       = CPU_UIMB_IRQ_MAX_OFFSET + 1,
65  CPU_PROC_IRQ_MAX_OFFSET       = CPU_PROC_IRQ_MIN_OFFSET + CPU_PROC_IRQ_COUNT - 1,
66  /*
67   * Summary
68   */
69  CPU_IRQ_COUNT                 = CPU_PROC_IRQ_MAX_OFFSET + 1,
70  CPU_MIN_OFFSET                = CPU_USIU_IRQ_MIN_OFFSET,
71  CPU_MAX_OFFSET                = CPU_PROC_IRQ_MAX_OFFSET,
72  /*
73   * USIU IRQ symbolic name definitions.
74   */         
75  CPU_USIU_EXT_IRQ_0            = CPU_USIU_IRQ_MIN_OFFSET,
76  CPU_USIU_INT_IRQ_0,
77
78  CPU_USIU_EXT_IRQ_1,
79  CPU_USIU_INT_IRQ_1,
80
81  CPU_USIU_EXT_IRQ_2,
82  CPU_USIU_INT_IRQ_2,
83 
84  CPU_USIU_EXT_IRQ_3,
85  CPU_USIU_INT_IRQ_3,
86 
87  CPU_USIU_EXT_IRQ_4,
88  CPU_USIU_INT_IRQ_4,
89
90  CPU_USIU_EXT_IRQ_5,
91  CPU_USIU_INT_IRQ_5,
92 
93  CPU_USIU_EXT_IRQ_6,
94  CPU_USIU_INT_IRQ_6,
95 
96  CPU_USIU_EXT_IRQ_7,
97  CPU_USIU_INT_IRQ_7,
98
99  /*
100   * Symbolic names for UISU interrupt sources.
101   */
102  CPU_PERIODIC_TIMER            = CPU_USIU_INT_IRQ_6,
103  CPU_UIMB_INTERRUPT            = CPU_USIU_INT_IRQ_7,
104             
105  /*
106   * UIMB IRQ symbolic name definitions.  The first 8 sources are aliases to
107   * the USIU interrupts of the same number, because they are detected in
108   * the USIU pending register rather than the UIMB pending register.
109   */
110  CPU_UIMB_IRQ_0                = CPU_USIU_INT_IRQ_0,
111  CPU_UIMB_IRQ_1                = CPU_USIU_INT_IRQ_1,
112  CPU_UIMB_IRQ_2                = CPU_USIU_INT_IRQ_2,
113  CPU_UIMB_IRQ_3                = CPU_USIU_INT_IRQ_3,
114  CPU_UIMB_IRQ_4                = CPU_USIU_INT_IRQ_4,
115  CPU_UIMB_IRQ_5                = CPU_USIU_INT_IRQ_5,
116  CPU_UIMB_IRQ_6                = CPU_USIU_INT_IRQ_6,
117  CPU_UIMB_IRQ_7                = CPU_USIU_INT_IRQ_7,
118
119  CPU_UIMB_IRQ_8                = CPU_UIMB_IRQ_MIN_OFFSET,
120  CPU_UIMB_IRQ_9,
121  CPU_UIMB_IRQ_10,
122  CPU_UIMB_IRQ_11,
123  CPU_UIMB_IRQ_12,
124  CPU_UIMB_IRQ_13,
125  CPU_UIMB_IRQ_14,
126  CPU_UIMB_IRQ_15,
127  CPU_UIMB_IRQ_16,
128  CPU_UIMB_IRQ_17,
129  CPU_UIMB_IRQ_18,
130  CPU_UIMB_IRQ_19,
131  CPU_UIMB_IRQ_20,
132  CPU_UIMB_IRQ_21,
133  CPU_UIMB_IRQ_22,
134  CPU_UIMB_IRQ_23,
135  CPU_UIMB_IRQ_24,
136  CPU_UIMB_IRQ_25,
137  CPU_UIMB_IRQ_26,
138  CPU_UIMB_IRQ_27,
139  CPU_UIMB_IRQ_28,
140  CPU_UIMB_IRQ_29,
141  CPU_UIMB_IRQ_30,
142  CPU_UIMB_IRQ_31,
143 
144  /*
145   * Symbolic names for UIMB interrupt sources.
146   */
147  CPU_IRQ_SCI                   = CPU_UIMB_IRQ_5,
148
149  /*
150   * Processor exceptions handled as rtems IRQ symbolic name definitions.
151   */
152  CPU_DECREMENTER               = CPU_PROC_IRQ_MIN_OFFSET
153     
154}rtems_irq_symbolic_name;
155
156/*
157 * Convert an rtems_irq_symbolic_name constant to an interrupt level
158 * suitable for programming into an I/O device's interrupt level field.
159 */
160int CPU_irq_level_from_symbolic_name(const rtems_irq_symbolic_name name);
161
162/*
163 * Type definition for RTEMS managed interrupts
164 */
165typedef unsigned char  rtems_irq_prio;
166struct  __rtems_irq_connect_data__;     /* forward declaratiuon */
167
168typedef void (*rtems_irq_hdl)           (void);
169typedef void (*rtems_irq_enable)        (const struct __rtems_irq_connect_data__*);
170typedef void (*rtems_irq_disable)       (const struct __rtems_irq_connect_data__*);
171typedef int  (*rtems_irq_is_enabled)    (const struct __rtems_irq_connect_data__*);
172
173typedef struct __rtems_irq_connect_data__ {
174  /*
175   * IRQ line
176   */
177  rtems_irq_symbolic_name       name;
178  /*
179   * Handler. See comment on handler properties below in function prototype.
180   */
181  rtems_irq_hdl                 hdl;
182  /*
183   * Function for enabling interrupts at device level (ONLY!).
184   * The CPU code will automatically enable it at USIU level and UIMB level.
185   * RATIONALE : anyway such code has to exist in current driver code.
186   * It is usually called immediately AFTER connecting the interrupt handler.
187   * RTEMS may well need such a function when restoring normal interrupt
188   * processing after a debug session.
189   *
190   */
191    rtems_irq_enable            on;     
192  /*
193   * Function for disabling interrupts at device level (ONLY!).
194   * The code will disable it at USIU and UIMB level. RATIONALE : anyway
195   * such code has to exist for clean shutdown. It is usually called
196   * BEFORE disconnecting the interrupt. RTEMS may well need such
197   * a function when disabling normal interrupt processing for
198   * a debug session. May well be a NOP function.
199   */
200  rtems_irq_disable             off;
201  /*
202   * Function enabling to know what interrupt may currently occur
203   * if someone manipulates the USIU and UIMB interrupt mask without care...
204   */
205  rtems_irq_is_enabled          isOn;
206}rtems_irq_connect_data;
207
208typedef struct {
209  /*
210   * size of all the table fields (*Tbl) described below.
211   */
212  unsigned int                  irqNb;
213  /*
214   * Default handler used when disconnecting interrupts.
215   */
216  rtems_irq_connect_data        defaultEntry;
217  /*
218   * Table containing initials/current value.
219   */
220  rtems_irq_connect_data*       irqHdlTbl;
221  /*
222   * actual value of CPU_USIU_IRQ_VECTOR_BASE...
223   */
224  rtems_irq_symbolic_name       irqBase;
225  /*
226   * software priorities associated with interrupts.
227   * if irqPrio  [i]  >  intrPrio  [j]  it  means  that 
228   * interrupt handler hdl connected for interrupt name i
229   * will  not be interrupted by the handler connected for interrupt j
230   * The interrupt source  will be physically masked at USIU and UIMB level.
231   */
232  rtems_irq_prio*               irqPrioTbl;
233}rtems_irq_global_settings;
234
235
236/*-------------------------------------------------------------------------+
237| Function Prototypes.
238+--------------------------------------------------------------------------*/
239
240#if 0
241/*
242 * -------------------- MPC5xx USIU Management Routines -----------------
243 */
244/*
245 * Function to disable a particular irq at USIU level.  After calling
246 * this function, even if the device asserts the interrupt line it will
247 * not be propagated further to the processor
248 */
249int CPU_irq_disable_at_usiu     (const rtems_irq_symbolic_name irqLine);
250/*
251 * Function to enable a particular irq at USIU level.  After calling
252 * this function, if the device asserts the interrupt line it will
253 * be propagated further to the processor
254 */
255int CPU_irq_enable_at_usiu      (const rtems_irq_symbolic_name irqLine);
256/*
257 * Function to acknowledge a particular irq at USIU level.  After calling
258 * this function, if a device asserts an enabled interrupt line it will
259 * be propagated further to the processor. Mainly useful for people
260 * writing raw handlers as this is automagically done for rtems managed
261 * handlers.
262 */
263int CPU_irq_ack_at_siu          (const rtems_irq_symbolic_name irqLine);
264/*
265 * function to check if a particular irq is enabled at USIU level.
266 */
267int CPU_irq_enabled_at_siu      (const rtems_irq_symbolic_name irqLine);
268
269#endif
270
271/*
272 * ------------ RTEMS Single Irq Handler Management Routines ----------------
273 */
274/*
275 * Function to connect a particular irq handler. This handler will NOT be
276 * called directly as the result of the corresponding interrupt. Instead, a
277 * RTEMS irq prologue will be called that will :
278 *
279 *      1) save the C scratch registers,
280 *      2) switch to a interrupt stack if the interrupt is not nested,
281 *      4) modify them to disable the current interrupt at  USIU level (and
282 *         maybe others depending on software priorities)
283 *      5) aknowledge the USIU',
284 *      6) demask the processor,
285 *      7) call the application handler
286 *
287 * As a result the hdl function provided
288 *
289 *      a) can perfectly be written is C,
290 *      b) may also well directly call the part of the RTEMS API that can be
291 *         used from interrupt level,
292 *      c) It only responsible for handling the jobs that need to be done at
293 *         the device level including (aknowledging/re-enabling the
294 *         interrupt at device, level, getting the data,...)
295 *
296 *      When returning from the function, the following will be performed by
297 *      the RTEMS irq epilogue :
298 *
299 *      1) masks the interrupts again,
300 *      2) restore the original USIU interrupt masks
301 *      3) switch back on the orinal stack if needed,
302 *      4) perform rescheduling when necessary,
303 *      5) restore the C scratch registers...
304 *      6) restore initial execution flow
305 *
306 */
307int CPU_install_rtems_irq_handler       (const rtems_irq_connect_data*);
308/*
309 * Function to connect an RTEMS irq handler for ptr->name.
310 */
311int CPU_get_current_rtems_irq_handler   (rtems_irq_connect_data* ptr);
312/*
313 * Function to get the RTEMS irq handler for ptr->name.
314 */
315int CPU_remove_rtems_irq_handler        (const rtems_irq_connect_data*);
316/*
317 * Function to disconnect the RTEMS irq handler for ptr->name.  This
318 * function checks that the value given is the current one for safety
319 * reason.  The user can use the previous function to get it.
320 */
321
322/*
323 * ------------ RTEMS Global Irq Handler Management Routines ----------------
324 */
325/*
326 * (Re) Initialize the RTEMS interrupt management.
327 *
328 * The result of calling this function will be the same as if each
329 * individual handler (config->irqHdlTbl[i].hdl) different from
330 * "config->defaultEntry.hdl" has been individualy connected via
331 *
332 *      CPU_install_rtems_irq_handler(&config->irqHdlTbl[i])
333 *
334 * and each handler currently equal to config->defaultEntry.hdl
335 * has been previously disconnected via
336 *
337 *       CPU_remove_rtems_irq_handler (&config->irqHdlTbl[i])
338 *
339 * This is to say that all information given will be used and not just
340 * only the space.
341 *
342 * CAUTION : the various table address contained in config will be used
343 *           directly by the interrupt mangement code in order to save
344 *           data size so they must stay valid after the call => they should
345 *           not be modified or declared on a stack.
346 */
347
348int CPU_rtems_irq_mngt_set(rtems_irq_global_settings* config);
349/*
350 * (Re) get info on current RTEMS interrupt management.
351 */
352int CPU_rtems_irq_mngt_get(rtems_irq_global_settings**);
353 
354extern void CPU_rtems_irq_mng_init(unsigned cpuId);
355
356#endif
357
358#endif
Note: See TracBrowser for help on using the repository browser.