source: rtems/c/src/lib/libcpu/arm/at91rm9200/irq/irq.c @ 23f1974

4.104.114.84.95
Last change on this file since 23f1974 was 23f1974, checked in by Joel Sherrill <joel.sherrill@…>, on 09/12/07 at 15:23:30

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

PR 1257/bsps

  • at91rm9200/irq/irq.c, lpc22xx/irq/irq.c, mc9328mxl/irq/irq.c, s3c2400/irq/irq.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: 2.4 KB
Line 
1/*
2 * Atmel AT91RM9200 Interrupt handler
3 *
4 * Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com>
5 *     
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13#include <bsp.h>
14#include <irq.h>
15#include <rtems/score/thread.h>
16#include <rtems/score/apiext.h>
17#include <at91rm9200.h>
18
19/*
20 * This function check that the value given for the irq line
21 * is valid.
22 */
23static int isValidInterrupt(int irq)
24{
25    if ( (irq < 0) || (irq >= AT91RM9200_MAX_INT)) {
26        return 0;
27    }
28    return 1;
29}
30
31/*
32 * Installs the interrupt handler.
33 */
34int BSP_install_rtems_irq_handler  (const rtems_irq_connect_data* irq)
35{
36    rtems_interrupt_level level;
37   
38    if (!isValidInterrupt(irq->name)) {
39        return 0;
40    }
41   
42    /*
43     * Check if default handler is actually connected. If not, issue
44     * an error. Note: irq->name is a number corresponding to the
45     * sources PID (see the at91rm9200_pid for this mapping).  We
46     * convert it to a long word offset to get source's vector register
47     */
48    if (AIC_SVR_REG(irq->name * 4) != (uint32_t) default_int_handler) {
49        return 0;
50    }
51   
52    rtems_interrupt_disable(level);
53   
54    /*
55     * store the new handler
56     */
57    AIC_SVR_REG(irq->name * 4) = (uint32_t) irq->hdl;
58   
59    /*
60     * unmask interrupt
61     */
62    AIC_CTL_REG(AIC_IECR) = 1 << irq->name;
63   
64    /*
65     * Enable interrupt on device
66     */
67    if(irq->on) {
68        irq->on(irq);
69    }
70   
71    rtems_interrupt_enable(level);
72   
73    return 1;
74}
75
76/*
77 * Remove and interrupt handler
78 */
79int BSP_remove_rtems_irq_handler  (const rtems_irq_connect_data* irq)
80{
81    rtems_interrupt_level level;
82 
83    if (!isValidInterrupt(irq->name)) {
84        return 0;
85    }
86
87    /*
88     * Check if the handler is actually connected. If not, issue an error.
89     */
90    if (AIC_SVR_REG(irq->name * 4) != (uint32_t) irq->hdl) {
91      return 0;
92    }
93    rtems_interrupt_disable(level);
94
95    /*
96     * mask interrupt
97     */
98    AIC_CTL_REG(AIC_IDCR) = 1 << irq->name;
99   
100    /*
101     * Disable interrupt on device
102     */
103    if(irq->off) {
104        irq->off(irq);
105    }
106
107    /*
108     * restore the default irq value
109     */
110    AIC_SVR_REG(irq->name * 4) = (uint32_t) default_int_handler;
111   
112    rtems_interrupt_enable(level);
113
114    return 1;
115}
Note: See TracBrowser for help on using the repository browser.