diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2005-07-06 18:46:04 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2005-07-06 18:46:04 +0000 |
commit | 3c7ed6b8cd505f696c9c2b6d90723094f334b348 (patch) | |
tree | 30da596d32865c2d042ece5735d16baeade7d17d /c/src/lib/libbsp/arm/gba/irq/irq.c | |
parent | Add PR. (diff) | |
download | rtems-3c7ed6b8cd505f696c9c2b6d90723094f334b348.tar.bz2 |
2005-07-06 Markku Puro <markku.puro@kopteri.net>
* .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.
Diffstat (limited to 'c/src/lib/libbsp/arm/gba/irq/irq.c')
-rw-r--r-- | c/src/lib/libbsp/arm/gba/irq/irq.c | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/arm/gba/irq/irq.c b/c/src/lib/libbsp/arm/gba/irq/irq.c new file mode 100644 index 0000000000..fbf93f17cd --- /dev/null +++ b/c/src/lib/libbsp/arm/gba/irq/irq.c @@ -0,0 +1,161 @@ +/** + * @file irq.c + * + * This file contains the implementation of the function described in irq.h. + */ +/* + * RTEMS GBA BSP + * + * Copyright (c) 2002 by Jay Monkman <jtm@smoothsmoothie.com> + * + * Copyright (c) 2002 by Charlie Steader <charlies@poliac.com> + * + * Copyright (c) 2004 by Markku Puro <markku.puro@kopteri.net> + * + * The license and distribution terms for this file may be + * found in found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#include <bsp.h> +#include <irq.h> +#include <gba_registers.h> +#include <rtems/score/thread.h> +#include <rtems/score/apiext.h> + + +/** + * @brief isValidInterrupt function check that the value given for the irq line is valid. + * + * @param irq irq number + * @return status code TRUE/FALSE (0/1) + */ +static int isValidInterrupt(int irq) +{ + if ( (irq < 0) || (irq > BSP_MAX_INT)) { + return 0; + } + return 1; +} + +/* + * ------------------------ RTEMS Single Irq Handler Mngt Routines ---------------- + */ + + +/** + * @brief BSP_install_rtems_irq_handler function install rtems irq handler. + * + * @param irq irq connect data + * @return status code TRUE/FALSE (0/1) + */ +int BSP_install_rtems_irq_handler (const rtems_irq_connect_data* irq) +{ + rtems_irq_hdl *HdlTable; + rtems_interrupt_level level; + + if (!isValidInterrupt(irq->name)) { + return 0; + } + /* + * Check if default handler is actually connected. If not issue an error. + */ + HdlTable = (rtems_irq_hdl *) (unsigned32)VECTOR_TABLE; + if (*(HdlTable + irq->name) != default_int_handler) { + return 0; + } + + _CPU_ISR_Disable(level); + + /* + * store the new handler + */ + *(HdlTable + irq->name) = irq->hdl; + + /* + * ack pending interrupt + */ + GBA_REG_IF |= (1 << (irq->name)); + + /* + * initialize the control register for the concerned interrupt + */ + GBA_REG_IE |= (1 << (irq->name)); + + /* + * Enable interrupt on device + */ + irq->on(irq); + + _CPU_ISR_Enable(level); + + return 1; +} + +/** + * @brief BSP_remove_rtems_irq_handler function removes rtems irq handler. + * + * @param irq irq connect data + * @return status code TRUE/FALSE (0/1) + */ +int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data* irq) +{ + rtems_irq_hdl *HdlTable; + rtems_interrupt_level level; + + if (!isValidInterrupt(irq->name)) { + return 0; + } + /* + * Check if the handler is actually connected. If not issue an error. + */ + HdlTable = (rtems_irq_hdl *) (unsigned32)VECTOR_TABLE; + if (*(HdlTable + irq->name) != irq->hdl) { + return 0; + } + _CPU_ISR_Disable(level); + + /* + * mask at INT controller level + */ + GBA_REG_IE &= ~(1 << irq->name); + + /* + * Disable interrupt on device + */ + irq->off(irq); + + /* + * restore the default irq value + */ + *(HdlTable + irq->name) = default_int_handler; + + _CPU_ISR_Enable(level); + + return 1; +} + + +/** + * @brief _ThreadProcessSignalsFromIrq function check that the value given for the irq line is valid. + * + * @param cxt exeption frame + * @return None + */ +void _ThreadProcessSignalsFromIrq (CPU_Exception_frame* ctx) +{ + /* + * Process pending signals that have not already been + * processed by _Thread_Dispatch. This happens quite + * unfrequently : the ISR must have posted an action + * to the current running thread. + */ + if ( _Thread_Do_post_task_switch_extension || + _Thread_Executing->do_post_task_switch_extension ) + { + _Thread_Executing->do_post_task_switch_extension = FALSE; + _API_extensions_Run_postswitch(); + } +} |