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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [powerpc/] [ppc40x/] [v2_0/] [src/] [var_intr.c] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      var_intr.c
4
//
5
//      PowerPC 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 Red Hat, 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 version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//==========================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):    jskov
44
// Contributors: jskov, gthomas
45
// Date:         2000-02-11
46
// Purpose:      PowerPC variant interrupt handlers
47
// Description:  This file contains code to handle interrupt related issues
48
//               on the PowerPC variant.
49
//
50
//####DESCRIPTIONEND####
51
//
52
//==========================================================================
53
 
54
#include <pkgconf/hal.h>
55
#define CYGARC_HAL_COMMON_EXPORT_CPU_MACROS
56
#include <cyg/hal/ppc_regs.h>
57
#include <cyg/hal/hal_intr.h>
58
#include <cyg/infra/cyg_type.h>
59
 
60
extern void hal_platform_IRQ_init(void);
61
 
62
 
63
static cyg_uint32 exier_mask[] = {
64
    0x00000000, // Unused
65
    0x00000000, // Unused
66
    0x80000000, // CYGNUM_HAL_INTERRUPT_CRITICAL         2
67
    0x08000000, // CYGNUM_HAL_INTERRUPT_SERIAL_RCV       3
68
    0x04000000, // CYGNUM_HAL_INTERRUPT_SERIAL_XMT       4
69
    0x02000000, // CYGNUM_HAL_INTERRUPT_JTAG_RCV         5
70
    0x01000000, // CYGNUM_HAL_INTERRUPT_JTAG_XMT         6
71
    0x00800000, // CYGNUM_HAL_INTERRUPT_DMA0             7
72
    0x00400000, // CYGNUM_HAL_INTERRUPT_DMA1             8
73
    0x00200000, // CYGNUM_HAL_INTERRUPT_DMA2             9
74
    0x00100000, // CYGNUM_HAL_INTERRUPT_DMA3            10
75
    0x00000010, // CYGNUM_HAL_INTERRUPT_EXT0            11
76
    0x00000008, // CYGNUM_HAL_INTERRUPT_EXT1            12
77
    0x00000004, // CYGNUM_HAL_INTERRUPT_EXT2            13
78
    0x00000002, // CYGNUM_HAL_INTERRUPT_EXT3            14
79
    0x00000001, // CYGNUM_HAL_INTERRUPT_EXT4            15
80
};
81
 
82
// This table inverts bit number to signal number
83
cyg_uint32 EXISR_TAB[] = {
84
    CYGNUM_HAL_INTERRUPT_CRITICAL,     // 0x80000000
85
    0x00000000,                        // 0x40000000
86
    0x00000000,                        // 0x20000000
87
    0x00000000,                        // 0x10000000
88
    CYGNUM_HAL_INTERRUPT_SERIAL_RCV,   // 0x08000000
89
    CYGNUM_HAL_INTERRUPT_SERIAL_XMT,   // 0x04000000
90
    CYGNUM_HAL_INTERRUPT_JTAG_RCV,     // 0x02000000
91
    CYGNUM_HAL_INTERRUPT_JTAG_XMT,     // 0x01000000
92
    CYGNUM_HAL_INTERRUPT_DMA0,         // 0x00800000
93
    CYGNUM_HAL_INTERRUPT_DMA1,         // 0x00400000
94
    CYGNUM_HAL_INTERRUPT_DMA2,         // 0x00200000
95
    CYGNUM_HAL_INTERRUPT_DMA3,         // 0x00100000
96
    0x00000000,                        // 0x00080000
97
    0x00000000,                        // 0x00040000
98
    0x00000000,                        // 0x00020000
99
    0x00000000,                        // 0x00010000
100
    0x00000000,                        // 0x00008000
101
    0x00000000,                        // 0x00004000
102
    0x00000000,                        // 0x00002000
103
    0x00000000,                        // 0x00001000
104
    0x00000000,                        // 0x00000800
105
    0x00000000,                        // 0x00000400
106
    0x00000000,                        // 0x00000200
107
    0x00000000,                        // 0x00000100
108
    0x00000000,                        // 0x00000080
109
    0x00000000,                        // 0x00000040
110
    0x00000000,                        // 0x00000020
111
    CYGNUM_HAL_INTERRUPT_EXT0,         // 0x00000010
112
    CYGNUM_HAL_INTERRUPT_EXT1,         // 0x00000008
113
    CYGNUM_HAL_INTERRUPT_EXT2,         // 0x00000004
114
    CYGNUM_HAL_INTERRUPT_EXT3,         // 0x00000002
115
    CYGNUM_HAL_INTERRUPT_EXT4          // 0x00000001
116
};
117
 
118
cyg_uint32 _hold_tcr = 0;  // Shadow of hardware register
119
 
120
externC void
121
hal_variant_IRQ_init(void)
122
{
123
    cyg_uint32 iocr;
124
 
125
    // Ensure all interrupts masked (disabled) & cleared
126
    CYGARC_MTDCR(DCR_EXIER, 0);
127
    CYGARC_MTDCR(DCR_EXISR, 0xFFFFFFFF);
128
 
129
    // Configure all external interrupts to be level/low
130
    CYGARC_MFDCR(DCR_IOCR, iocr);
131
    iocr &= ~0xFFC00000;
132
    CYGARC_MTDCR(DCR_IOCR, iocr);
133
 
134
    // Disable timers
135
    CYGARC_MTSPR(SPR_TCR, 0);
136
 
137
    // Let the platform do any overrides
138
    hal_platform_IRQ_init();
139
}
140
 
141
externC void
142
hal_ppc40x_interrupt_mask(int vector)
143
{
144
    cyg_uint32 exier, tcr;
145
 
146
    switch (vector) {
147
    case CYGNUM_HAL_INTERRUPT_CRITICAL:
148
    case CYGNUM_HAL_INTERRUPT_SERIAL_RCV:
149
    case CYGNUM_HAL_INTERRUPT_SERIAL_XMT:
150
    case CYGNUM_HAL_INTERRUPT_JTAG_RCV:
151
    case CYGNUM_HAL_INTERRUPT_JTAG_XMT:
152
    case CYGNUM_HAL_INTERRUPT_DMA0:
153
    case CYGNUM_HAL_INTERRUPT_DMA1:
154
    case CYGNUM_HAL_INTERRUPT_DMA2:
155
    case CYGNUM_HAL_INTERRUPT_DMA3:
156
    case CYGNUM_HAL_INTERRUPT_EXT0:
157
    case CYGNUM_HAL_INTERRUPT_EXT1:
158
    case CYGNUM_HAL_INTERRUPT_EXT2:
159
    case CYGNUM_HAL_INTERRUPT_EXT3:
160
    case CYGNUM_HAL_INTERRUPT_EXT4:
161
        CYGARC_MFDCR(DCR_EXIER, exier);
162
        exier &= ~exier_mask[vector];
163
        CYGARC_MTDCR(DCR_EXIER, exier);
164
        break;
165
    case CYGNUM_HAL_INTERRUPT_VAR_TIMER:
166
        CYGARC_MFSPR(SPR_TCR, tcr);
167
        tcr = _hold_tcr;
168
        tcr &= ~TCR_PIE;
169
        CYGARC_MTSPR(SPR_TCR, tcr);
170
        _hold_tcr = tcr;
171
        break;
172
    case CYGNUM_HAL_INTERRUPT_FIXED_TIMER:
173
        CYGARC_MFSPR(SPR_TCR, tcr);
174
        tcr = _hold_tcr;
175
        tcr &= ~TCR_FIE;
176
        CYGARC_MTSPR(SPR_TCR, tcr);
177
        _hold_tcr = tcr;
178
        break;
179
    case CYGNUM_HAL_INTERRUPT_WATCHDOG_TIMER:
180
        CYGARC_MFSPR(SPR_TCR, tcr);
181
        tcr = _hold_tcr;
182
        tcr &= ~TCR_WIE;
183
        CYGARC_MTSPR(SPR_TCR, tcr);
184
        _hold_tcr = tcr;
185
        break;
186
    default:
187
    }
188
}
189
 
190
externC void
191
hal_ppc40x_interrupt_unmask(int vector)
192
{
193
    cyg_uint32 exier, tcr;
194
 
195
    switch (vector) {
196
    case CYGNUM_HAL_INTERRUPT_CRITICAL:
197
    case CYGNUM_HAL_INTERRUPT_SERIAL_RCV:
198
    case CYGNUM_HAL_INTERRUPT_SERIAL_XMT:
199
    case CYGNUM_HAL_INTERRUPT_JTAG_RCV:
200
    case CYGNUM_HAL_INTERRUPT_JTAG_XMT:
201
    case CYGNUM_HAL_INTERRUPT_DMA0:
202
    case CYGNUM_HAL_INTERRUPT_DMA1:
203
    case CYGNUM_HAL_INTERRUPT_DMA2:
204
    case CYGNUM_HAL_INTERRUPT_DMA3:
205
    case CYGNUM_HAL_INTERRUPT_EXT0:
206
    case CYGNUM_HAL_INTERRUPT_EXT1:
207
    case CYGNUM_HAL_INTERRUPT_EXT2:
208
    case CYGNUM_HAL_INTERRUPT_EXT3:
209
    case CYGNUM_HAL_INTERRUPT_EXT4:
210
        CYGARC_MFDCR(DCR_EXIER, exier);
211
        exier |= exier_mask[vector];
212
        CYGARC_MTDCR(DCR_EXIER, exier);
213
        break;
214
    case CYGNUM_HAL_INTERRUPT_VAR_TIMER:
215
        CYGARC_MFSPR(SPR_TCR, tcr);
216
        tcr = _hold_tcr;
217
        tcr |= TCR_PIE;
218
        CYGARC_MTSPR(SPR_TCR, tcr);
219
        _hold_tcr = tcr;
220
        break;
221
    case CYGNUM_HAL_INTERRUPT_FIXED_TIMER:
222
        CYGARC_MFSPR(SPR_TCR, tcr);
223
        tcr = _hold_tcr;
224
        tcr |= TCR_FIE;
225
        CYGARC_MTSPR(SPR_TCR, tcr);
226
        _hold_tcr = tcr;
227
        break;
228
    case CYGNUM_HAL_INTERRUPT_WATCHDOG_TIMER:
229
        CYGARC_MFSPR(SPR_TCR, tcr);
230
        tcr = _hold_tcr;
231
        tcr |= TCR_WIE;
232
        CYGARC_MTSPR(SPR_TCR, tcr);
233
        _hold_tcr = tcr;
234
        break;
235
    default:
236
    }
237
}
238
 
239
externC void
240
hal_ppc40x_interrupt_acknowledge(int vector)
241
{
242
    switch (vector) {
243
    case CYGNUM_HAL_INTERRUPT_EXT0:
244
    case CYGNUM_HAL_INTERRUPT_EXT1:
245
    case CYGNUM_HAL_INTERRUPT_EXT2:
246
    case CYGNUM_HAL_INTERRUPT_EXT3:
247
    case CYGNUM_HAL_INTERRUPT_EXT4:
248
        CYGARC_MTDCR(DCR_EXISR, exier_mask[vector]);
249
        break;
250
    case CYGNUM_HAL_INTERRUPT_VAR_TIMER:
251
        CYGARC_MTSPR(SPR_TSR, TSR_PIS);  // clear & acknowledge interrupt
252
        break;
253
    case CYGNUM_HAL_INTERRUPT_FIXED_TIMER:
254
        CYGARC_MTSPR(SPR_TSR, TSR_FIS);  // clear & acknowledge interrupt
255
        break;
256
    case CYGNUM_HAL_INTERRUPT_WATCHDOG_TIMER:
257
        CYGARC_MTSPR(SPR_TSR, TSR_WIS);  // clear & acknowledge interrupt
258
        break;
259
    case CYGNUM_HAL_INTERRUPT_CRITICAL:
260
    case CYGNUM_HAL_INTERRUPT_SERIAL_RCV:
261
    case CYGNUM_HAL_INTERRUPT_SERIAL_XMT:
262
    case CYGNUM_HAL_INTERRUPT_JTAG_RCV:
263
    case CYGNUM_HAL_INTERRUPT_JTAG_XMT:
264
    case CYGNUM_HAL_INTERRUPT_DMA0:
265
    case CYGNUM_HAL_INTERRUPT_DMA1:
266
    case CYGNUM_HAL_INTERRUPT_DMA2:
267
    case CYGNUM_HAL_INTERRUPT_DMA3:
268
    default:
269
    }
270
}
271
 
272
// Note: These functions are only [well] defined for "external" interrupts
273
// which can be controlled via the EXIER register.
274
externC void
275
hal_ppc40x_interrupt_configure(int vector, int level, int dir)
276
{
277
    cyg_uint32 mask, new_state, iocr;
278
 
279
    if ((vector >= CYGNUM_HAL_INTERRUPT_EXT0) &&
280
        (vector <= CYGNUM_HAL_INTERRUPT_EXT4)) {
281
        mask = 0x03 << (30 - ((vector - CYGNUM_HAL_INTERRUPT_EXT0)*2));
282
        new_state = (dir & 0x01);  // Up/Down    
283
        if (level == 0) {
284
            // Edge triggered
285
            new_state = 0x02;
286
        }
287
        new_state <<= (30 - ((vector - CYGNUM_HAL_INTERRUPT_EXT0)*2));
288
        CYGARC_MFDCR(DCR_IOCR, iocr);
289
        iocr = (iocr & ~mask) | new_state;
290
        CYGARC_MTDCR(DCR_IOCR, iocr);
291
    }
292
}
293
 
294
externC void
295
hal_ppc40x_interrupt_set_level(int vector, int level)
296
{
297
}
298
 
299
// -------------------------------------------------------------------------
300
// EOF var_intr.c

powered by: WebSVN 2.1.0

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