source: rtems/c/src/lib/libbsp/arm/gba/irq/irq.h @ 3c7ed6b

4.104.114.84.9
Last change on this file since 3c7ed6b was 3c7ed6b, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 6, 2005 at 6:46:04 PM

2005-07-06 Markku Puro <markku.puro@…>

  • .cvsignore, ChangeLog?, Makefile.am, README, bsp_specs, configure.ac, clock/clockdrv.c, console/conio.c, console/console.c, console/defaultfont.c, include/arm_mode_bits.h, include/asm_macros.h, include/bsp.h, include/bspopts.h.in, include/conio.h, include/gba.h, include/gba_registers.h, include/tm27.h, irq/bsp_irq_asm.S, irq/bsp_irq_init.c, irq/irq.c, irq/irq.h, irq/irq_asm.S, irq/irq_init.c, start/logo.S, start/start.S, startup/bspstart.c, startup/cpu.c, startup/cpu_asm.S, startup/exit.c, startup/linkcmds, timer/timer.c: New files.
  • Property mode set to 100644
File size: 6.2 KB
Line 
1/**
2 *  @file 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 *  RTEMS GBA BSP
9 *
10 *  Copyright (c) 2004  Markku Puro <markku.puro@kopteri.net>
11 *
12 *  The license and distribution terms for this file may be
13 *  found in found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#ifndef _IRQ_H_
20#define _IRQ_H_
21
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/*
28 * Include some preprocessor value also used by assember code
29 */
30
31#define VECTOR_TABLE  (&irq_vector_table[0])
32
33#include <stdint.h>
34#include <rtems.h>
35
36extern void default_int_handler();
37
38/*---------------------------------------------------------------------------*
39 *  MACROS                                                                   *
40 *---------------------------------------------------------------------------*/
41
42#define ENABLE_IRQ()   GBA_REG_IME = 1;
43#define DISABLE_IRQ()  GBA_REG_IME = 0;
44
45
46/*-------------------------------------------------------------------------+
47| Constants
48+--------------------------------------------------------------------------*/
49
50typedef enum {
51  BSP_IRQ_VBLANK    = 0,
52  BSP_IRQ_HBLANK    = 1,
53  BSP_IRQ_VCOUNTER  = 2,
54  BSP_IRQ_TIMER0    = 3,
55  BSP_IRQ_TIMER1    = 4,
56  BSP_IRQ_TIMER2    = 5,
57  BSP_IRQ_TIMER3    = 6,
58  BSP_IRQ_SERIAL    = 7,
59  BSP_IRQ_DMA0      = 8,
60  BSP_IRQ_DMA1      = 9,
61  BSP_IRQ_DMA2      = 10,
62  BSP_IRQ_DMA3      = 11,
63  BSP_IRQ_KEY       = 12,
64  BSP_IRQ_CART      = 13,
65  BSP_IRQ_NA14      = 14,
66  BSP_IRQ_NA15      = 15,
67  BSP_MAX_INT       = 16  /**< BSP_MAX_INT <= _irq_max_vector in linkcmds */
68} rtems_irq_symbolic_name;
69
70/*
71 * Type definition for RTEMS managed interrupts
72 */
73typedef unsigned char  rtems_irq_level;
74typedef unsigned char  rtems_irq_trigger;
75
76extern void        _irq_max_vector;               /**< defined in lincmds    */
77extern uint32_t    irq_vector_table[BSP_MAX_INT]; /**< allocated in linkcmds */
78
79
80struct  __rtems_irq_connect_data__;     /* forward declaratiuon */
81
82typedef void (*rtems_irq_hdl)           (void);
83typedef void (*rtems_irq_enable)        (const struct __rtems_irq_connect_data__*);
84typedef void (*rtems_irq_disable)       (const struct __rtems_irq_connect_data__*);
85typedef int  (*rtems_irq_is_enabled)    (const struct __rtems_irq_connect_data__*);
86
87/** irq connection data structure */
88typedef struct __rtems_irq_connect_data__ {
89  /**
90   * IRQ line
91   */
92  rtems_irq_symbolic_name       name;
93  /**
94   * handler. See comment on handler properties below in function prototype.
95   */
96  rtems_irq_hdl                 hdl;
97  /**
98   * function for enabling interrupts at device level (ONLY!).
99   * The BSP code will automatically enable it at PIC level.
100   * RATIONALE : anyway such code has to exist in current driver code.
101   * It is usually called immediately AFTER connecting the interrupt handler.
102   * RTEMS may well need such a function when restoring normal interrupt
103   * processing after a debug session.
104   *
105   */
106    rtems_irq_enable            on;
107  /**
108   * function for disabling interrupts at device level (ONLY!).
109   * The code will disable it at PIC level. RATIONALE : anyway
110   * such code has to exist for clean shutdown. It is usually called
111   * BEFORE disconnecting the interrupt. RTEMS may well need such
112   * a function when disabling normal interrupt processing for
113   * a debug session. May well be a NOP function.
114   */
115  rtems_irq_disable             off;
116  /**
117   * function enabling to know what interrupt may currently occur
118   * if someone manipulates the PIC interrupt mask without care...
119   */
120    rtems_irq_is_enabled        isOn;
121  /**
122   * irq priority level
123   */
124  rtems_irq_level               irqLevel;
125  /**
126   * Trigger way : Rising or falling edge or High or low level
127   */
128  rtems_irq_trigger             irqTrigger;
129} rtems_irq_connect_data;
130
131/*-------------------------------------------------------------------------+
132| Function Prototypes.
133+--------------------------------------------------------------------------*/
134/*
135 * ------------------------ RTEMS Single Irq Handler Mngt Routines ----------------
136 */
137
138/**
139 * @brief function to initialize the interrupt for a specific BSP
140 */
141void BSP_rtems_irq_mngt_init();
142
143
144/**
145 * @brief function to connect a particular irq handler.
146 * This hanlder will NOT be called directly as the result of the corresponding interrupt.
147 * Instead, a RTEMS irq prologue will be called that will :
148 *      1) save the C scratch registers,
149 *      2) switch to a interrupt stack if the interrupt is not nested,
150 *      3) store the current i8259s' interrupt masks
151 *      4) modify them to disable the current interrupt at 8259 level (and may
152 *      be others depending on software priorities)
153 *      5) aknowledge the i8259s',
154 *      6) demask the processor,
155 *      7) call the application handler
156 *
157 * As a result the hdl function provided
158 *      a) can perfectly be written is C,
159 *      b) may also well directly call the part of the RTEMS API that can be used
160 *      from interrupt level,
161 *      c) It only responsible for handling the jobs that need to be done at
162 *      the device level including (aknowledging/re-enabling the interrupt at device,
163 *      level, getting the data,...)
164 *
165 *      When returning from the function, the following will be performed by
166 *      the RTEMS irq epilogue :
167 *
168 *      1) masks the interrupts again,
169 *      2) restore the original i8259s' interrupt masks
170 *      3) switch back on the orinal stack if needed,
171 *      4) perform rescheduling when necessary,
172 *      5) restore the C scratch registers...
173 *      6) restore initial execution flow
174 *
175 */
176int BSP_install_rtems_irq_handler       (const rtems_irq_connect_data*);
177
178/**
179 * function to get the current RTEMS irq handler for ptr->name. It enables to
180 * define hanlder chain...
181 */
182int BSP_get_current_rtems_irq_handler   (rtems_irq_connect_data* ptr);
183
184/**
185 * @brief function to get disconnect the RTEMS irq handler for ptr->name.
186 * This function checks that the value given is the current one for safety reason.
187 * The user can use the previous function to get it.
188 */
189int BSP_remove_rtems_irq_handler        (const rtems_irq_connect_data*);
190
191
192#ifdef __cplusplus
193}
194#endif
195
196#endif /* _IRQ_H_ */
Note: See TracBrowser for help on using the repository browser.