diff options
Diffstat (limited to 'c/src/lib/libbsp/arm/gba/irq/irq.c')
-rw-r--r-- | c/src/lib/libbsp/arm/gba/irq/irq.c | 153 |
1 files changed, 31 insertions, 122 deletions
diff --git a/c/src/lib/libbsp/arm/gba/irq/irq.c b/c/src/lib/libbsp/arm/gba/irq/irq.c index 6abc48f6e3..567cf91be8 100644 --- a/c/src/lib/libbsp/arm/gba/irq/irq.c +++ b/c/src/lib/libbsp/arm/gba/irq/irq.c @@ -6,6 +6,8 @@ /* * RTEMS GBA BSP * + * Copyright (c) 2010 embedded brains GmbH. + * * Copyright (c) 2002 by Jay Monkman <jtm@smoothsmoothie.com> * * Copyright (c) 2002 by Charlie Steader <charlies@poliac.com> @@ -20,144 +22,51 @@ */ #include <bsp.h> -#include <irq.h> -#include <gba_registers.h> -#include <rtems/score/thread.h> -#include <rtems/score/apiext.h> +#include <bsp/irq.h> +#include <bsp/irq-generic.h> +#include <gba_registers.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) +void bsp_interrupt_dispatch(void) { - if ( (irq < 0) || (irq > BSP_MAX_INT)) { - return 0; - } - return 1; -} + unsigned reg_ie = GBA_REG_IE; + unsigned reg_if = GBA_REG_IF & reg_ie; + rtems_vector_number vector = 31 - __builtin_clz(reg_if); -/* - * ------------------------ RTEMS Single Irq Handler Mngt Routines ---------------- - */ + bsp_interrupt_handler_dispatch(vector); + GBA_REG_IF = 1 << vector; +} -/** - * @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_status_code bsp_interrupt_vector_enable(rtems_vector_number vector) { - 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 *) (uint32_t)VECTOR_TABLE; - if (*(HdlTable + irq->name) != default_int_handler) { - return 0; - } - - rtems_interrupt_disable(level); - - /* - * store the new handler - */ - *(HdlTable + irq->name) = irq->hdl; + GBA_REG_IE |= 1 << vector; - /* - * 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 - */ - if (irq->on) - irq->on(irq); - - rtems_interrupt_enable(level); - - return 1; + return RTEMS_SUCCESSFUL; } -/** - * @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_status_code bsp_interrupt_vector_disable(rtems_vector_number vector) { - 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 *) (uint32_t)VECTOR_TABLE; - if (*(HdlTable + irq->name) != irq->hdl) { - return 0; - } - rtems_interrupt_disable(level); + GBA_REG_IE &= ~(1 << vector); - /* - * mask at INT controller level - */ - GBA_REG_IE &= ~(1 << irq->name); - - /* - * Disable interrupt on device - */ - if (irq->off) - irq->off(irq); + return RTEMS_SUCCESSFUL; +} - /* - * restore the default irq value - */ - *(HdlTable + irq->name) = default_int_handler; +rtems_status_code bsp_interrupt_facility_initialize(void) +{ + /* clear all interrupt status flags */ + GBA_REG_IF = 0xffff; + /* disable all interrupts */ + GBA_REG_IE = 0; + /* set master interrupt enable */ + GBA_REG_IME = 1; - rtems_interrupt_enable(level); + /* Exception handler is already present in the ROM BIOS */ - return 1; + return RTEMS_SUCCESSFUL; } - -/** - * @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) +void bsp_interrupt_handler_default(rtems_vector_number vector) { - /* - * 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(); - } + printk("spurious interrupt: %u\n", vector); } |