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

Subversion Repositories openrisc_me

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