OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [lib/] [libbsp/] [arm/] [vegaplus/] [irq/] [irq.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/* irq.c
2
 *
3
 *  This file contains the implementation of the function described in irq.h
4
 *
5
 *  CopyRight (C) 2000 Canon Research France SA.
6
 *  Emmanuel Raguet,  mailto:raguet@crf.canon.fr
7
 *
8
 *  The license and distribution terms for this file may be
9
 *  found in found in the file LICENSE in this distribution or at
10
 *  http://www.OARcorp.com/rtems/license.html.
11
 *
12
 *  irq.c,v 1.2 2000/09/13 19:42:20 joel Exp
13
 */
14
 
15
 
16
#include <bsp.h>
17
#include <irq.h>
18
#include <registers.h>
19
#include <rtems/score/thread.h>
20
#include <rtems/score/apiext.h>
21
 
22
 
23
/*
24
 * This function check that the value given for the irq line
25
 * is valid.
26
 */
27
 
28
static int isValidInterrupt(int irq)
29
{
30
  if ( (irq < 0) || (irq > BSP_MAX_INT))
31
    return 0;
32
  return 1;
33
}
34
 
35
/*
36
 * ------------------------ RTEMS Single Irq Handler Mngt Routines ----------------
37
 */
38
 
39
int BSP_install_rtems_irq_handler  (const rtems_irq_connect_data* irq)
40
{
41
    rtems_irq_hdl *HdlTable;
42
    rtems_interrupt_level level;
43
 
44
    if (!isValidInterrupt(irq->name)) {
45
      return 0;
46
    }
47
    /*
48
     * Check if default handler is actually connected. If not issue an error.
49
     */
50
    HdlTable = (rtems_irq_hdl *) VECTOR_TABLE;
51
    if (*(HdlTable + irq->name) != default_int_handler) {
52
      return 0;
53
    }
54
 
55
    _CPU_ISR_Disable(level);
56
 
57
    /*
58
     * store the new handler
59
     */
60
    *(HdlTable + irq->name) = irq->hdl;
61
 
62
    /*
63
     * initialize the control register for the concerned interrupt
64
     */
65
    Regs[(INTCNTL0 + irq->name)] = (long)(irq->irqTrigger) | (long)(irq->irqLevel) ;
66
 
67
    /*
68
     * ack pending interrupt
69
     */
70
    Regs[INTACK] |= (long)(1 << irq->name);
71
 
72
    /*
73
     * unmask at INT controler level level
74
     */
75
    Regs[INTMASK] &= ~(long)(1 << irq->name);
76
 
77
    /*
78
     * Enable interrupt on device
79
     */
80
    irq->on(irq);
81
 
82
    _CPU_ISR_Enable(level);
83
 
84
    return 1;
85
}
86
 
87
int BSP_remove_rtems_irq_handler  (const rtems_irq_connect_data* irq)
88
{
89
    rtems_irq_hdl *HdlTable;
90
    rtems_interrupt_level level;
91
 
92
    if (!isValidInterrupt(irq->name)) {
93
      return 0;
94
    }
95
    /*
96
     * Check if the handler is actually connected. If not issue an error.
97
     */
98
    HdlTable = (rtems_irq_hdl *) VECTOR_TABLE;
99
    if (*(HdlTable + irq->name) != irq->hdl) {
100
      return 0;
101
    }
102
    _CPU_ISR_Disable(level);
103
 
104
    /*
105
     * mask at INT controller level
106
     */
107
    Regs[INTMASK] |= (long)(1 << irq->name);
108
 
109
    /*
110
     * Disable interrupt on device
111
     */
112
    irq->off(irq);
113
 
114
    /*
115
     * restore the default irq value
116
     */
117
    *(HdlTable + irq->name) = default_int_handler;
118
 
119
    _CPU_ISR_Enable(level);
120
 
121
    return 1;
122
}
123
 
124
 
125
 
126
void _ThreadProcessSignalsFromIrq (CPU_Exception_frame* ctx)
127
{
128
  /*
129
   * Process pending signals that have not already been
130
   * processed by _Thread_Displatch. This happens quite
131
   * unfrequently : the ISR must have posted an action
132
   * to the current running thread.
133
   */
134
  if ( _Thread_Do_post_task_switch_extension ||
135
       _Thread_Executing->do_post_task_switch_extension ) {
136
    _Thread_Executing->do_post_task_switch_extension = FALSE;
137
    _API_extensions_Run_postswitch();
138
  }
139
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.