OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [i386/] [shared/] [irq/] [irq.h] - Blame information for rev 493

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/* 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) 1998 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.OARcorp.com/rtems/license.html.
17
 *
18
 *  $Id: irq.h,v 1.2 2001-09-27 11:59:49 chris Exp $
19
 */
20
 
21
#ifndef _IRQ_H_
22
#define _IRQ_H_
23
 
24
#ifdef __cplusplus
25
extern "C" {
26
#endif
27
 
28
/*
29
 * Include some preprocessor value also used by assember code
30
 */
31
 
32
#include <irq_asm.h>
33
#include <rtems.h>
34
/*-------------------------------------------------------------------------+
35
| Constants
36
+--------------------------------------------------------------------------*/
37
 
38
typedef enum {
39
    /* Base vector for our IRQ handlers. */
40
  BSP_IRQ_VECTOR_BASE           =       BSP_ASM_IRQ_VECTOR_BASE,
41
  BSP_IRQ_LINES_NUMBER          =       16,
42
  BSP_LOWEST_OFFSET             =       0,
43
  BSP_MAX_OFFSET                =       BSP_IRQ_LINES_NUMBER - 1,
44
    /*
45
     * Interrupt offset in comparison to BSP_ASM_IRQ_VECTOR_BASE
46
     * NB : 1) Interrupt vector number in IDT = offset + BSP_ASM_IRQ_VECTOR_BASE
47
     *      2) The same name should be defined on all architecture
48
     *         so that handler connexion can be unchanged.
49
     */
50
  BSP_PERIODIC_TIMER            =       0,
51
 
52
  BSP_KEYBOARD                  =       1,
53
 
54
  BSP_UART_COM2_IRQ             =       3,
55
 
56
  BSP_UART_COM1_IRQ             =       4,
57
 
58
  BSP_RT_TIMER1         =       8,
59
 
60
  BSP_RT_TIMER3         =       10
61
} rtems_irq_symbolic_name;
62
 
63
 
64
 
65
 
66
/*
67
 * Type definition for RTEMS managed interrupts
68
 */
69
typedef unsigned char  rtems_irq_prio;
70
typedef unsigned short rtems_i8259_masks;
71
 
72
extern  rtems_i8259_masks i8259s_cache;
73
 
74
struct  __rtems_irq_connect_data__;     /* forward declaratiuon */
75
 
76
typedef void (*rtems_irq_hdl)           (void);
77
typedef void (*rtems_irq_enable)        (const struct __rtems_irq_connect_data__*);
78
typedef void (*rtems_irq_disable)       (const struct __rtems_irq_connect_data__*);
79
typedef int  (*rtems_irq_is_enabled)    (const struct __rtems_irq_connect_data__*);
80
 
81
typedef struct __rtems_irq_connect_data__ {
82
  /*
83
   * IRQ line
84
   */
85
  rtems_irq_symbolic_name       name;
86
  /*
87
   * handler. See comment on handler properties below in function prototype.
88
   */
89
  rtems_irq_hdl                 hdl;
90
  /*
91
   * function for enabling interrupts at device level (ONLY!).
92
   * The BSP code will automatically enable it at i8259s level.
93
   * RATIONALE : anyway such code has to exist in current driver code.
94
   * It is usually called immediately AFTER connecting the interrupt handler.
95
   * RTEMS may well need such a function when restoring normal interrupt
96
   * processing after a debug session.
97
   *
98
   */
99
    rtems_irq_enable            on;
100
  /*
101
   * function for disabling interrupts at device level (ONLY!).
102
   * The code will disable it at i8259s level. RATIONALE : anyway
103
   * such code has to exist for clean shutdown. It is usually called
104
   * BEFORE disconnecting the interrupt. RTEMS may well need such
105
   * a function when disabling normal interrupt processing for
106
   * a debug session. May well be a NOP function.
107
   */
108
  rtems_irq_disable             off;
109
  /*
110
   * function enabling to know what interrupt may currently occur
111
   * if someone manipulates the i8259s interrupt mask without care...
112
   */
113
    rtems_irq_is_enabled        isOn;
114
} rtems_irq_connect_data;
115
 
116
typedef struct {
117
  /*
118
   * size of all the table fields (*Tbl) described below.
119
   */
120
  unsigned int                  irqNb;
121
  /*
122
   * Default handler used when disconnecting interrupts.
123
   */
124
  rtems_irq_connect_data        defaultEntry;
125
  /*
126
   * Table containing initials/current value.
127
   */
128
  rtems_irq_connect_data*       irqHdlTbl;
129
  /*
130
   * actual value of BSP_IRQ_VECTOR_BASE...
131
   */
132
  rtems_irq_symbolic_name       irqBase;
133
  /*
134
   * software priorities associated with interrupts.
135
   * if irqPrio  [i]  >  intrPrio  [j]  it  means  that
136
   * interrupt handler hdl connected for interrupt name i
137
   * will  not be interrupted by the handler connected for interrupt j
138
   * The interrupt source  will be physically masked at i8259 level.
139
   */
140
    rtems_irq_prio*             irqPrioTbl;
141
}rtems_irq_global_settings;
142
 
143
 
144
 
145
 
146
/*-------------------------------------------------------------------------+
147
| Function Prototypes.
148
+--------------------------------------------------------------------------*/
149
/*
150
 * ------------------------ Intel 8259 (or emulation) Mngt Routines -------
151
 */
152
 
153
/*
154
 * function to disable a particular irq at 8259 level. After calling
155
 * this function, even if the device asserts the interrupt line it will
156
 * not be propagated further to the processor
157
 */
158
int BSP_irq_disable_at_i8259s        (const rtems_irq_symbolic_name irqLine);
159
/*
160
 * function to enable a particular irq at 8259 level. After calling
161
 * this function, if the device asserts the interrupt line it will
162
 * be propagated further to the processor
163
 */
164
int BSP_irq_enable_at_i8259s            (const rtems_irq_symbolic_name irqLine);
165
/*
166
 * function to acknoledge a particular irq at 8259 level. After calling
167
 * this function, if a device asserts an enabled interrupt line it will
168
 * be propagated further to the processor. Mainly usefull for people
169
 * writting raw handlers as this is automagically done for rtems managed
170
 * handlers.
171
 */
172
int BSP_irq_ack_at_i8259s               (const rtems_irq_symbolic_name irqLine);
173
/*
174
 * function to check if a particular irq is enabled at 8259 level. After calling
175
 */
176
int BSP_irq_enabled_at_i8259s           (const rtems_irq_symbolic_name irqLine);
177
/*
178
 * ------------------------ RTEMS Single Irq Handler Mngt Routines ----------------
179
 */
180
/*
181
 * function to connect a particular irq handler. This hanlder will NOT be called
182
 * directly as the result of the corresponding interrupt. Instead, a RTEMS
183
 * irq prologue will be called that will :
184
 *
185
 *      1) save the C scratch registers,
186
 *      2) switch to a interrupt stack if the interrupt is not nested,
187
 *      3) store the current i8259s' interrupt masks
188
 *      4) modify them to disable the current interrupt at 8259 level (and may
189
 *      be others depending on software priorities)
190
 *      5) aknowledge the i8259s',
191
 *      6) demask the processor,
192
 *      7) call the application handler
193
 *
194
 * As a result the hdl function provided
195
 *
196
 *      a) can perfectly be written is C,
197
 *      b) may also well directly call the part of the RTEMS API that can be used
198
 *      from interrupt level,
199
 *      c) It only responsible for handling the jobs that need to be done at
200
 *      the device level including (aknowledging/re-enabling the interrupt at device,
201
 *      level, getting the data,...)
202
 *
203
 *      When returning from the function, the following will be performed by
204
 *      the RTEMS irq epilogue :
205
 *
206
 *      1) masks the interrupts again,
207
 *      2) restore the original i8259s' interrupt masks
208
 *      3) switch back on the orinal stack if needed,
209
 *      4) perform rescheduling when necessary,
210
 *      5) restore the C scratch registers...
211
 *      6) restore initial execution flow
212
 *
213
 */
214
int BSP_install_rtems_irq_handler       (const rtems_irq_connect_data*);
215
/*
216
 * function to get the current RTEMS irq handler for ptr->name. It enables to
217
 * define hanlder chain...
218
 */
219
int BSP_get_current_rtems_irq_handler   (rtems_irq_connect_data* ptr);
220
/*
221
 * function to get disconnect the RTEMS irq handler for ptr->name.
222
 * This function checks that the value given is the current one for safety reason.
223
 * The user can use the previous function to get it.
224
 */
225
int BSP_remove_rtems_irq_handler        (const rtems_irq_connect_data*);
226
 
227
/*
228
 * ------------------------ RTEMS Global Irq Handler Mngt Routines ----------------
229
 */
230
/*
231
 * (Re) Initialize the RTEMS interrupt management.
232
 *
233
 * The result of calling this function will be the same as if each individual
234
 * handler (config->irqHdlTbl[i].hdl)  different from "config->defaultEntry.hdl"
235
 * has been individualy connected via
236
 *      BSP_install_rtems_irq_handler(&config->irqHdlTbl[i])
237
 * And each handler currently equal to config->defaultEntry.hdl
238
 * has been previously disconnected via
239
 *       BSP_remove_rtems_irq_handler (&config->irqHdlTbl[i])
240
 *
241
 * This is to say that all information given will be used and not just
242
 * only the space.
243
 *
244
 * CAUTION : the various table address contained in config will be used
245
 *           directly by the interrupt mangement code in order to save
246
 *           data size so they must stay valid after the call => they should
247
 *           not be modified or declared on a stack.
248
 */
249
 
250
int BSP_rtems_irq_mngt_set(rtems_irq_global_settings* config);
251
/*
252
 * (Re) get info on current RTEMS interrupt management.
253
 */
254
int BSP_rtems_irq_mngt_get(rtems_irq_global_settings**);
255
 
256
#ifdef __cplusplus
257
}
258
#endif
259
 
260
#endif /* _IRQ_H_ */
261
/* end of include file */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.