source: rtems/c/src/lib/libbsp/arm/edb7312/irq/irq.c @ 7ae2775

4.104.115
Last change on this file since 7ae2775 was f3343c6e, checked in by Joel Sherrill <joel.sherrill@…>, on 09/12/07 at 15:15:32

2007-09-12 Joel Sherrill <joel.sherrill@…>

PR 1257/bsps

  • csb336/network/lan91c11x.c, csb337/startup/bspstart.c, edb7312/irq/irq.c, gba/irq/irq.c, gba/irq/irq_init.c, gp32/startup/bspstart.c, rtl22xx/startup/bspstart.c, shared/abort/abort.c, shared/abort/simple_abort.c, shared/irq/irq_init.c: Code outside of cpukit should use the public API for rtems_interrupt_disable/rtems_interrupt_enable. By bypassing the public API and directly accessing _CPU_ISR_Disable and _CPU_ISR_Enable, they were bypassing the compiler memory barrier directive which could lead to problems. This patch also changes the type of the variable passed into these routines and addresses minor style issues.
  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * Cirrus EP7312 Intererrupt handler
3 *
4 * Copyright (c) 2002 by Jay Monkman <jtm@smoothsmoothie.com>
5 *
6 * Copyright (c) 2002 by Charlie Steader <charlies@poliac.com>
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *
14 *  $Id$
15*/
16#include <bsp.h>
17#include <irq.h>
18#include <rtems/score/thread.h>
19#include <rtems/score/apiext.h>
20#include <ep7312.h>
21
22/*
23 * This function check that the value given for the irq line
24 * is valid.
25 */
26
27static int isValidInterrupt(int irq)
28{
29  if ( (irq < 0) || (irq > BSP_MAX_INT))
30    return 0;
31  return 1;
32}
33
34/*
35 * -------------------- RTEMS Single Irq Handler Mngt Routines ----------------
36 */
37
38int BSP_install_rtems_irq_handler  (const rtems_irq_connect_data* irq)
39{
40    rtems_irq_hdl *HdlTable;
41    rtems_interrupt_level level;
42
43    if (!isValidInterrupt(irq->name)) {
44      return 0;
45    }
46    /*
47     * Check if default handler is actually connected. If not issue an error.
48     */
49    HdlTable = (rtems_irq_hdl *) VECTOR_TABLE;
50    if (*(HdlTable + irq->name) != default_int_handler) {
51      return 0;
52    }
53
54    rtems_interrupt_disable(level);
55
56    /*
57     * store the new handler
58     */
59    *(HdlTable + irq->name) = irq->hdl;
60
61    /*
62     * unmask interrupt
63     */
64    if(irq->name >= BSP_EXTFIQ && irq->name <= BSP_SSEOTI)
65    {
66        /* interrupt managed by INTMR1 and INTSR1 */
67        *EP7312_INTMR1 |= (1 << irq->name);
68    }
69    else if(irq->name >= BSP_KBDINT && irq->name <= BSP_SS2TX)
70    {
71        /* interrupt managed by INTMR2 and INTSR2 */
72        *EP7312_INTMR2 |= (1 << (irq->name - 16));
73    }
74    else if(irq->name >= BSP_UTXINT2 && irq->name <= BSP_URXINT2)
75    {
76        /* interrupt managed by INTMR2 and INTSR2 */
77        *EP7312_INTMR2 |= (1 << (irq->name - 7));
78    }
79    else if(irq->name == BSP_DAIINT)
80    {
81        /* interrupt managed by INTMR3 and INTSR3 */
82        *EP7312_INTMR3 |= (1 << (irq->name - 21));
83    }
84
85    /*
86     * Enable interrupt on device
87     */
88    if(irq->on)
89    {
90        irq->on(irq);
91    }
92
93    rtems_interrupt_enable(level);
94
95    return 1;
96}
97
98int BSP_remove_rtems_irq_handler  (const rtems_irq_connect_data* irq)
99{
100    rtems_irq_hdl *HdlTable;
101    rtems_interrupt_level level;
102
103    if (!isValidInterrupt(irq->name)) {
104      return 0;
105    }
106    /*
107     * Check if the handler is actually connected. If not issue an error.
108     */
109    HdlTable = (rtems_irq_hdl *) VECTOR_TABLE;
110    if (*(HdlTable + irq->name) != irq->hdl) {
111      return 0;
112    }
113    rtems_interrupt_disable(level);
114
115    /*
116     * mask interrupt
117     */
118    if(irq->name >= BSP_EXTFIQ && irq->name <= BSP_SSEOTI)
119    {
120        /* interrupt managed by INTMR1 and INTSR1 */
121        *EP7312_INTMR1 &= ~(1 << irq->name);
122    }
123    else if(irq->name >= BSP_KBDINT && irq->name <= BSP_SS2TX)
124    {
125        /* interrupt managed by INTMR2 and INTSR2 */
126        *EP7312_INTMR2 &= ~(1 << (irq->name - 16));
127    }
128    else if(irq->name >= BSP_UTXINT2 && irq->name <= BSP_URXINT2)
129    {
130        /* interrupt managed by INTMR2 and INTSR2 */
131        *EP7312_INTMR2 &= ~(1 << (irq->name - 7));
132    }
133    else if(irq->name == BSP_DAIINT)
134    {
135        /* interrupt managed by INTMR3 and INTSR3 */
136        *EP7312_INTMR3 &= ~(1 << (irq->name - 21));
137    }
138
139    /*
140     * Disable interrupt on device
141     */
142    if(irq->off)
143        irq->off(irq);
144
145    /*
146     * restore the default irq value
147     */
148    *(HdlTable + irq->name) = default_int_handler;
149
150    rtems_interrupt_enable(level);
151
152    return 1;
153}
Note: See TracBrowser for help on using the repository browser.