RTEMS 7.0-rc1
Loading...
Searching...
No Matches
irq.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
17/*
18 * Copyright (c) 1998 Eric Valette <eric.valette@free.fr>
19 *
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
22 * are met:
23 * 1. Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
33 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
40 */
41
42#ifndef _RTEMS_IRQ_H
43#define _RTEMS_IRQ_H
44
45#ifndef ASM
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51
52/*
53 * Type definition for RTEMS managed interrupts
54 */
55typedef unsigned char rtems_irq_prio;
56struct __rtems_irq_connect_data__; /* forward declaratiuon */
57
58typedef unsigned int rtems_irq_number;
59typedef void *rtems_irq_hdl_param;
60typedef void (*rtems_irq_hdl) (rtems_irq_hdl_param);
61typedef void (*rtems_irq_enable) (const struct __rtems_irq_connect_data__*);
62typedef void (*rtems_irq_disable) (const struct __rtems_irq_connect_data__*);
63typedef int (*rtems_irq_is_enabled) (const struct __rtems_irq_connect_data__*);
64
66 /*
67 * IRQ line
68 */
69 rtems_irq_number name;
70 /*
71 * handler. See comment on handler properties below in function prototype.
72 */
73 rtems_irq_hdl hdl;
74 /*
75 * Handler handle to store private data
76 */
77 rtems_irq_hdl_param handle;
78 /*
79 * function for enabling interrupts at device level (ONLY!).
80 * The BSP code will automatically enable it at i8259s level.
81 * RATIONALE : anyway such code has to exist in current driver code.
82 * It is usually called immediately AFTER connecting the interrupt handler.
83 * RTEMS may well need such a function when restoring normal interrupt
84 * processing after a debug session.
85 *
86 */
87 rtems_irq_enable on;
88 /*
89 * function for disabling interrupts at device level (ONLY!).
90 * The code will disable it at i8259s level. RATIONALE : anyway
91 * such code has to exist for clean shutdown. It is usually called
92 * BEFORE disconnecting the interrupt. RTEMS may well need such
93 * a function when disabling normal interrupt processing for
94 * a debug session. May well be a NOP function.
95 */
96 rtems_irq_disable off;
97 /*
98 * function enabling to know what interrupt may currently occur
99 * if someone manipulates the i8259s interrupt mask without care...
100 */
101 rtems_irq_is_enabled isOn;
102
103#ifdef BSP_SHARED_HANDLER_SUPPORT
104 /*
105 * Set to -1 for vectors forced to have only 1 handler
106 */
107 void *next_handler;
108#endif
109
111
112typedef struct {
113 /*
114 * size of all the table fields (*Tbl) described below.
115 */
116 unsigned int irqNb;
117 /*
118 * Default handler used when disconnecting interrupts.
119 */
120 rtems_irq_connect_data defaultEntry;
121 /*
122 * Table containing initials/current value.
123 */
124 rtems_irq_connect_data* irqHdlTbl;
125 /*
126 * actual value of BSP_ISA_IRQ_VECTOR_BASE...
127 */
128 rtems_irq_number irqBase;
129 /*
130 * software priorities associated with interrupts.
131 * if (*irqPrio [i] > intrPrio [j] it means that
132 * interrupt handler hdl connected for interrupt name i
133 * will not be interrupted by the handler connected for interrupt j
134 * The interrupt source will be physically masked at i8259 level.
135 */
136 rtems_irq_prio* irqPrioTbl;
138
139/*-------------------------------------------------------------------------+
140| Function Prototypes.
141+--------------------------------------------------------------------------*/
142/*
143 * -------------------- RTEMS Single Irq Handler Mngt Routines ----------------
144 */
145/*
146 * function to connect a particular irq handler. This hanlder will NOT be called
147 * directly as the result of the corresponding interrupt. Instead, a RTEMS
148 * irq prologue will be called that will :
149 *
150 * 1) save the C scratch registers,
151 * 2) switch to a interrupt stack if the interrupt is not nested,
152 * 3) store the current i8259s' interrupt masks
153 * 4) modify them to disable the current interrupt at 8259 level (and may
154 * be others depending on software priorities)
155 * 5) aknowledge the i8259s',
156 * 6) demask the processor,
157 * 7) call the application handler
158 *
159 * As a result the hdl function provided
160 *
161 * a) can perfectly be written is C,
162 * b) may also well directly call the part of the RTEMS API that can be
163 * used from interrupt level,
164 * c) It only responsible for handling the jobs that need to be done at
165 * the device level including (aknowledging/re-enabling the interrupt at
166 * device level, getting the data,...)
167 *
168 * When returning from the function, the following will be performed by
169 * the RTEMS irq epilogue :
170 *
171 * 1) masks the interrupts again,
172 * 2) restore the original i8259s' interrupt masks
173 * 3) switch back on the orinal stack if needed,
174 * 4) perform rescheduling when necessary,
175 * 5) restore the C scratch registers...
176 * 6) restore initial execution flow
177 *
178 */
179int BSP_install_rtems_irq_handler (const rtems_irq_connect_data*);
180/*
181 * function to get the current RTEMS irq handler for ptr->name. It enables to
182 * define hanlder chain...
183 */
184int BSP_get_current_rtems_irq_handler (rtems_irq_connect_data* ptr);
185/*
186 * function to get disconnect the RTEMS irq handler for ptr->name.
187 * This function checks that the value given is the current one for safety reason.
188 * The user can use the previous function to get it.
189 */
190int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data*);
191
192
193/*
194 * ----------------- RTEMS Shared Irq Handler Mngt Routines ----------------
195 */
196#ifdef BSP_SHARED_HANDLER_SUPPORT
197int BSP_install_rtems_shared_irq_handler (const rtems_irq_connect_data*);
198#endif
199
200/*
201 * Less cumbersome, alternate entry points;
202 * RETURNS: more traditional, 0 on success, nonzero on error
203 *
204 * The BSP_rtems_int_connect() and BSP_rtems_int_disconnect() functions are
205 * only present on some PowerPC BSPs. Do not use them. Use
206 * rtems_interrupt_handler_install() instead.
207 */
208
209int BSP_rtems_int_connect(
210 rtems_irq_number n,
211 rtems_irq_hdl hdl,
212 rtems_irq_hdl_param p
213);
214
215int BSP_rtems_int_disconnect(
216 rtems_irq_number n,
217 rtems_irq_hdl hdl,
218 rtems_irq_hdl_param p
219);
220
221/*
222 * ----------------- RTEMS Global Irq Handler Mngt Routines ----------------
223 */
224/*
225 * (Re) Initialize the RTEMS interrupt management.
226 *
227 * The result of calling this function will be the same as if each individual
228 * handler (config->irqHdlTbl[i].hdl) different from "config->defaultEntry.hdl"
229 * has been individualy connected via
230 * BSP_install_rtems_irq_handler(&config->irqHdlTbl[i])
231 * And each handler currently equal to config->defaultEntry.hdl
232 * has been previously disconnected via
233 * BSP_remove_rtems_irq_handler (&config->irqHdlTbl[i])
234 *
235 * This is to say that all information given will be used and not just
236 * only the space.
237 *
238 * CAUTION : the various table address contained in config will be used
239 * directly by the interrupt mangement code in order to save
240 * data size so they must stay valid after the call => they should
241 * not be modified or declared on a stack.
242 */
243
244int BSP_rtems_irq_mngt_set(rtems_irq_global_settings* config);
245
246/*
247 * (Re) get info on current RTEMS interrupt management.
248 */
249int BSP_rtems_irq_mngt_get(rtems_irq_global_settings**);
250
251#ifdef __cplusplus
252}
253#endif
254
255#endif /* ASM */
256#endif /* _RTEMS_IRQ_H */
Definition: irq.h:65
Definition: irq.h:112