source: rtems/c/src/lib/libbsp/sparc/shared/include/genirq.h @ 4a7d1026

4.11
Last change on this file since 4a7d1026 was 4a7d1026, checked in by Daniel Hellstrom <daniel@…>, on Apr 13, 2015 at 8:25:52 AM

sparc bsps: updated license to rtems.org

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/* General Shared Interrupt handling function interface
2 *
3 * The functions does not manipulate the IRQ controller or the
4 * interrupt level of the CPU. It simply helps the caller with
5 * managing shared interrupts where multiple interrupt routines
6 * share on interrupt vector/number.
7 *
8 * COPYRIGHT (c) 2008.
9 * Cobham Gaisler AB.
10 *
11 * The license and distribution terms for this file may be
12 * found in the file LICENSE in this distribution or at
13 * http://www.rtems.org/license/LICENSE.
14 */
15
16#ifndef __GENIRQ_H__
17#define __GENIRQ_H__
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23typedef void (*genirq_handler)(void *arg);
24typedef void* genirq_t;
25
26struct genirq_stats {
27        unsigned int    irq_cnt;
28};
29
30/* Initialize the genirq interface. Must be the first function
31 * called.
32 *
33 * Returns zero on success, otherwise failure.
34 */
35extern genirq_t genirq_init(int number_of_irqs);
36
37/* Free the dynamically allocated memory that the genirq interface has
38 * allocated.
39 *
40 * Returns zero on success, otherwise failure.
41 */
42extern void genirq_destroy(genirq_t d);
43
44/* Check IRQ number validity
45 *
46 * Returns zero for valid IRQ numbers, -1 of invalid IRQ numbers.
47 */
48extern int genirq_check(genirq_t d, int irq);
49
50/* Register shared interrupt handler.
51 *
52 * \param irq    The interrupt number to register ISR on
53 * \param isr    The interrupt service routine called upon IRQ
54 * \param arg    The argument given to isr() when called.
55 *
56 * Return Values
57 * -1  = Failed
58 * 0   = Handler registered Successfully, first handler on this IRQ
59 * 1   = Handler registered Successfully, _not_ first handler on this IRQ
60 */
61extern int genirq_register(genirq_t d, int irq, genirq_handler isr, void *arg);
62
63/* Unregister an previous registered interrupt handler
64 *
65 * Return Values
66 *  -1 = ISR not registered before
67 *  0  = ISR unregistered
68 *  1  = Unable to unregister enabled ISR
69 */
70extern int genirq_unregister(genirq_t d, int irq, genirq_handler isr, void *arg);
71
72/* Enables IRQ only for this isr[arg] combination. Records if this
73 * is the first interrupt enable, only then must interrupts be enabled
74 * on the interrupt controller.
75 *
76 * IRQs must be disabled before entering this function.
77 *
78 * Return values
79 *  -1 = Failure, for example isr[arg] not registered on this irq
80 *  0  = IRQ must be enabled, it is the first IRQ handler to be enabled
81 *  1  = IRQ has already been enabled, either by isr[arg] or by another handler
82 */
83extern int genirq_enable(genirq_t d, int irq, genirq_handler isr, void *arg);
84
85/* Disables IRQ only for this isr[arg] combination. Records if this
86 * is the only interrupt handler that is enabled on this IRQ, only then
87 * must interrupts be disabled on the interrupt controller.
88 *
89 * IRQs must be disabled before entering this function.
90 *
91 * Return values
92 *  -1 = Failure, for example isr[arg] not registered on this irq
93 *  0  = IRQ must be disabled, no ISR are enabled for this IRQ
94 *  1  = ISR has already been disabled, or other ISRs are still enabled
95 */
96extern int genirq_disable(genirq_t d, int irq, genirq_handler isr, void *arg);
97
98/* Must be called by user when an IRQ has fired, the argument 'irq'
99 * is the IRQ number of the IRQ which was fired.
100 */
101extern void genirq_doirq(genirq_t d, int irq);
102
103#ifdef __cplusplus
104}
105#endif
106
107#endif
Note: See TracBrowser for help on using the repository browser.