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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [mips/] [ref4955/] [v2_0/] [include/] [plf_intr.h] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_HAL_PLF_INTR_H
2
#define CYGONCE_HAL_PLF_INTR_H
3
 
4
//==========================================================================
5
//
6
//      plf_intr.h
7
//
8
//      REF4955 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 Red Hat, 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 version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
// for more details.
24
//
25
// You should have received a copy of the GNU General Public License along
26
// with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28
//
29
// As a special exception, if other files instantiate templates or use macros
30
// or inline functions from this file, or you compile this file and link it
31
// with other works to produce a work based on this file, this file does not
32
// by itself cause the resulting work to be covered by the GNU General Public
33
// License. However the source code for this file must still be made available
34
// in accordance with section (3) of the GNU General Public License.
35
//
36
// This exception does not invalidate any other reasons why a work based on
37
// this file might be covered by the GNU General Public License.
38
//
39
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40
// at http://sources.redhat.com/ecos/ecos-license/
41
// -------------------------------------------
42
//####ECOSGPLCOPYRIGHTEND####
43
//==========================================================================
44
//#####DESCRIPTIONBEGIN####
45
//
46
// Author(s):    jskov
47
// Contributors: jskov, nickg
48
// Date:         2000-05-09
49
// Purpose:      Define Interrupt support
50
// Description:  The macros defined here provide the HAL APIs for handling
51
//               interrupts and the clock for the REF4955 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 vectors.
68
 
69
#ifndef CYGHWR_HAL_INTERRUPT_VECTORS_DEFINED
70
 
71
 
72
// The first 6 correspond to the interrupt lines in the status/cause regs
73
#define CYGNUM_HAL_INTERRUPT_V320USC_INT0       0
74
#define CYGNUM_HAL_INTERRUPT_V320USC_INT1       1
75
#define CYGNUM_HAL_INTERRUPT_EXT                2
76
#define CYGNUM_HAL_INTERRUPT_LAN                3
77
#define CYGNUM_HAL_INTERRUPT_IO                 4
78
#define CYGNUM_HAL_INTERRUPT_COMPARE            5
79
 
80
 
81
#if defined(CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN)
82
 
83
// This overlaps with LB_MBI below but it doesn't matter. It's only used
84
// by the HAL to access the special chaining entry in the ISR tables.
85
// All other attempted access to the ISR table will be redirected to this
86
// entry (curtsey of HAL_TRANSLATE_VECTOR). The other vector definitions
87
// are still valid, but only for enable/disable/config etc. (i.e., in
88
// chaining mode they have associated entries in the ISR tables).
89
#define CYGNUM_HAL_INTERRUPT_CHAINING           6
90
 
91
#define HAL_TRANSLATE_VECTOR(_vector_,_index_) \
92
    (_index_) = CYGNUM_HAL_INTERRUPT_CHAINING
93
 
94
#endif
95
 
96
 
97
// The next 32 correspond to the interrupt lines in the V320USC's interrupt
98
// controller. These are decoded from the controller when an interrupt
99
// enters via CYGNUM_HAL_INTERRUPT_V320USC_INT0.
100
#define CYGNUM_HAL_INTERRUPT_INTC_V320USC_base  6 
101
#define CYGNUM_HAL_INTERRUPT_LB_MBI             6 
102
#define CYGNUM_HAL_INTERRUPT_PCI_MBI            7 
103
#define CYGNUM_HAL_INTERRUPT_RESERVED_2         8 
104
#define CYGNUM_HAL_INTERRUPT_I2O_OP_NE          9 
105
#define CYGNUM_HAL_INTERRUPT_I2O_IF_NF          10
106
#define CYGNUM_HAL_INTERRUPT_I2O_IP_NE          11
107
#define CYGNUM_HAL_INTERRUPT_I2O_OP_NF          12
108
#define CYGNUM_HAL_INTERRUPT_I2O_OF_NE          13
109
#define CYGNUM_HAL_INTERRUPT_RESERVED_8         14
110
#define CYGNUM_HAL_INTERRUPT_RESERVED_9         15
111
#define CYGNUM_HAL_INTERRUPT_RESERVED_10        16
112
#define CYGNUM_HAL_INTERRUPT_RESERVED_11        17
113
#define CYGNUM_HAL_INTERRUPT_TIMER0             18
114
#define CYGNUM_HAL_INTERRUPT_TIMER1             19
115
#define CYGNUM_HAL_INTERRUPT_RESERVED_14        20     
116
#define CYGNUM_HAL_INTERRUPT_ENUM               21
117
#define CYGNUM_HAL_INTERRUPT_DMA0               22
118
#define CYGNUM_HAL_INTERRUPT_DMA1               23
119
#define CYGNUM_HAL_INTERRUPT_RESERVED_18        24
120
#define CYGNUM_HAL_INTERRUPT_RESERVED_19        25
121
#define CYGNUM_HAL_INTERRUPT_PWR_STATE          26
122
#define CYGNUM_HAL_INTERRUPT_HBI                27
123
#define CYGNUM_HAL_INTERRUPT_WDI                28
124
#define CYGNUM_HAL_INTERRUPT_BWI                29
125
#define CYGNUM_HAL_INTERRUPT_PSLAVE_PI          30
126
#define CYGNUM_HAL_INTERRUPT_PMASTER_PI         31
127
#define CYGNUM_HAL_INTERRUPT_PCI_T_ABORT        32
128
#define CYGNUM_HAL_INTERRUPT_PCI_M_ABORT        33
129
#define CYGNUM_HAL_INTERRUPT_DRAM_PI            34
130
#define CYGNUM_HAL_INTERRUPT_RESERVED_29        35
131
#define CYGNUM_HAL_INTERRUPT_DI0                36
132
#define CYGNUM_HAL_INTERRUPT_DI1                37
133
 
134
// The next 6 correspond to the interrupt lines specific to the PCI
135
// connector (decoded from CYGNUM_HAL_INTERRUPT_V320USC_INT1)
136
#define CYGNUM_HAL_INTERRUPT_INTC_PCI_base      38
137
#define CYGNUM_HAL_INTERRUPT_SERR               38
138
#define CYGNUM_HAL_INTERRUPT_PERR               39
139
#define CYGNUM_HAL_INTERRUPT_INTD               40
140
#define CYGNUM_HAL_INTERRUPT_INTC               41
141
#define CYGNUM_HAL_INTERRUPT_INTB               42
142
#define CYGNUM_HAL_INTERRUPT_INTA               43
143
 
144
// The next 5 correspond to the interrupt lines specific to the REF4955
145
// board (decoded from CYGNUM_HAL_INTERRUPT_IO)
146
#define CYGNUM_HAL_INTERRUPT_INTC_IO_base       44
147
#define CYGNUM_HAL_INTERRUPT_SOFTWARE           44
148
#define CYGNUM_HAL_INTERRUPT_INT_SWITCH         45
149
#define CYGNUM_HAL_INTERRUPT_PARALLEL           46
150
#define CYGNUM_HAL_INTERRUPT_DEBUG_UART         47
151
#define CYGNUM_HAL_INTERRUPT_USER_UART          48
152
 
153
 
154
// Min/Max ISR numbers and how many there are
155
#define CYGNUM_HAL_ISR_MIN                     CYGNUM_HAL_INTERRUPT_V320USC_INT0
156
#define CYGNUM_HAL_ISR_MAX                     CYGNUM_HAL_INTERRUPT_USER_UART
157
#define CYGNUM_HAL_ISR_COUNT                   (CYGNUM_HAL_ISR_MAX - CYGNUM_HAL_ISR_MIN + 1)
158
 
159
// The vector used by the Real time clock
160
#define CYGNUM_HAL_INTERRUPT_RTC            CYGNUM_HAL_INTERRUPT_COMPARE
161
 
162
#define CYGHWR_HAL_INTERRUPT_VECTORS_DEFINED
163
 
164
#endif
165
 
166
//--------------------------------------------------------------------------
167
// Interrupt controler information
168
 
169
// V320USC 
170
#define CYGARC_REG_INT_STAT   0xb80000ec
171
 
172
#define CYGARC_REG_INT_CFG0   0xb80000e0
173
#define CYGARC_REG_INT_CFG1   0xb80000e4
174
#define CYGARC_REG_INT_CFG2   0xb80000e8
175
#define CYGARC_REG_INT_CFG3   0xb8000158
176
 
177
#define CYGARC_REG_INT_CFG_INT0 0x00000100
178
#define CYGARC_REG_INT_CFG_INT1 0x00000200
179
#define CYGARC_REG_INT_CFG_INT2 0x00000400
180
#define CYGARC_REG_INT_CFG_INT3 0x00000800
181
 
182
 
183
// FPGA
184
#define CYGARC_REG_PCI_STAT   0xb5300000
185
#define CYGARC_REG_PCI_MASK   0xb5300030
186
 
187
#define CYGARC_REG_IO_STAT    0xb5300010
188
#define CYGARC_REG_IO_MASK    0xb5300040
189
 
190
 
191
#define HAL_INTERRUPT_MASK( _vector_ )                                      \
192
    CYG_MACRO_START                                                         \
193
    if( (_vector_) <= CYGNUM_HAL_INTERRUPT_COMPARE )                        \
194
    {                                                                       \
195
        asm volatile (                                                      \
196
            "mfc0   $3,$12\n"                                               \
197
            "la     $2,0x00000400\n"                                        \
198
            "sllv   $2,$2,%0\n"                                             \
199
            "nor    $2,$2,$0\n"                                             \
200
            "and    $3,$3,$2\n"                                             \
201
            "mtc0   $3,$12\n"                                               \
202
            "nop; nop; nop\n"                                               \
203
            :                                                               \
204
            : "r"(_vector_)                                                 \
205
            : "$2", "$3"                                                    \
206
            );                                                              \
207
    }                                                                       \
208
    else if ((_vector_) >= CYGNUM_HAL_INTERRUPT_INTC_IO_base)               \
209
    {                                                                       \
210
        cyg_uint8 _mask_;                                                   \
211
        cyg_uint32 _shift_ = (_vector_)-CYGNUM_HAL_INTERRUPT_INTC_IO_base;  \
212
        HAL_READ_UINT8(CYGARC_REG_IO_MASK, _mask_ );                        \
213
        _mask_ &= ~(1<<_shift_);                                            \
214
        HAL_WRITE_UINT8(CYGARC_REG_IO_MASK, _mask_ );                       \
215
    }                                                                       \
216
    else if (_vector_ >= CYGNUM_HAL_INTERRUPT_INTC_PCI_base)                \
217
    {                                                                       \
218
        cyg_uint8 _mask_;                                                   \
219
        cyg_uint32 _shift_ = (_vector_)-CYGNUM_HAL_INTERRUPT_INTC_PCI_base; \
220
        HAL_READ_UINT8(CYGARC_REG_PCI_MASK, _mask_ );                       \
221
        _mask_ &= ~(1<<_shift_);                                            \
222
        HAL_WRITE_UINT8(CYGARC_REG_PCI_MASK, _mask_ );                      \
223
    } else { /* V320USC */                                                  \
224
        cyg_uint32 _mask_;                                                  \
225
        cyg_uint32 _shift_ =                                                \
226
            (_vector_)-CYGNUM_HAL_INTERRUPT_INTC_V320USC_base;              \
227
        HAL_READ_UINT32(CYGARC_REG_INT_CFG0, _mask_ );                      \
228
        _mask_ &= !(1<<_shift_);                                            \
229
        HAL_WRITE_UINT32(CYGARC_REG_INT_CFG0, _mask_ );                     \
230
    }                                                                       \
231
    CYG_MACRO_END
232
 
233
#define HAL_INTERRUPT_UNMASK( _vector_ )                                    \
234
    CYG_MACRO_START                                                         \
235
    if( (_vector_) <= CYGNUM_HAL_INTERRUPT_COMPARE )                        \
236
    {                                                                       \
237
        asm volatile (                                                      \
238
            "mfc0   $3,$12\n"                                               \
239
            "la     $2,0x00000400\n"                                        \
240
            "sllv   $2,$2,%0\n"                                             \
241
            "or     $3,$3,$2\n"                                             \
242
            "mtc0   $3,$12\n"                                               \
243
            "nop; nop; nop\n"                                               \
244
            :                                                               \
245
            : "r"(_vector_)                                                 \
246
            : "$2", "$3"                                                    \
247
            );                                                              \
248
    }                                                                       \
249
    else if ((_vector_) >= CYGNUM_HAL_INTERRUPT_INTC_IO_base)               \
250
    {                                                                       \
251
        cyg_uint8 _mask_;                                                   \
252
        cyg_uint32 _shift_ = (_vector_)-CYGNUM_HAL_INTERRUPT_INTC_IO_base;  \
253
        HAL_READ_UINT8(CYGARC_REG_IO_MASK, _mask_ );                        \
254
        _mask_ |= (1<<_shift_);                                             \
255
        HAL_WRITE_UINT8(CYGARC_REG_IO_MASK, _mask_ );                       \
256
    }                                                                       \
257
    else if (_vector_ >= CYGNUM_HAL_INTERRUPT_INTC_PCI_base)                \
258
    {                                                                       \
259
        cyg_uint8 _mask_;                                                   \
260
        cyg_uint32 _shift_ = (_vector_)-CYGNUM_HAL_INTERRUPT_INTC_PCI_base; \
261
        HAL_READ_UINT8(CYGARC_REG_PCI_MASK, _mask_ );                       \
262
        _mask_ |= (1<<_shift_);                                             \
263
        HAL_WRITE_UINT8(CYGARC_REG_PCI_MASK, _mask_ );                      \
264
    } else { /* V320USC */                                                  \
265
        cyg_uint32 _mask_;                                                  \
266
        cyg_uint32 _shift_ =                                                \
267
            (_vector_)-CYGNUM_HAL_INTERRUPT_INTC_V320USC_base;              \
268
        HAL_READ_UINT32(CYGARC_REG_INT_CFG0, _mask_ );                      \
269
        _mask_ |= (1<<_shift_);                                             \
270
        HAL_WRITE_UINT32(CYGARC_REG_INT_CFG0, _mask_ );                     \
271
    }                                                                       \
272
    CYG_MACRO_END
273
 
274
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )                           \
275
    CYG_MACRO_START                                                     \
276
    cyg_uint32 _srvector_ = _vector_;                                   \
277
    if ((_vector_) >= CYGNUM_HAL_INTERRUPT_INTC_IO_base) {              \
278
        _srvector_ = CYGNUM_HAL_INTERRUPT_IO;                           \
279
    } else if (_vector_ >= CYGNUM_HAL_INTERRUPT_INTC_PCI_base) {        \
280
        _srvector_ = CYGNUM_HAL_INTERRUPT_V320USC_INT1;                 \
281
    } else if (_vector_ >= CYGNUM_HAL_INTERRUPT_INTC_V320USC_base) {    \
282
        cyg_uint32 _mask_;                                              \
283
        cyg_uint32 _shift_ =                                            \
284
            (_vector_)-CYGNUM_HAL_INTERRUPT_INTC_V320USC_base;          \
285
        _mask_ = (1<<_shift_);                                          \
286
        HAL_WRITE_UINT32(CYGARC_REG_INT_STAT, _mask_ );                 \
287
        _srvector_ = CYGNUM_HAL_INTERRUPT_V320USC_INT0;                 \
288
    }                                                                   \
289
    asm volatile (                                                      \
290
        "mfc0   $3,$13\n"                                               \
291
        "la     $2,0x00000400\n"                                        \
292
        "sllv   $2,$2,%0\n"                                             \
293
        "nor    $2,$2,$0\n"                                             \
294
        "and    $3,$3,$2\n"                                             \
295
        "mtc0   $3,$13\n"                                               \
296
        "nop; nop; nop\n"                                               \
297
        :                                                               \
298
        : "r"(_srvector_)                                               \
299
        : "$2", "$3"                                                    \
300
        );                                                              \
301
    CYG_MACRO_END
302
 
303
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ )
304
 
305
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )
306
 
307
#define CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
308
 
309
 
310
//----------------------------------------------------------------------------
311
// Reset.
312
#define CYGARC_REG_BOARD_RESET 0xb5400000
313
 
314
#define HAL_PLATFORM_RESET() HAL_WRITE_UINT8(CYGARC_REG_BOARD_RESET,0)
315
 
316
#define HAL_PLATFORM_RESET_ENTRY 0xbfc00000
317
 
318
//--------------------------------------------------------------------------
319
#endif // ifndef CYGONCE_HAL_PLF_INTR_H
320
// 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.