source: rtems/c/src/lib/libcpu/arm/s3c2400/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.2 KB
Line 
1/* irq.c
2 *
3 *  This file contains the implementation of the function described in irq.h
4 *
5 *  CopyRight (C) 2000 Canon Research France SA.
6 *  Emmanuel Raguet,  mailto:raguet@crf.canon.fr
7 *
8 *  The license and distribution terms for this file may be
9 *  found in found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15
16#include <bsp.h>
17#include <irq.h>
18#include <rtems/score/thread.h>
19#include <rtems/score/apiext.h>
20#include <s3c2400.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    }
32
33    return 1;
34}
35
36/*
37 * ------------------- RTEMS Single Irq Handler Mngt Routines ----------------
38 */
39
40int BSP_install_rtems_irq_handler  (const rtems_irq_connect_data* irq)
41{
42    rtems_irq_hdl         *HdlTable;
43    rtems_interrupt_level  level;
44   
45    if (!isValidInterrupt(irq->name)) {
46        return 0;
47    }
48
49    /*
50     * Check if default handler is actually connected. If not issue an error.
51     */
52    HdlTable = (rtems_irq_hdl *)VECTOR_TABLE;
53    if (*(HdlTable + irq->name) != default_int_handler) {
54        return 0;
55    }
56   
57    rtems_interrupt_disable(level);
58
59    /*
60     * store the new handler
61     */
62    *(HdlTable + irq->name) = irq->hdl;
63
64    /*
65     * Enable interrupt on device
66     */
67    if(irq->on)
68    {
69        irq->on(irq);
70    }
71
72    rtems_interrupt_enable(level);
73
74    return 1;
75}
76
77int BSP_remove_rtems_irq_handler  (const rtems_irq_connect_data* irq)
78{
79    rtems_irq_hdl         *HdlTable;
80    rtems_interrupt_level  level;
81 
82    if (!isValidInterrupt(irq->name)) {
83        return 0;
84    }
85
86    /*
87     * Check if the handler is actually connected. If not issue an error.
88     */
89    HdlTable = (rtems_irq_hdl *)VECTOR_TABLE;
90    if (*(HdlTable + irq->name) != irq->hdl) {
91        return 0;
92    }
93    rtems_interrupt_disable(level);
94
95    /*
96     * Disable interrupt on device
97     */
98    if(irq->off) {
99        irq->off(irq);
100    }
101
102    /*
103     * restore the default irq value
104     */
105    *(HdlTable + irq->name) = default_int_handler;
106         
107    rtems_interrupt_enable(level);
108
109    return 1;
110}
Note: See TracBrowser for help on using the repository browser.