source: rtems/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/irq_supp.h @ 2d2de4eb

4.104.115
Last change on this file since 2d2de4eb was 2d2de4eb, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 10/23/09 at 07:32:46

Update for exception support changes.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 *  The license and distribution terms for this file may be
3 *  found in found in the file LICENSE in this distribution or at
4 *  http://www.rtems.com/license/LICENSE.
5 *
6 *  $Id$
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 found in the file LICENSE in this distribution or at
18 *  http://www.rtems.com/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/* IRQ dispatcher to be defined by the PIC driver; note that it MUST
56 * implement shared interrupts.
57 * Note also that the exception frame passed to this handler is not very
58 * meaningful. Only the volatile registers and vector info are stored.
59 *
60 *******************************************************************
61 * The routine must return zero if the interrupt was handled. If a
62 * nonzero value is returned the dispatcher may panic and flag an
63 * uncaught exception.
64 *******************************************************************
65 */
66int C_dispatch_irq_handler (BSP_Exception_frame *frame, unsigned int excNum);
67
68/*
69 * Snippet to be used by PIC drivers and by bsp_irq_dispatch_list
70 * traverses list of shared handlers for a given interrupt
71 *
72 */
73
74static inline void
75bsp_irq_dispatch_list_base(
76  rtems_irq_connect_data *tbl,
77  unsigned irq,
78  rtems_irq_hdl sentinel
79)
80{
81        rtems_irq_connect_data* vchain;
82        for( vchain = &tbl[irq];
83                        ((int)vchain != -1 && vchain->hdl != sentinel);
84                        vchain = (rtems_irq_connect_data*)vchain->next_handler )
85        {
86          vchain->hdl(vchain->handle);
87        }
88}
89
90
91/*
92 * Snippet to be used by PIC drivers;
93 * enables interrupts, traverses list of
94 * shared handlers for a given interrupt
95 * and restores original irq level
96 *
97 * Note that _ISR_Get_level() & friends are preferable to
98 * manipulating MSR directly.
99 */
100
101static inline void
102bsp_irq_dispatch_list(
103  rtems_irq_connect_data *tbl,
104  unsigned irq,
105  rtems_irq_hdl sentinel
106)
107{
108        register uint32_t l_orig;
109
110        l_orig = _ISR_Get_level();
111
112        /* Enable all interrupts */
113        _ISR_Set_level(0);
114
115
116        bsp_irq_dispatch_list_base( tbl, irq, sentinel );
117
118        /* Restore original level */
119        _ISR_Set_level(l_orig);
120}
121
122#ifdef __cplusplus
123}
124#endif
125
126#endif
Note: See TracBrowser for help on using the repository browser.