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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mips/] [vrc437x/] [current/] [include/] [plf_intr.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_HAL_PLF_INTR_H
2
#define CYGONCE_HAL_PLF_INTR_H
3
 
4
//==========================================================================
5
//
6
//      plf_intr.h
7
//
8
//      VRC437X Interrupt and clock support
9
//
10
//==========================================================================
11
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
12
// -------------------------------------------                              
13
// This file is part of eCos, the Embedded Configurable Operating System.   
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under    
17
// the terms of the GNU General Public License as published by the Free     
18
// Software Foundation; either version 2 or (at your option) any later      
19
// version.                                                                 
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT      
22
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
24
// for more details.                                                        
25
//
26
// You should have received a copy of the GNU General Public License        
27
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
28
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
29
//
30
// As a special exception, if other files instantiate templates or use      
31
// macros or inline functions from this file, or you compile this file      
32
// and link it with other works to produce a work based on this file,       
33
// this file does not by itself cause the resulting work to be covered by   
34
// the GNU General Public License. However the source code for this file    
35
// must still be made available in accordance with section (3) of the GNU   
36
// General Public License v2.                                               
37
//
38
// This exception does not invalidate any other reasons why a work based    
39
// on this file might be covered by the GNU General Public License.         
40
// -------------------------------------------                              
41
// ####ECOSGPLCOPYRIGHTEND####                                              
42
//==========================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):    nickg
46
// Contributors: nickg, jskov,
47
//               gthomas, jlarmour
48
// Date:         1999-02-16
49
// Purpose:      Define Interrupt support
50
// Description:  The macros defined here provide the HAL APIs for handling
51
//               interrupts and the clock for the VRC437X board.
52
//              
53
// Usage:
54
//              #include <cyg/hal/plf_intr.h>
55
//              ...
56
//              
57
//
58
//####DESCRIPTIONEND####
59
//
60
//==========================================================================
61
 
62
#include <pkgconf/hal.h>
63
 
64
#include <cyg/infra/cyg_type.h>
65
 
66
//--------------------------------------------------------------------------
67
// Interrupt controller stuff.
68
 
69
// The first 6 correspond to the interrupt lines in the status/cause regs
70
#define CYGNUM_HAL_INTERRUPT_VRC437X            0
71
#define CYGNUM_HAL_INTERRUPT_IPL0               1
72
#define CYGNUM_HAL_INTERRUPT_IPL1               2
73
#define CYGNUM_HAL_INTERRUPT_IPL2               3
74
#define CYGNUM_HAL_INTERRUPT_POWER              4
75
#define CYGNUM_HAL_INTERRUPT_COMPARE            5
76
// The next 32 correspond to the interrupt lines in the 4372 interrupt
77
// controller. These are decoded from the controller when an interrupt
78
// on any of the IPL[0:2] lines in signalled.
79
#define CYGNUM_HAL_INTERRUPT_REALTIME_A         6
80
#define CYGNUM_HAL_INTERRUPT_REALTIME_B         7
81
#define CYGNUM_HAL_INTERRUPT_DUART              8
82
#define CYGNUM_HAL_INTERRUPT_TIMER              9
83
#define CYGNUM_HAL_INTERRUPT_PARALLEL           10
84
#define CYGNUM_HAL_INTERRUPT_PCI_INTA           11
85
#define CYGNUM_HAL_INTERRUPT_PCI_INTB           12
86
#define CYGNUM_HAL_INTERRUPT_PCI_INTC           13
87
#define CYGNUM_HAL_INTERRUPT_PCI_INTD           14
88
#define CYGNUM_HAL_INTERRUPT_INT_9              15
89
#define CYGNUM_HAL_INTERRUPT_INT_10             16
90
#define CYGNUM_HAL_INTERRUPT_INT_11             17
91
#define CYGNUM_HAL_INTERRUPT_INT_12             18
92
#define CYGNUM_HAL_INTERRUPT_INT_13             19
93
#define CYGNUM_HAL_INTERRUPT_DMA_0              20
94
#define CYGNUM_HAL_INTERRUPT_DMA_1              21
95
#define CYGNUM_HAL_INTERRUPT_DMA_2              22
96
#define CYGNUM_HAL_INTERRUPT_DMA_3              23
97
#define CYGNUM_HAL_INTERRUPT_TICK_0             24
98
#define CYGNUM_HAL_INTERRUPT_TICK_1             25
99
#define CYGNUM_HAL_INTERRUPT_UNUSED_20          26
100
#define CYGNUM_HAL_INTERRUPT_UNUSED_21          27
101
#define CYGNUM_HAL_INTERRUPT_IO_TIMEOUT         28
102
#define CYGNUM_HAL_INTERRUPT_PCI_PERR           29
103
#define CYGNUM_HAL_INTERRUPT_PCI_SERR           30
104
#define CYGNUM_HAL_INTERRUPT_PCI_SIG_TA         31
105
#define CYGNUM_HAL_INTERRUPT_PCI_REC_TA         32
106
#define CYGNUM_HAL_INTERRUPT_PCI_SIG_MA         33
107
#define CYGNUM_HAL_INTERRUPT_PCI_ADD            34
108
#define CYGNUM_HAL_INTERRUPT_PCI_RET_ERR        35
109
#define CYGNUM_HAL_INTERRUPT_UNUSED_30          36
110
#define CYGNUM_HAL_INTERRUPT_UNUSED_31          37
111
 
112
// Min/Max ISR numbers and how many there are
113
#define CYGNUM_HAL_ISR_MIN                     0
114
#define CYGNUM_HAL_ISR_MAX                     37
115
#define CYGNUM_HAL_ISR_COUNT                   38
116
 
117
// The vector used by the Real time clock. The default here is to use
118
// interrupt 5, which is connected to the counter/comparator registers
119
// in many MIPS variants.
120
 
121
#ifndef CYGNUM_HAL_INTERRUPT_RTC
122
#define CYGNUM_HAL_INTERRUPT_RTC            CYGNUM_HAL_INTERRUPT_COMPARE
123
#endif
124
 
125
#define CYGHWR_HAL_INTERRUPT_VECTORS_DEFINED
126
 
127
//--------------------------------------------------------------------------
128
// Vector translation.
129
// For chained interrupts we only have a single vector though which all
130
// are passed. For unchained interrupts we have a vector per interrupt.
131
// Vector 0 has a special catcher ISR for spurious interrupts from the VRC437X
132
// and vectors 1-3 are springboards, so we chain through vector 4.
133
 
134
#if defined(CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN)
135
 
136
#define HAL_TRANSLATE_VECTOR(_vector_,_index_)  \
137
{                                               \
138
    if ((_vector_)==0)                          \
139
        (_index_) = 0;                          \
140
    else                                        \
141
        (_index_) = 4;                          \
142
}
143
#endif
144
 
145
//--------------------------------------------------------------------------
146
// controller access code
147
 
148
#define CYGHWR_HAL_MIPS_VRC4372_BASE            0xbc000000
149
#define CYGHWR_HAL_MIPS_VRC4372_INTC_POL        (CYGHWR_HAL_MIPS_VRC4372_BASE+0x200)
150
#define CYGHWR_HAL_MIPS_VRC4372_INTC_TRIG       (CYGHWR_HAL_MIPS_VRC4372_BASE+0x204)
151
#define CYGHWR_HAL_MIPS_VRC4372_INTC_PINS       (CYGHWR_HAL_MIPS_VRC4372_BASE+0x208)
152
#define CYGHWR_HAL_MIPS_VRC4372_INTC_MASK0      (CYGHWR_HAL_MIPS_VRC4372_BASE+0x20c)
153
#define CYGHWR_HAL_MIPS_VRC4372_INTC_STAT0      (CYGHWR_HAL_MIPS_VRC4372_BASE+0x210)
154
#define CYGHWR_HAL_MIPS_VRC4372_INTC_MASK1      (CYGHWR_HAL_MIPS_VRC4372_BASE+0x214)
155
#define CYGHWR_HAL_MIPS_VRC4372_INTC_STAT1      (CYGHWR_HAL_MIPS_VRC4372_BASE+0x218)
156
#define CYGHWR_HAL_MIPS_VRC4372_INTC_MASK2      (CYGHWR_HAL_MIPS_VRC4372_BASE+0x21c)
157
#define CYGHWR_HAL_MIPS_VRC4372_INTC_STAT2      (CYGHWR_HAL_MIPS_VRC4372_BASE+0x220)
158
 
159
#define CYGHWR_HAL_MIPS_VRC4372_INTC_MASK_OFF   8
160
 
161
// Array which stores the configured priority levels for the configured
162
// interrupts.
163
externC volatile CYG_BYTE cyg_hal_interrupt_level[CYGNUM_HAL_ISR_COUNT];
164
 
165
#define HAL_INTERRUPT_MASK( _vector_ )                                          \
166
CYG_MACRO_START                                                                 \
167
    if( _vector_ <= CYGNUM_HAL_INTERRUPT_COMPARE )                              \
168
    {                                                                           \
169
        asm volatile (                                                          \
170
            "mfc0   $3,$12\n"                                                   \
171
            "la     $2,0x00000400\n"                                            \
172
            "sllv   $2,$2,%0\n"                                                 \
173
            "nor    $2,$2,$0\n"                                                 \
174
            "and    $3,$3,$2\n"                                                 \
175
            "mtc0   $3,$12\n"                                                   \
176
            "nop; nop; nop\n"                                                   \
177
            :                                                                   \
178
            : "r"(_vector_)                                                     \
179
            : "$2", "$3"                                                        \
180
            );                                                                  \
181
    }                                                                           \
182
    else                                                                        \
183
    {                                                                           \
184
        CYG_WORD32 _mask_;                                                      \
185
        CYG_BYTE _shift_;                                                       \
186
        HAL_IO_REGISTER _maskreg_ = CYGHWR_HAL_MIPS_VRC4372_INTC_MASK0 +        \
187
                                    cyg_hal_interrupt_level[_vector_] *         \
188
                                    CYGHWR_HAL_MIPS_VRC4372_INTC_MASK_OFF;      \
189
        HAL_READ_UINT32( _maskreg_, _mask_ );                                   \
190
        _shift_ = _vector_-CYGNUM_HAL_INTERRUPT_REALTIME_A;                     \
191
        _mask_ &= ~(1<<_shift_);                                                \
192
        HAL_WRITE_UINT32( _maskreg_, _mask_ );                                  \
193
    }                                                                           \
194
CYG_MACRO_END
195
 
196
#define HAL_INTERRUPT_UNMASK( _vector_ )                                        \
197
CYG_MACRO_START                                                                 \
198
    if( _vector_ <= CYGNUM_HAL_INTERRUPT_COMPARE )                              \
199
    {                                                                           \
200
        asm volatile (                                                          \
201
            "mfc0   $3,$12\n"                                                   \
202
            "la     $2,0x00000400\n"                                            \
203
            "sllv   $2,$2,%0\n"                                                 \
204
            "or     $3,$3,$2\n"                                                 \
205
            "mtc0   $3,$12\n"                                                   \
206
            "nop; nop; nop\n"                                                   \
207
            :                                                                   \
208
            : "r"(_vector_)                                                     \
209
            : "$2", "$3"                                                        \
210
            );                                                                  \
211
    }                                                                           \
212
    else                                                                        \
213
    {                                                                           \
214
        CYG_WORD32 _mask_;                                                      \
215
        CYG_BYTE _shift_;                                                       \
216
        HAL_IO_REGISTER _maskreg_ = CYGHWR_HAL_MIPS_VRC4372_INTC_MASK0 +        \
217
                                    cyg_hal_interrupt_level[_vector_] *         \
218
                                    CYGHWR_HAL_MIPS_VRC4372_INTC_MASK_OFF;      \
219
        HAL_READ_UINT32( _maskreg_, _mask_ );                                   \
220
        _shift_ = _vector_-CYGNUM_HAL_INTERRUPT_REALTIME_A;                     \
221
        _mask_ |= 1<<_shift_;                                                   \
222
        HAL_WRITE_UINT32( _maskreg_, _mask_ );                                  \
223
    }                                                                           \
224
CYG_MACRO_END
225
 
226
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )                           \
227
CYG_MACRO_START                                                         \
228
    CYG_WORD32 _srvector_ = _vector_;                                   \
229
    if( _vector_ > CYGNUM_HAL_INTERRUPT_COMPARE )                       \
230
    {                                                                   \
231
        CYG_WORD32 _stat_;                                              \
232
        CYG_BYTE _shift_;                                               \
233
        HAL_IO_REGISTER _statreg_ = CYGHWR_HAL_MIPS_VRC4372_INTC_STAT0 +\
234
            cyg_hal_interrupt_level[_vector_] *                         \
235
            CYGHWR_HAL_MIPS_VRC4372_INTC_MASK_OFF;                      \
236
        HAL_READ_UINT32( _statreg_, _stat_ );                           \
237
        _shift_ = _vector_-CYGNUM_HAL_INTERRUPT_REALTIME_A;             \
238
        _stat_ &= ~(1<<_shift_);                                        \
239
        HAL_WRITE_UINT32( _statreg_, _stat_ );                          \
240
        _srvector_ = cyg_hal_interrupt_level[_vector_] +                \
241
            CYGNUM_HAL_INTERRUPT_IPL0;                                  \
242
    }                                                                   \
243
    asm volatile (                                                      \
244
        "mfc0   $3,$13\n"                                               \
245
        "la     $2,0x00000400\n"                                        \
246
        "sllv   $2,$2,%0\n"                                             \
247
        "nor    $2,$2,$0\n"                                             \
248
        "and    $3,$3,$2\n"                                             \
249
        "mtc0   $3,$13\n"                                               \
250
        "nop; nop; nop\n"                                               \
251
        :                                                               \
252
        : "r"(_srvector_)                                               \
253
        : "$2", "$3"                                                    \
254
        );                                                              \
255
CYG_MACRO_END
256
 
257
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ )                      \
258
CYG_MACRO_START                                                                 \
259
    if( (_vector_ >= CYGNUM_HAL_INTERRUPT_REALTIME_A) &&                        \
260
        (_vector_ <= CYGNUM_HAL_INTERRUPT_INT_13))                              \
261
    {                                                                           \
262
        CYG_WORD32 mask = 1<<(_vector_-CYGNUM_HAL_INTERRUPT_REALTIME_A);        \
263
        CYG_WORD32 pol;                                                         \
264
        CYG_WORD32 trig;                                                        \
265
        HAL_READ_UINT32( CYGHWR_HAL_MIPS_VRC4372_INTC_POL, pol );               \
266
        HAL_READ_UINT32( CYGHWR_HAL_MIPS_VRC4372_INTC_TRIG, trig );             \
267
        if( _level_ )                                                           \
268
        {                                                                       \
269
            pol &= ~mask;                                                       \
270
            if( _up_ ) trig |= mask;                                            \
271
            else trig &= ~mask;                                                 \
272
        }                                                                       \
273
        else                                                                    \
274
        {                                                                       \
275
            pol |= mask;                                                        \
276
            if( !(_up_) ) trig |= mask;                                         \
277
            else trig &= ~mask;                                                 \
278
        }                                                                       \
279
        HAL_WRITE_UINT32( CYGHWR_HAL_MIPS_VRC4372_INTC_POL, pol );              \
280
        HAL_WRITE_UINT32( CYGHWR_HAL_MIPS_VRC4372_INTC_TRIG, trig );            \
281
    }                                                                           \
282
CYG_MACRO_END
283
 
284
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )    \
285
CYG_MACRO_START                                         \
286
    if( _vector_ > CYGNUM_HAL_INTERRUPT_COMPARE )       \
287
    {                                                   \
288
        cyg_uint32 _ilevel_ = _level_;                  \
289
        while( _ilevel_ > 2 ) _ilevel_ -= 2;            \
290
        cyg_hal_interrupt_level[_vector_] = _ilevel_;   \
291
    }                                                   \
292
CYG_MACRO_END
293
 
294
#define CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
295
 
296
//--------------------------------------------------------------------------
297
// Control-C support.
298
 
299
#if defined(CYGDBG_HAL_MIPS_DEBUG_GDB_CTRLC_SUPPORT)
300
 
301
# define CYGHWR_HAL_GDB_PORT_VECTOR CYGNUM_HAL_INTERRUPT_DUART
302
 
303
externC cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
304
 
305
#define HAL_CTRLC_ISR hal_ctrlc_isr
306
 
307
#endif
308
 
309
//----------------------------------------------------------------------------
310
// Reset.
311
 
312
#define HAL_PLATFORM_RESET()            CYG_EMPTY_STATEMENT
313
 
314
#define HAL_PLATFORM_RESET_ENTRY        0xbfc00000
315
 
316
//--------------------------------------------------------------------------
317
#endif // ifndef CYGONCE_HAL_PLF_INTR_H
318
// End of plf_intr.h

powered by: WebSVN 2.1.0

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