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

Subversion Repositories openrisc

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

Go to most recent revision | 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
//      Malta 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, dmoseley
48
// Date:         2001-03-20
49
// Purpose:      Define Interrupt support
50
// Description:  The macros defined here provide the HAL APIs for handling
51
//               interrupts and the clock for the Malta 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
// First an assembly safe part
65
 
66
//--------------------------------------------------------------------------
67
// Interrupt vectors.
68
 
69
#ifndef CYGHWR_HAL_INTERRUPT_VECTORS_DEFINED
70
 
71
// These are decoded via the IP bits of the cause
72
// register when an external interrupt is delivered.
73
 
74
#define CYGNUM_HAL_INTERRUPT_SOUTH_BRIDGE_INTR   0
75
#define CYGNUM_HAL_INTERRUPT_SOUTH_BRIDGE_SMI    1
76
#define CYGNUM_HAL_INTERRUPT_CBUS_UART           2
77
#define CYGNUM_HAL_INTERRUPT_COREHI              3
78
#define CYGNUM_HAL_INTERRUPT_CORELO              4
79
#define CYGNUM_HAL_INTERRUPT_COMPARE             5
80
 
81
#define CYGNUM_HAL_INTERRUPT_EXTERNAL_BASE       6
82
 
83
#define CYGNUM_HAL_INTERRUPT_CTRL1_BASE          6
84
#define CYGNUM_HAL_INTERRUPT_TIMER               6
85
#define CYGNUM_HAL_INTERRUPT_KEYBOARD            7
86
#define CYGNUM_HAL_INTERRUPT_CASCADE             8 // this is where int ctrl2 is cascaded
87
#define CYGNUM_HAL_INTERRUPT_TTY1                9
88
#define CYGNUM_HAL_INTERRUPT_TTY0               10
89
#define CYGNUM_HAL_INTERRUPT_11                 11
90
#define CYGNUM_HAL_INTERRUPT_FLOPPY             12
91
#define CYGNUM_HAL_INTERRUPT_PARALLEL           13
92
 
93
#define CYGNUM_HAL_INTERRUPT_CTRL2_BASE         14
94
#define CYGNUM_HAL_INTERRUPT_REAL_TIME_CLOCK    14
95
#define CYGNUM_HAL_INTERRUPT_I2C                15
96
#define CYGNUM_HAL_INTERRUPT_PCI_AB             16
97
#define CYGNUM_HAL_INTERRUPT_PCI_CD             17
98
#define CYGNUM_HAL_INTERRUPT_MOUSE              18
99
#define CYGNUM_HAL_INTERRUPT_19                 19
100
#define CYGNUM_HAL_INTERRUPT_IDE_PRIMARY        20
101
#define CYGNUM_HAL_INTERRUPT_IDE_SECONDARY      21
102
 
103
#if defined(CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN)
104
 
105
// This overlaps with CYGNUM_HAL_INTERRUPT_EXTERNAL_BASE above but it
106
// doesn't matter. It's only used by the HAL to access the special
107
// chaining entry in the ISR tables.  All other attempted access to
108
// the ISR table will be redirected to this entry (courtesy of
109
// HAL_TRANSLATE_VECTOR). The other vector definitions are still
110
// valid, but only for enable/disable/config etc. (i.e., in chaining
111
// mode they have associated entries in the ISR tables).
112
#define CYGNUM_HAL_INTERRUPT_CHAINING           6
113
 
114
#define HAL_TRANSLATE_VECTOR(_vector_,_index_) \
115
    (_index_) = CYGNUM_HAL_INTERRUPT_CHAINING
116
 
117
// Min/Max ISR numbers
118
#define CYGNUM_HAL_ISR_MIN                 0
119
#define CYGNUM_HAL_ISR_MAX                 CYGNUM_HAL_INTERRUPT_CHAINING
120
 
121
#else
122
 
123
// Min/Max ISR numbers
124
#define CYGNUM_HAL_ISR_MIN                 0
125
#define CYGNUM_HAL_ISR_MAX                 CYGNUM_HAL_INTERRUPT_IDE_SECONDARY
126
#endif // CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
127
 
128
#define CYGNUM_HAL_ISR_COUNT               (CYGNUM_HAL_ISR_MAX - CYGNUM_HAL_ISR_MIN + 1)
129
 
130
// The vector used by the Real time clock
131
#define CYGNUM_HAL_INTERRUPT_RTC           CYGNUM_HAL_INTERRUPT_COMPARE
132
 
133
#define CYGHWR_HAL_INTERRUPT_VECTORS_DEFINED
134
 
135
#endif
136
 
137
 
138
//--------------------------------------------------------------------------
139
#ifndef __ASSEMBLER__
140
 
141
#include <cyg/infra/cyg_type.h>
142
#include <cyg/hal/plf_io.h>
143
 
144
//--------------------------------------------------------------------------
145
// Interrupt controller access.
146
 
147
#ifndef CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
148
 
149
// Array which stores the configured priority levels for the configured
150
// interrupts.
151
externC volatile CYG_BYTE hal_interrupt_level[CYGNUM_HAL_ISR_COUNT];
152
 
153
#define HAL_INTERRUPT_MASK( _vector_ )                       \
154
    CYG_MACRO_START                                                         \
155
    if( (_vector_) <= CYGNUM_HAL_INTERRUPT_COMPARE )                        \
156
    {                                                                       \
157
        asm volatile (                                                      \
158
            "mfc0   $3,$12\n"                                               \
159
            "la     $2,0x00000400\n"                                        \
160
            "sllv   $2,$2,%0\n"                                             \
161
            "nor    $2,$2,$0\n"                                             \
162
            "and    $3,$3,$2\n"                                             \
163
            "mtc0   $3,$12\n"                                               \
164
            "nop; nop; nop\n"                                               \
165
            :                                                               \
166
            : "r"(_vector_)                                                 \
167
            : "$2", "$3"                                                    \
168
            );                                                              \
169
    }                                                                       \
170
    else if ((_vector_) >= CYGNUM_HAL_INTERRUPT_CTRL2_BASE)                 \
171
    {                                                                       \
172
        cyg_uint8 _mask_;                                                   \
173
        cyg_uint32 _shift_ = (_vector_)-CYGNUM_HAL_INTERRUPT_CTRL2_BASE;    \
174
        HAL_READ_UINT8(HAL_PIIX4_SLAVE_OCW1, _mask_ );                      \
175
        _mask_ |= (1<<_shift_);                                             \
176
        HAL_WRITE_UINT8(HAL_PIIX4_SLAVE_OCW1, _mask_ );                     \
177
    }                                                                       \
178
    else /* CTRL1 */                                                        \
179
    {                                                                       \
180
        cyg_uint8 _mask_;                                                   \
181
        cyg_uint32 _shift_ = (_vector_)-CYGNUM_HAL_INTERRUPT_CTRL1_BASE;    \
182
        HAL_READ_UINT8(HAL_PIIX4_MASTER_OCW1, _mask_ );                     \
183
        _mask_ |= (1<<_shift_);                                             \
184
        HAL_WRITE_UINT8(HAL_PIIX4_MASTER_OCW1, _mask_ );                    \
185
    }                                                                       \
186
    CYG_MACRO_END
187
 
188
#define HAL_INTERRUPT_UNMASK( _vector_ )                     \
189
    CYG_MACRO_START                                                         \
190
    if( (_vector_) <= CYGNUM_HAL_INTERRUPT_COMPARE )                        \
191
    {                                                                       \
192
        asm volatile (                                                      \
193
            "mfc0   $3,$12\n"                                               \
194
            "la     $2,0x00000400\n"                                        \
195
            "sllv   $2,$2,%0\n"                                             \
196
            "or     $3,$3,$2\n"                                             \
197
            "mtc0   $3,$12\n"                                               \
198
            "nop; nop; nop\n"                                               \
199
            :                                                               \
200
            : "r"(_vector_)                                                 \
201
            : "$2", "$3"                                                    \
202
            );                                                              \
203
    }                                                                       \
204
    else if ((_vector_) >= CYGNUM_HAL_INTERRUPT_CTRL2_BASE)                 \
205
    {                                                                       \
206
        cyg_uint8 _mask_;                                                   \
207
        cyg_uint32 _shift_ = (_vector_)-CYGNUM_HAL_INTERRUPT_CTRL2_BASE;    \
208
        HAL_READ_UINT8(HAL_PIIX4_SLAVE_OCW1, _mask_ );                      \
209
        _mask_ &= ~(1<<_shift_);                                            \
210
        HAL_WRITE_UINT8(HAL_PIIX4_SLAVE_OCW1, _mask_ );                     \
211
    }                                                                       \
212
    else /* CTRL1 */                                                        \
213
    {                                                                       \
214
        cyg_uint8 _mask_;                                                   \
215
        cyg_uint32 _shift_ = (_vector_)-CYGNUM_HAL_INTERRUPT_CTRL1_BASE;    \
216
        HAL_READ_UINT8(HAL_PIIX4_MASTER_OCW1, _mask_ );                     \
217
        _mask_ &= ~(1<<_shift_);                                            \
218
        HAL_WRITE_UINT8(HAL_PIIX4_MASTER_OCW1, _mask_ );                    \
219
    }                                                                       \
220
    CYG_MACRO_END
221
 
222
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )                   \
223
    CYG_MACRO_START                                             \
224
    cyg_uint32 _srvector_ = _vector_;                           \
225
    if ((_vector_) >= CYGNUM_HAL_INTERRUPT_CTRL2_BASE)          \
226
    {                                                           \
227
        HAL_WRITE_UINT8(HAL_PIIX4_SLAVE_OCW3, 0x20 );           \
228
    }                                                           \
229
    if ((_vector_) >= CYGNUM_HAL_INTERRUPT_CTRL1_BASE)          \
230
    {                                                           \
231
        HAL_WRITE_UINT8(HAL_PIIX4_MASTER_OCW3, 0x20 );          \
232
    }                                                           \
233
    if ((_vector_) >= CYGNUM_HAL_INTERRUPT_EXTERNAL_BASE) {     \
234
        _srvector_ = CYGNUM_HAL_INTERRUPT_SOUTH_BRIDGE_INTR;    \
235
    }                                                           \
236
    asm volatile (                                              \
237
        "mfc0   $3,$13\n"                                       \
238
        "la     $2,0x00000400\n"                                \
239
        "sllv   $2,$2,%0\n"                                     \
240
        "nor    $2,$2,$0\n"                                     \
241
        "and    $3,$3,$2\n"                                     \
242
        "mtc0   $3,$13\n"                                       \
243
        "nop; nop; nop\n"                                       \
244
        :                                                       \
245
        : "r"(_srvector_)                                       \
246
        : "$2", "$3"                                            \
247
        );                                                      \
248
    CYG_MACRO_END
249
 
250
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ )                  \
251
    CYG_MACRO_START                                                         \
252
    if ((_vector_) >= CYGNUM_HAL_INTERRUPT_CTRL2_BASE)                      \
253
    {                                                                       \
254
        cyg_uint8 _mask_;                                                   \
255
        cyg_uint32 _shift_ = (_vector_)-CYGNUM_HAL_INTERRUPT_CTRL2_BASE;    \
256
        HAL_READ_UINT8(HAL_PIIX4_ELCR2, _mask_ );                           \
257
        _mask_ &= ~(1<<_shift_);                                            \
258
        if (_level_) _mask_ |= (1<<_shift_);                                \
259
        _mask_ &= HAL_PIIX4_ELCR2_MASK;                                     \
260
        HAL_WRITE_UINT8(HAL_PIIX4_ELCR2, _mask_ );                          \
261
    }                                                                       \
262
    else if ((_vector_) >= CYGNUM_HAL_INTERRUPT_CTRL1_BASE)                 \
263
    {                                                                       \
264
        cyg_uint8 _mask_;                                                   \
265
        cyg_uint32 _shift_ = (_vector_)-CYGNUM_HAL_INTERRUPT_CTRL1_BASE;    \
266
        HAL_READ_UINT8(HAL_PIIX4_ELCR1, _mask_ );                           \
267
        _mask_ &= ~(1<<_shift_);                                            \
268
        if (_level_) _mask_ |= (1<<_shift_);                                \
269
        _mask_ &= HAL_PIIX4_ELCR1_MASK;                                     \
270
        HAL_WRITE_UINT8(HAL_PIIX4_ELCR1, _mask_ );                          \
271
    }                                                                       \
272
    CYG_MACRO_END
273
 
274
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )
275
 
276
#define CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
277
 
278
#endif
279
 
280
 
281
//--------------------------------------------------------------------------
282
// Control-C support.
283
 
284
#if defined(CYGDBG_HAL_MIPS_DEBUG_GDB_CTRLC_SUPPORT)
285
 
286
# define CYGHWR_HAL_GDB_PORT_VECTOR CYGNUM_HAL_INTERRUPT_SER
287
 
288
externC cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
289
 
290
# define HAL_CTRLC_ISR hal_ctrlc_isr
291
 
292
#endif
293
 
294
 
295
//----------------------------------------------------------------------------
296
// Reset.
297
#ifndef CYGHWR_HAL_RESET_DEFINED
298
extern void hal_malta_reset( void );
299
#define CYGHWR_HAL_RESET_DEFINED
300
#define HAL_PLATFORM_RESET()             hal_malta_reset()
301
 
302
#define HAL_PLATFORM_RESET_ENTRY 0xbfc00000
303
 
304
#endif // CYGHWR_HAL_RESET_DEFINED
305
 
306
#endif // __ASSEMBLER__
307
 
308
//--------------------------------------------------------------------------
309
#endif // ifndef CYGONCE_HAL_PLF_INTR_H
310
// 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.