source: rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/irq.c @ 7afe5a2

4.104.114.84.95
Last change on this file since 7afe5a2 was 7afe5a2, checked in by Jay Monkman <jtm@…>, on 06/03/06 at 03:14:07

2006-06-02 Jay Monkman

  • at91rm9200/irq/bsp_irq_init.c, mc9328mxl/clock/clockdrv.c, mc9328mxl/irq/bsp_irq_asm.S, mc9328mxl/irq/bsp_irq_init.c, mc9328mxl/irq/irq.c, mc9328mxl/irq/irq.h, s3c2400/irq/bsp_irq_init.c: Changed interrupt handling to use shared rtems_irq_connect_data struct.
  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 * Motorola MC9328MXL 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.OARcorp.com/rtems/license.html.
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 <mc9328mxl.h>
18
19mc9328mxl_irq_info_t bsp_vector_table[BSP_MAX_INT];
20
21/*
22 * This function check that the value given for the irq line
23 * is valid.
24 */
25static int isValidInterrupt(int irq)
26{
27  if ( (irq < 0) || (irq >= BSP_MAX_INT))
28    return 0;
29  return 1;
30}
31
32/*
33 * Installs the interrupt handler.
34 *
35 * You should only have to add the code to unmask the interrupt.
36 *
37 */
38int BSP_install_rtems_irq_handler  (const rtems_irq_connect_data* irq)
39{
40    rtems_interrupt_level level;
41   
42    if (!isValidInterrupt(irq->name)) {
43      return 0;
44    }
45
46    /*
47     * Check if default handler is actually connected. If not issue an error.
48     */
49    if (bsp_vector_table[irq->name].vector != default_int_handler) {
50        return 0;
51    }
52
53    _CPU_ISR_Disable(level);
54
55    /*
56     * store the new handler
57     */
58    bsp_vector_table[irq->name].vector = irq->hdl;
59    bsp_vector_table[irq->name].data = irq->handle;
60
61    /*
62     * Enable interrupt on device
63     */
64    if(irq->on)
65    {
66        irq->on(irq);
67    }
68   
69    _CPU_ISR_Enable(level);
70   
71    return 1;
72}
73
74/*
75 * Remove and interrupt handler
76 *
77 * You should only have to add the code to mask the interrupt.
78 *
79 */
80int BSP_remove_rtems_irq_handler  (const rtems_irq_connect_data* irq)
81{
82    rtems_interrupt_level level;
83
84    if (!isValidInterrupt(irq->name)) {
85      return 0;
86    }
87    /*
88     * Check if the handler is actually connected. If not issue an error.
89     */
90    if (bsp_vector_table[irq->name].vector != irq->hdl) {
91        return 0;
92    }
93
94    _CPU_ISR_Disable(level);
95
96
97    /*
98     * Disable interrupt on device
99     */
100    if(irq->off) {
101        irq->off(irq);
102    }
103    /*
104     * restore the default irq value
105     */
106    bsp_vector_table[irq->name].vector = default_int_handler;
107    bsp_vector_table[irq->name].data = NULL;
108
109    _CPU_ISR_Enable(level);
110
111    return 1;
112}
113
114
Note: See TracBrowser for help on using the repository browser.