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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mips/] [idt32334/] [current/] [src/] [var_intr.c] - Blame information for rev 794

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      var_intr.c
4
//
5
//      IDT3233x variant interrupt handlers
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):    tmichals
43
// Contributors: tmichals
44
// Date:         2002-09-20
45
// Purpose:      IDT 3233x variant interrupt handlers
46
// Description:  This file contains code to handle interrupt related issues
47
//               on the idt 3233x variant.
48
//
49
//####DESCRIPTIONEND####
50
//
51
//==========================================================================
52
#include <pkgconf/hal.h>
53
#include <pkgconf/system.h>
54
 
55
#include CYGBLD_HAL_PLATFORM_H
56
#include CYGHWR_MEMORY_LAYOUT_H
57
 
58
#include <cyg/infra/cyg_type.h>         // Base types
59
 
60
#include <cyg/hal/hal_io.h>             // IO macros
61
#include <cyg/hal/hal_stub.h>           // Stub macros
62
#include <cyg/hal/hal_if.h>             // calling interface API
63
#include <cyg/hal/hal_arch.h>           // Register state info
64
#include <cyg/hal/hal_diag.h>
65
#include <cyg/hal/hal_intr.h>           // Interrupt names
66
#include <cyg/hal/hal_cache.h>
67
 
68
/* This is the Reference board configuration */
69
#include <cyg/hal/idt79rc233x.h>
70
 
71
#include <cyg/infra/diag.h>             // diag_printf
72
#include <cyg/hal/drv_api.h>            // CYG_ISR_HANDLED
73
 
74
 
75
typedef cyg_uint32 cyg_ISR(cyg_uint32 vector, CYG_ADDRWORD data);
76
 
77
extern void cyg_interrupt_post_dsr( CYG_ADDRWORD intr_obj );
78
 
79
static inline cyg_uint32
80
hal_call_isr (cyg_uint32 vector)
81
{
82
    cyg_ISR *isr;
83
    CYG_ADDRWORD data;
84
    cyg_uint32 isr_ret;
85
 
86
    isr = (cyg_ISR*) hal_interrupt_handlers[vector];
87
    data = hal_interrupt_data[vector];
88
 
89
    isr_ret = (*isr) (vector, data);
90
 
91
#ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT
92
    if (isr_ret & CYG_ISR_CALL_DSR) {
93
        cyg_interrupt_post_dsr (hal_interrupt_objects[vector]);
94
    }
95
#endif
96
 
97
    return isr_ret & ~CYG_ISR_CALL_DSR;
98
}
99
 
100
/* This is only for expansion interrupts */
101
 
102
void cyg_hal_interrupt_mask ( cyg_uint32 vector )
103
{
104
    cyg_uint32 reg, _old;
105
 
106
    /* done to void race conditions */
107
    HAL_DISABLE_INTERRUPTS(_old);
108
 
109
    switch (vector)
110
        {
111
        case CYGNUM_HAL_INTERRUPT_SIO_0:
112
            HAL_WRITE_UINT32(INTR_COM0_REG, 0);
113
            HAL_READ_UINT32(INTR_MASK_REG, reg);
114
            HAL_WRITE_UINT32(INTR_MASK_REG, (reg & (~(1 << SERIAL_PORT0_GROUP))));
115
            break;
116
 
117
        case CYGNUM_HAL_INTERRUPT_SIO_1:
118
            HAL_WRITE_UINT32(INTR_COM1_REG, 0);
119
            HAL_READ_UINT32(INTR_MASK_REG, reg);
120
            HAL_WRITE_UINT32(INTR_MASK_REG, (reg & (~(1 << SERIAL_PORT1_GROUP))));
121
            break;
122
 
123
        default:
124
            HAL_INTERRUPT_MASK_CPU(vector);
125
        }
126
 
127
    HAL_RESTORE_INTERRUPTS(_old);
128
    return;
129
}
130
 
131
void cyg_hal_interrupt_unmask( cyg_uint32 vector)
132
{
133
    cyg_uint32 reg, _old;
134
 
135
    /* done to void race conditions */
136
    HAL_DISABLE_INTERRUPTS(_old);
137
 
138
    switch (vector)
139
        {
140
        case CYGNUM_HAL_INTERRUPT_SIO_0:
141
            HAL_WRITE_UINT32(INTR_COM0_REG, 1);
142
            HAL_READ_UINT32(INTR_MASK_REG, reg);
143
            HAL_WRITE_UINT32(INTR_MASK_REG, (reg | ((1 << SERIAL_PORT0_GROUP))));
144
            break;
145
 
146
        case CYGNUM_HAL_INTERRUPT_SIO_1:
147
            HAL_WRITE_UINT32(INTR_COM1_REG, 1);
148
            HAL_READ_UINT32(INTR_MASK_REG, reg);
149
            HAL_WRITE_UINT32(INTR_MASK_REG, (reg | ((1 << SERIAL_PORT1_GROUP))));
150
            break;
151
 
152
        default:
153
            HAL_INTERRUPT_UNMASK_CPU(vector);
154
        }
155
 
156
    HAL_RESTORE_INTERRUPTS(_old);
157
    return;
158
}
159
 
160
void cyg_hal_interrupt_acknowledge (cyg_uint32 vector)
161
{
162
    cyg_uint32 reg, _old;
163
 
164
    switch (vector)
165
        {
166
        case CYGNUM_HAL_INTERRUPT_SIO_0:
167
            HAL_WRITE_UINT32(INTR_CLEAR_COM0, 1);
168
            HAL_WRITE_UINT32(INTR_CLEAR_REG, (reg | ((1 << SERIAL_PORT0_GROUP))));
169
            break;
170
 
171
        case CYGNUM_HAL_INTERRUPT_SIO_1:
172
            HAL_WRITE_UINT32(INTR_CLEAR_COM1, 1);
173
            HAL_WRITE_UINT32(INTR_CLEAR_REG, (reg | ((1 << SERIAL_PORT1_GROUP))));
174
            break;
175
 
176
        default:
177
            HAL_INTERRUPT_ACKNOWLEDGE_CPU(vector);
178
        }
179
}
180
 
181
externC cyg_uint32
182
hal_extended_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data)
183
{
184
    cyg_uint32 isrRet;
185
    cyg_uint32 pendingIsr;
186
    cyg_uint32 isrNum;
187
 
188
 
189
    HAL_READ_UINT32 (INTR_STATUS_PTR, pendingIsr);
190
 
191
    // Although we could check 32-bits of the register, according
192
    // to the IDT32334 docs, only bits 1 to 14 are actually used.
193
    for (isrNum=1; isrNum <=14; isrNum++)
194
        if ( (1 << isrNum) & pendingIsr)
195
            break;
196
 
197
    if (pendingIsr) {
198
        isrRet = hal_call_isr (CYGNUM_LAST_IDT_INTERRUPT + isrNum);
199
 
200
        if (isrRet & CYG_ISR_HANDLED)
201
            return isrRet;
202
    }
203
 
204
    return 0;
205
}
206
 
207
externC void
208
hal_variant_IRQ_init(void)
209
{
210
    HAL_INTERRUPT_MASK (CYGNUM_EXPANSION);
211
 
212
    /* clear the mask register */
213
    HAL_WRITE_UINT32(INTR_MASK_REG, 0); /* all expansion interrupts are masked */
214
 
215
    HAL_INTERRUPT_ATTACH (CYGNUM_EXPANSION, &hal_extended_isr, 0, 0);
216
    HAL_INTERRUPT_UNMASK (CYGNUM_EXPANSION);
217
}
218
 
219
externC void
220
hal_IRQ_init(void)
221
{
222
    int i;
223
 
224
    /* yes this is a quick fix; arch.inc should be changed, but this is
225
     * good enough for now */
226
    for (i=0; i <= CYGNUM_HAL_INTERRUPT_5;++i )
227
                HAL_INTERRUPT_MASK (i);
228
 
229
    hal_variant_IRQ_init();
230
}
231
 
232
// EOF var_intr.c

powered by: WebSVN 2.1.0

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