source: rtems/c/src/lib/libbsp/arm/gba/irq/irq.c @ 3c7ed6b

4.104.114.84.95
Last change on this file since 3c7ed6b was 3c7ed6b, checked in by Joel Sherrill <joel.sherrill@…>, on 07/06/05 at 18:46:04

2005-07-06 Markku Puro <markku.puro@…>

  • .cvsignore, ChangeLog?, Makefile.am, README, bsp_specs, configure.ac, clock/clockdrv.c, console/conio.c, console/console.c, console/defaultfont.c, include/arm_mode_bits.h, include/asm_macros.h, include/bsp.h, include/bspopts.h.in, include/conio.h, include/gba.h, include/gba_registers.h, include/tm27.h, irq/bsp_irq_asm.S, irq/bsp_irq_init.c, irq/irq.c, irq/irq.h, irq/irq_asm.S, irq/irq_init.c, start/logo.S, start/start.S, startup/bspstart.c, startup/cpu.c, startup/cpu_asm.S, startup/exit.c, startup/linkcmds, timer/timer.c: New files.
  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[3c7ed6b]1/**
2 *  @file irq.c
3 *
4 *  This file contains the implementation of the function described in irq.h.
5 */
6/*
7 *  RTEMS GBA BSP
8 *
9 *  Copyright (c) 2002 by Jay Monkman <jtm@smoothsmoothie.com>
10 *
11 *  Copyright (c) 2002 by Charlie Steader <charlies@poliac.com>
12 *
13 *  Copyright (c) 2004 by Markku Puro <markku.puro@kopteri.net>
14 *
15 *  The license and distribution terms for this file may be
16 *  found in found in the file LICENSE in this distribution or at
17 *  http://www.rtems.com/license/LICENSE.
18 *
19 *  $Id$
20 */
21
22#include <bsp.h>
23#include <irq.h>
24#include <gba_registers.h>
25#include <rtems/score/thread.h>
26#include <rtems/score/apiext.h>
27
28
29/**
30 *  @brief isValidInterrupt function check that the value given for the irq line is valid.
31 *
32 *  @param  irq irq number
33 *  @return status code TRUE/FALSE (0/1)
34 */
35static int isValidInterrupt(int irq)
36{
37  if ( (irq < 0) || (irq > BSP_MAX_INT)) {
38     return 0;
39  }
40  return 1;
41}
42
43/*
44 * ------------------------ RTEMS Single Irq Handler Mngt Routines ----------------
45 */
46
47
48/**
49 *  @brief BSP_install_rtems_irq_handler function install rtems irq handler.
50 *
51 *  @param  irq irq connect data
52 *  @return status code TRUE/FALSE (0/1)
53 */
54int BSP_install_rtems_irq_handler  (const rtems_irq_connect_data* irq)
55{
56    rtems_irq_hdl *HdlTable;
57    rtems_interrupt_level level;
58
59    if (!isValidInterrupt(irq->name)) {
60       return 0;
61    }
62    /*
63     * Check if default handler is actually connected. If not issue an error.
64     */
65    HdlTable = (rtems_irq_hdl *) (unsigned32)VECTOR_TABLE;
66    if (*(HdlTable + irq->name) != default_int_handler) {
67       return 0;
68    }
69
70    _CPU_ISR_Disable(level);
71
72    /*
73     * store the new handler
74     */
75    *(HdlTable + irq->name) = irq->hdl;
76
77    /*
78     * ack pending interrupt
79     */
80    GBA_REG_IF |= (1 << (irq->name));
81
82    /*
83     * initialize the control register for the concerned interrupt
84     */
85    GBA_REG_IE |= (1 << (irq->name));
86
87    /*
88     * Enable interrupt on device
89     */
90    irq->on(irq);
91
92    _CPU_ISR_Enable(level);
93
94    return 1;
95}
96
97/**
98 *  @brief BSP_remove_rtems_irq_handler function removes rtems irq handler.
99 *
100 *  @param  irq irq connect data
101 *  @return status code TRUE/FALSE (0/1)
102 */
103int BSP_remove_rtems_irq_handler  (const rtems_irq_connect_data* irq)
104{
105    rtems_irq_hdl *HdlTable;
106    rtems_interrupt_level level;
107
108    if (!isValidInterrupt(irq->name)) {
109       return 0;
110    }
111    /*
112     * Check if the handler is actually connected. If not issue an error.
113     */
114    HdlTable = (rtems_irq_hdl *) (unsigned32)VECTOR_TABLE;
115    if (*(HdlTable + irq->name) != irq->hdl) {
116       return 0;
117    }
118    _CPU_ISR_Disable(level);
119
120    /*
121     * mask at INT controller level
122     */
123    GBA_REG_IE &= ~(1 << irq->name);
124
125    /*
126     * Disable interrupt on device
127     */
128    irq->off(irq);
129
130    /*
131     * restore the default irq value
132     */
133    *(HdlTable + irq->name) = default_int_handler;
134
135    _CPU_ISR_Enable(level);
136
137    return 1;
138}
139
140
141/**
142 *  @brief _ThreadProcessSignalsFromIrq function check that the value given for the irq line is valid.
143 *
144 *  @param  cxt exeption frame
145 *  @return None
146 */
147void _ThreadProcessSignalsFromIrq (CPU_Exception_frame* ctx)
148{
149  /*
150   * Process pending signals that have not already been
151   * processed by _Thread_Dispatch. This happens quite
152   * unfrequently : the ISR must have posted an action
153   * to the current running thread.
154   */
155  if ( _Thread_Do_post_task_switch_extension ||
156       _Thread_Executing->do_post_task_switch_extension )
157  {
158     _Thread_Executing->do_post_task_switch_extension = FALSE;
159     _API_extensions_Run_postswitch();
160  }
161}
Note: See TracBrowser for help on using the repository browser.