source: rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/irq.c @ 8824dd7a

4.104.114.84.95
Last change on this file since 8824dd7a was 1cfcfd3, checked in by Jay Monkman <jtm@…>, on 07/15/04 at 06:25:44

2004-07-15 Jay Monkman

  • ChangeLog?, Makefile.am, clock/.cvsignore, clock/clockdrv.c, include/mc9328mxl.h, irq/.cvsignore, irq/bsp_irq_asm.S, irq/bsp_irq_init.c, irq/irq.c, irq/irq.h, timer/.cvsignore, timer/timer.c: New files.
  • Property mode set to 100644
File size: 2.1 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
19/*
20 * This function check that the value given for the irq line
21 * is valid.
22 */
23static int isValidInterrupt(int irq)
24{
25  if ( (irq < 0) || (irq >= BSP_MAX_INT))
26    return 0;
27  return 1;
28}
29
30/*
31 * Installs the interrupt handler.
32 *
33 * You should only have to add the code to unmask the interrupt.
34 *
35 */
36int BSP_install_rtems_irq_handler  (const rtems_irq_connect_data* irq)
37{
38    rtems_interrupt_level level;
39    uint32_t *bsp_tbl;
40
41    bsp_tbl = (uint32_t*)&bsp_vector_table;
42   
43    if (!isValidInterrupt(irq->name)) {
44      return 0;
45    }
46
47    /*
48     * Check if default handler is actually connected. If not issue an error.
49     */
50    if (bsp_tbl[irq->name] != default_int_handler) {
51      return 0;
52    }
53
54    _CPU_ISR_Disable(level);
55
56    /*
57     * store the new handler
58     */
59    bsp_tbl[irq->name] = irq->hdl;
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    uint32_t *bsp_tbl;
84
85    bsp_tbl = (uint32_t*)&bsp_vector_table;
86 
87    if (!isValidInterrupt(irq->name)) {
88      return 0;
89    }
90    /*
91     * Check if the handler is actually connected. If not issue an error.
92     */
93    if (bsp_tbl[irq->name] != irq->hdl) {
94      return 0;
95    }
96
97    _CPU_ISR_Disable(level);
98
99
100    /*
101     * Disable interrupt on device
102     */
103    if(irq->off) {
104        irq->off(irq);
105    }
106    /*
107     * restore the default irq value
108     */
109    bsp_tbl[irq->name] = default_int_handler;
110   
111
112    _CPU_ISR_Enable(level);
113
114    return 1;
115}
116
117
Note: See TracBrowser for help on using the repository browser.