source: rtems/c/src/lib/libbsp/powerpc/shared/irq/irq.h @ c1e7b3f

4.104.114.84.95
Last change on this file since c1e7b3f was e79a1947, checked in by Joel Sherrill <joel.sherrill@…>, on 11/10/04 at 23:51:17

2004-11-10 Richard Campbell <richard.campbell@…>

  • Makefile.am, bootloader/misc.c, bootloader/pci.c, bootloader/pci.h, console/console.c, console/inch.c, console/reboot.c, console/uart.c, console/uart.h, irq/irq.c, irq/irq.h, irq/irq_init.c, motorola/motorola.c, motorola/motorola.h, openpic/openpic.c, openpic/openpic.h, pci/detect_raven_bridge.c, pci/pci.c, start/start.S, startup/bspstart.c, vectors/vectors_init.c, vme/vmeconfig.c: Add MVME2100 BSP and MPC8240 support. There was also a significant amount of spelling and whitespace cleanup.
  • tod/todcfg.c: New file.
  • Property mode set to 100644
File size: 12.1 KB
Line 
1/* irq.h
2 *
3 *  This include file describe the data structure and the functions implemented
4 *  by RTEMS to write interrupt handlers.
5 *
6 *  Copyright (C) 1999 valette@crf.canon.fr
7 *
8 *  This code is heavilly inspired by the public specification of STREAM V2
9 *  that can be found at :
10 *
11 *      <http://www.chorus.com/Documentation/index.html> by following
12 *  the STREAM API Specification Document link.
13 *
14 *  The license and distribution terms for this file may be
15 *  found in found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21#ifndef LIBBSP_POWERPC_MCP750_IRQ_IRQ_H
22#define LIBBSP_POWERPC_MCP750_IRQ_IRQ_H
23
24/*
25 * 8259 edge/level control definitions at VIA
26 */
27#define ISA8259_M_ELCR          0x4d0
28#define ISA8259_S_ELCR          0x4d1
29
30#define ELCRS_INT15_LVL         0x80
31#define ELCRS_INT14_LVL         0x40
32#define ELCRS_INT13_LVL         0x20
33#define ELCRS_INT12_LVL         0x10
34#define ELCRS_INT11_LVL         0x08
35#define ELCRS_INT10_LVL         0x04
36#define ELCRS_INT9_LVL          0x02
37#define ELCRS_INT8_LVL          0x01
38#define ELCRM_INT7_LVL          0x80
39#define ELCRM_INT6_LVL          0x40
40#define ELCRM_INT5_LVL          0x20
41#define ELCRM_INT4_LVL          0x10
42#define ELCRM_INT3_LVL          0x8
43#define ELCRM_INT2_LVL          0x4
44#define ELCRM_INT1_LVL          0x2
45#define ELCRM_INT0_LVL          0x1
46
47#define BSP_ASM_IRQ_VECTOR_BASE 0x0
48    /* PIC's command and mask registers */
49#define PIC_MASTER_COMMAND_IO_PORT              0x20    /* Master PIC command register */
50#define PIC_SLAVE_COMMAND_IO_PORT               0xa0    /* Slave PIC command register */
51#define PIC_MASTER_IMR_IO_PORT                  0x21    /* Master PIC Interrupt Mask Register */
52#define PIC_SLAVE_IMR_IO_PORT                   0xa1    /* Slave PIC Interrupt Mask Register */
53
54    /* Command for specific EOI (End Of Interrupt): Interrupt acknowledge */
55#define PIC_EOSI        0x60    /* End of Specific Interrupt (EOSI) */
56#define SLAVE_PIC_EOSI  0x62    /* End of Specific Interrupt (EOSI) for cascade */
57#define PIC_EOI         0x20    /* Generic End of Interrupt (EOI) */
58
59#ifndef ASM
60
61#ifdef __cplusplus
62extern "C" {
63#endif
64
65/*
66 * Symbolic IRQ names and related definitions
67 */
68
69typedef enum {
70  /* Base vector for our ISA IRQ handlers. */
71  BSP_ISA_IRQ_VECTOR_BASE       = BSP_ASM_IRQ_VECTOR_BASE,
72  /*
73   * ISA IRQ handler related definitions
74   */
75  BSP_ISA_IRQ_NUMBER            = 16,
76  BSP_ISA_IRQ_LOWEST_OFFSET     = 0,
77  BSP_ISA_IRQ_MAX_OFFSET        = BSP_ISA_IRQ_LOWEST_OFFSET + BSP_ISA_IRQ_NUMBER - 1,
78  /*
79   * PCI IRQ handlers related definitions
80   * CAUTION : BSP_PCI_IRQ_LOWEST_OFFSET should be equal to OPENPIC_VEC_SOURCE
81   */
82  BSP_PCI_IRQ_NUMBER            = 16,
83  BSP_PCI_IRQ_LOWEST_OFFSET     = BSP_ISA_IRQ_NUMBER,
84  BSP_PCI_IRQ_MAX_OFFSET        = BSP_PCI_IRQ_LOWEST_OFFSET + BSP_PCI_IRQ_NUMBER - 1,
85  /*
86   * PowerPC exceptions handled as interrupt where an RTEMS managed interrupt
87   * handler might be connected
88   */
89  BSP_PROCESSOR_IRQ_NUMBER      = 1,
90  BSP_PROCESSOR_IRQ_LOWEST_OFFSET = BSP_PCI_IRQ_MAX_OFFSET + 1,
91  BSP_PROCESSOR_IRQ_MAX_OFFSET  = BSP_PROCESSOR_IRQ_LOWEST_OFFSET + BSP_PROCESSOR_IRQ_NUMBER - 1,
92  /* Misc vectors for OPENPIC irqs (IPI, timers)
93   */
94  BSP_MISC_IRQ_NUMBER           = 8,
95  BSP_MISC_IRQ_LOWEST_OFFSET    = BSP_PROCESSOR_IRQ_MAX_OFFSET + 1,
96  BSP_MISC_IRQ_MAX_OFFSET       = BSP_MISC_IRQ_LOWEST_OFFSET + BSP_MISC_IRQ_NUMBER - 1,
97  /*
98   * Summary
99   */
100  BSP_IRQ_NUMBER                = BSP_MISC_IRQ_MAX_OFFSET + 1,
101  BSP_LOWEST_OFFSET             = BSP_ISA_IRQ_LOWEST_OFFSET,
102  BSP_MAX_OFFSET                = BSP_MISC_IRQ_MAX_OFFSET,
103    /*
104     * Some ISA IRQ symbolic name definition
105     */
106  BSP_ISA_PERIODIC_TIMER        = 0,
107  BSP_ISA_KEYBOARD              = 1,
108  BSP_ISA_UART_COM2_IRQ         = 3,
109  BSP_ISA_UART_COM1_IRQ         = 4,
110  BSP_ISA_RT_TIMER1             = 8,
111  BSP_ISA_RT_TIMER3             = 10,
112    /*
113     * Some PCI IRQ symbolic name definition
114     */
115  BSP_PCI_IRQ0                  = BSP_PCI_IRQ_LOWEST_OFFSET,
116  BSP_PCI_ISA_BRIDGE_IRQ        = BSP_PCI_IRQ0,
117
118#if defined(mvme2100)
119  BSP_DEC21143_IRQ                = BSP_PCI_IRQ_LOWEST_OFFSET + 1,
120  BSP_PMC_PCMIP_TYPE1_SLOT0_IRQ   = BSP_PCI_IRQ_LOWEST_OFFSET + 2,
121  BSP_PCMIP_TYPE1_SLOT1_IRQ       = BSP_PCI_IRQ_LOWEST_OFFSET + 3,
122  BSP_PCMIP_TYPE2_SLOT0_IRQ       = BSP_PCI_IRQ_LOWEST_OFFSET + 4,
123  BSP_PCMIP_TYPE2_SLOT1_IRQ       = BSP_PCI_IRQ_LOWEST_OFFSET + 5,
124  BSP_PCI_INTA_UNIVERSE_LINT0_IRQ = BSP_PCI_IRQ_LOWEST_OFFSET + 7,
125  BSP_PCI_INTB_UNIVERSE_LINT1_IRQ = BSP_PCI_IRQ_LOWEST_OFFSET + 8,
126  BSP_PCI_INTC_UNIVERSE_LINT2_IRQ = BSP_PCI_IRQ_LOWEST_OFFSET + 9,
127  BSP_PCI_INTD_UNIVERSE_LINT3_IRQ = BSP_PCI_IRQ_LOWEST_OFFSET + 10,
128  BSP_UART_COM1_IRQ               = BSP_PCI_IRQ_LOWEST_OFFSET + 13,
129  BSP_FRONT_PANEL_ABORT_IRQ       = BSP_PCI_IRQ_LOWEST_OFFSET + 14,
130  BSP_RTC_IRQ                     = BSP_PCI_IRQ_LOWEST_OFFSET + 15,
131#endif
132
133    /*
134     * Some Processor execption handled as RTEMS IRQ symbolic name definition
135     */
136  BSP_DECREMENTER               = BSP_PROCESSOR_IRQ_LOWEST_OFFSET
137
138} rtems_irq_symbolic_name;
139
140/*
141 * Type definition for RTEMS managed interrupts
142 */
143typedef unsigned char  rtems_irq_prio;
144typedef unsigned short rtems_i8259_masks;
145
146extern  volatile rtems_i8259_masks i8259s_cache;
147
148struct  __rtems_irq_connect_data__;     /* forward declaratiuon */
149
150typedef void (*rtems_irq_hdl)           (void);
151typedef void (*rtems_irq_enable)        (const struct __rtems_irq_connect_data__*);
152typedef void (*rtems_irq_disable)       (const struct __rtems_irq_connect_data__*);
153typedef int  (*rtems_irq_is_enabled)    (const struct __rtems_irq_connect_data__*);
154
155typedef struct __rtems_irq_connect_data__ {
156      /*
157       * IRQ line
158       */
159      rtems_irq_symbolic_name   name;
160      /*
161       * handler. See comment on handler properties below in function prototype.
162       */
163      rtems_irq_hdl                     hdl;
164      /*
165       * function for enabling interrupts at device level (ONLY!).
166       * The BSP code will automatically enable it at i8259s level and openpic level.
167       * RATIONALE : anyway such code has to exist in current driver code.
168       * It is usually called immediately AFTER connecting the interrupt handler.
169       * RTEMS may well need such a function when restoring normal interrupt
170       * processing after a debug session.
171       *
172       */
173      rtems_irq_enable          on;
174      /*
175       * function for disabling interrupts at device level (ONLY!).
176       * The code will disable it at i8259s level. RATIONALE : anyway
177       * such code has to exist for clean shutdown. It is usually called
178       * BEFORE disconnecting the interrupt. RTEMS may well need such
179       * a function when disabling normal interrupt processing for
180       * a debug session. May well be a NOP function.
181       */
182      rtems_irq_disable         off;
183      /*
184       * function enabling to know what interrupt may currently occur
185       * if someone manipulates the i8259s interrupt mask without care...
186       */
187      rtems_irq_is_enabled      isOn;
188      /*
189       *  Set to -1 for vectors forced to have only 1 handler
190       */
191      void *next_handler;
192
193}rtems_irq_connect_data;
194
195typedef struct {
196  /*
197   * size of all the table fields (*Tbl) described below.
198   */
199  unsigned int                  irqNb;
200  /*
201   * Default handler used when disconnecting interrupts.
202   */
203  rtems_irq_connect_data        defaultEntry;
204  /*
205   * Table containing initials/current value.
206   */
207  rtems_irq_connect_data*       irqHdlTbl;
208  /*
209   * actual value of BSP_ISA_IRQ_VECTOR_BASE...
210   */
211  rtems_irq_symbolic_name       irqBase;
212  /*
213   * software priorities associated with interrupts.
214   * if (*irqPrio  [i]  >  intrPrio  [j]  it  means  that
215   * interrupt handler hdl connected for interrupt name i
216   * will  not be interrupted by the handler connected for interrupt j
217   * The interrupt source  will be physically masked at i8259 level.
218   */
219    rtems_irq_prio*             irqPrioTbl;
220}rtems_irq_global_settings;
221
222/*-------------------------------------------------------------------------+
223| Function Prototypes.
224+--------------------------------------------------------------------------*/
225/*
226 * ------------------------ Intel 8259 (or emulation) Mngt Routines -------
227 */
228
229/*
230 * function to disable a particular irq at 8259 level. After calling
231 * this function, even if the device asserts the interrupt line it will
232 * not be propagated further to the processor
233 */
234int BSP_irq_disable_at_i8259s        (const rtems_irq_symbolic_name irqLine);
235/*
236 * function to enable a particular irq at 8259 level. After calling
237 * this function, if the device asserts the interrupt line it will
238 * be propagated further to the processor
239 */
240int BSP_irq_enable_at_i8259s            (const rtems_irq_symbolic_name irqLine);
241/*
242 * function to acknowledge a particular irq at 8259 level. After calling
243 * this function, if a device asserts an enabled interrupt line it will
244 * be propagated further to the processor. Mainly usefull for people
245 * writing raw handlers as this is automagically done for RTEMS managed
246 * handlers.
247 */
248int BSP_irq_ack_at_i8259s               (const rtems_irq_symbolic_name irqLine);
249/*
250 * function to check if a particular irq is enabled at 8259 level. After calling
251 */
252int BSP_irq_enabled_at_i8259s           (const rtems_irq_symbolic_name irqLine);
253/*
254 * ------------------------ RTEMS Single Irq Handler Mngt Routines ----------------
255 */
256/*
257 * function to connect a particular irq handler. This hanlder will NOT be called
258 * directly as the result of the corresponding interrupt. Instead, a RTEMS
259 * irq prologue will be called that will :
260 *
261 *      1) save the C scratch registers,
262 *      2) switch to a interrupt stack if the interrupt is not nested,
263 *      3) store the current i8259s' interrupt masks
264 *      4) modify them to disable the current interrupt at 8259 level (and may
265 *      be others depending on software priorities)
266 *      5) acknowledge the i8259s',
267 *      6) demask the processor,
268 *      7) call the application handler
269 *
270 * As a result the hdl function provided
271 *
272 *      a) can perfectly be written is C,
273 *      b) may also well directly call the part of the RTEMS API that can be
274 *      used from interrupt level,
275 *      c) It only responsible for handling the jobs that need to be done at
276 *      the device level including (aknowledging/re-enabling the interrupt
277 *      at device, level, getting the data,...)
278 *
279 *      When returning from the function, the following will be performed by
280 *      the RTEMS irq epilogue:
281 *
282 *      1) masks the interrupts again,
283 *      2) restore the original i8259s' interrupt masks
284 *      3) switch back on the orinal stack if needed,
285 *      4) perform rescheduling when necessary,
286 *      5) restore the C scratch registers...
287 *      6) restore initial execution flow
288 */
289int BSP_install_rtems_irq_handler       (const rtems_irq_connect_data*);
290int BSP_install_rtems_shared_irq_handler  (const rtems_irq_connect_data*);
291
292#define BSP_SHARED_HANDLER_SUPPORT      1
293
294/*
295 * function to get the current RTEMS irq handler for ptr->name. It enables to
296 * define hanlder chain...
297 */
298int BSP_get_current_rtems_irq_handler   (rtems_irq_connect_data* ptr);
299/*
300 * function to get disconnect the RTEMS irq handler for ptr->name.
301 * This function checks that the value given is the current one for safety
302 * reasons.
303 * The user can use the previous function to get it.
304 */
305int BSP_remove_rtems_irq_handler        (const rtems_irq_connect_data*);
306
307/*
308 * ------------------------ RTEMS Global Irq Handler Mngt Routines ----------------
309 */
310/*
311 * (Re) Initialize the RTEMS interrupt management.
312 *
313 * The result of calling this function will be the same as if each individual
314 * handler (config->irqHdlTbl[i].hdl)  different from "config->defaultEntry.hdl"
315 * has been individualy connected via
316 *      BSP_install_rtems_irq_handler(&config->irqHdlTbl[i])
317 * And each handler currently equal to config->defaultEntry.hdl
318 * has been previously disconnected via
319 *       BSP_remove_rtems_irq_handler (&config->irqHdlTbl[i])
320 *
321 * This is to say that all information given will be used and not just
322 * only the space.
323 *
324 * CAUTION : the various table address contained in config will be used
325 *           directly by the interrupt mangement code in order to save
326 *           data size so they must stay valid after the call => they should
327 *           not be modified or declared on a stack.
328 */
329
330int BSP_rtems_irq_mngt_set(rtems_irq_global_settings* config);
331/*
332 * (Re) get info on current RTEMS interrupt management.
333 */
334int BSP_rtems_irq_mngt_get(rtems_irq_global_settings**);
335
336extern void BSP_rtems_irq_mng_init(unsigned cpuId);
337extern void BSP_i8259s_init(void);
338
339#ifdef __cplusplus
340}
341#endif
342
343#endif
344
345#endif
Note: See TracBrowser for help on using the repository browser.