RTEMS 7.0-rc1
Loading...
Searching...
No Matches
irq_supp.h
1/* SPDX-License-Identifier: GPL-2.0+-with-RTEMS-exception */
2
3/*
4 * The license and distribution terms for this file may be
5 * found in the file LICENSE in this distribution or at
6 * http://www.rtems.org/license/LICENSE.
7 */
8
9#ifndef IRQ_SHARED_IRQ_C_GLUE_H
10#define IRQ_SHARED_IRQ_C_GLUE_H
11/*
12 * This header describes the routines that are needed by the shared
13 * version of 'irq.c' (implementing the RTEMS irq API). They
14 * must be provided by the BSP.
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.org/license/LICENSE.
19 *
20 */
21
22#ifndef BSP_SHARED_HANDLER_SUPPORT
23#define BSP_SHARED_HANDLER_SUPPORT 1
24#endif
25
26#include <rtems.h>
27#include <rtems/irq.h>
28
29#include <bsp/vectors.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/*
36 * PIC-independent functions to enable/disable interrupt lines at
37 * the pic.
38 *
39 * NOTE: the routines must ignore requests for enabling/disabling
40 * interrupts that are outside of the range handled by the
41 * PIC(s).
42 */
43extern void BSP_enable_irq_at_pic(const rtems_irq_number irqLine);
44/*
45 * RETURNS: nonzero (> 0 ) if irq was enabled originally, zero if irq
46 * was off and negative value if there was an error.
47 */
48extern int BSP_disable_irq_at_pic(const rtems_irq_number irqLine);
49
50/*
51 * Initialize the PIC.
52 */
53extern int BSP_setup_the_pic(rtems_irq_global_settings* config);
54
55/*
56 * Set up for the irq-generic.h interface.
57 */
58int BSP_rtems_irq_generic_set(rtems_irq_global_settings* config);
59
60/* IRQ dispatcher to be defined by the PIC driver; note that it MUST
61 * implement shared interrupts.
62 * Note also that the exception frame passed to this handler is not very
63 * meaningful. Only the volatile registers and vector info are stored.
64 *
65 *******************************************************************
66 * The routine must return zero if the interrupt was handled. If a
67 * nonzero value is returned the dispatcher may panic and flag an
68 * uncaught exception.
69 *******************************************************************
70 */
71int C_dispatch_irq_handler (BSP_Exception_frame *frame, unsigned int excNum);
72
73/*
74 * Snippet to be used by PIC drivers and by bsp_irq_dispatch_list
75 * traverses list of shared handlers for a given interrupt
76 *
77 */
78
79static inline void
80bsp_irq_dispatch_list_base(
82 unsigned irq,
83 rtems_irq_hdl sentinel
84)
85{
87 for( vchain = &tbl[irq];
88 ((intptr_t)vchain != -1 && vchain->hdl != sentinel);
89 vchain = (rtems_irq_connect_data*)vchain->next_handler )
90 {
91 vchain->hdl(vchain->handle);
92 }
93}
94
95
96/*
97 * Snippet to be used by PIC drivers;
98 * enables interrupts, traverses list of
99 * shared handlers for a given interrupt
100 * and restores original irq level
101 *
102 * Note that _ISR_Get_level() & friends are preferable to
103 * manipulating MSR directly.
104 */
105
106static inline void
107bsp_irq_dispatch_list(
109 unsigned irq,
110 rtems_irq_hdl sentinel
111)
112{
113 register uint32_t l_orig;
114
115 l_orig = _ISR_Get_level();
116
117 /* Enable all interrupts */
119
120
121 bsp_irq_dispatch_list_base( tbl, irq, sentinel );
122
123 /* Restore original level */
124 _ISR_Set_level(l_orig);
125}
126
127#ifdef __cplusplus
128}
129#endif
130
131#endif
PowerPC Exceptions API.
Interrupt Handler Support.
#define _ISR_Get_level()
Return current interrupt level.
Definition: isrlevel.h:147
#define _ISR_Set_level(_new_level)
Set current interrupt level.
Definition: isrlevel.h:159
This header file defines the RTEMS Classic API.
The set of registers that specifies the complete processor state.
Definition: cpu.h:500
Definition: irq.h:65
Definition: irq.h:112