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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [powerpc/] [mpc8xx/] [current/] [include/] [var_intr.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_VAR_INTR_H
2
#define CYGONCE_VAR_INTR_H
3
//=============================================================================
4
//
5
//      var_intr.h
6
//
7
//      Variant HAL interrupt and clock support
8
//
9
//=============================================================================
10
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
11
// -------------------------------------------                              
12
// This file is part of eCos, the Embedded Configurable Operating System.   
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under    
16
// the terms of the GNU General Public License as published by the Free     
17
// Software Foundation; either version 2 or (at your option) any later      
18
// version.                                                                 
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT      
21
// ANY 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        
26
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
27
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
28
//
29
// As a special exception, if other files instantiate templates or use      
30
// macros or inline functions from this file, or you compile this file      
31
// and link it with other works to produce a work based on this file,       
32
// this file does not by itself cause the resulting work to be covered by   
33
// the GNU General Public License. However the source code for this file    
34
// must still be made available in accordance with section (3) of the GNU   
35
// General Public License v2.                                               
36
//
37
// This exception does not invalidate any other reasons why a work based    
38
// on this file might be covered by the GNU General Public License.         
39
// -------------------------------------------                              
40
// ####ECOSGPLCOPYRIGHTEND####                                              
41
//=============================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):   nickg
45
// Contributors:nickg, jskov, jlarmour, hmt, gthomas
46
// Date:        2000-04-02
47
// Purpose:     Variant interrupt support
48
// Description: The macros defined here provide the HAL APIs for handling
49
//              interrupts and the clock on the MPC8xx variant CPUs.
50
// Usage:       Is included via the architecture interrupt header:
51
//              #include <cyg/hal/hal_intr.h>
52
//              ...
53
//
54
//####DESCRIPTIONEND####
55
//
56
//=============================================================================
57
 
58
#include <pkgconf/hal.h>
59
 
60
#include <cyg/hal/plf_intr.h>
61
 
62
#include <cyg/infra/cyg_type.h>         // types
63
 
64
#include <cyg/hal/ppc_regs.h>           // register definitions
65
 
66
#include <cyg/hal/hal_io.h>             // io macros
67
#include <cyg/infra/cyg_ass.h>          // CYG_FAIL
68
 
69
//-----------------------------------------------------------------------------
70
// Exception vectors.
71
 
72
// Additional exceptions on the MPC8xx CPUs
73
#define CYGNUM_HAL_VECTOR_RESERVED_F         15
74
#define CYGNUM_HAL_VECTOR_SW_EMUL            16
75
#define CYGNUM_HAL_VECTOR_ITLB_MISS          17
76
#define CYGNUM_HAL_VECTOR_DTLB_MISS          18
77
#define CYGNUM_HAL_VECTOR_ITLB_ERROR         19
78
#define CYGNUM_HAL_VECTOR_DTLB_ERROR         20
79
#define CYGNUM_HAL_VECTOR_RESERVED_15        21
80
#define CYGNUM_HAL_VECTOR_RESERVED_16        22
81
#define CYGNUM_HAL_VECTOR_RESERVED_17        23
82
#define CYGNUM_HAL_VECTOR_RESERVED_18        24
83
#define CYGNUM_HAL_VECTOR_RESERVED_19        25
84
#define CYGNUM_HAL_VECTOR_RESERVED_1A        26
85
#define CYGNUM_HAL_VECTOR_RESERVED_1B        27
86
#define CYGNUM_HAL_VECTOR_DATA_BP            28
87
#define CYGNUM_HAL_VECTOR_INSTRUCTION_BP     29
88
#define CYGNUM_HAL_VECTOR_PERIPHERAL_BP      30
89
#define CYGNUM_HAL_VECTOR_NMI                31
90
 
91
#define CYGNUM_HAL_VSR_MAX                   CYGNUM_HAL_VECTOR_NMI
92
 
93
// These are the values used when passed out to an
94
// external exception handler using cyg_hal_deliver_exception()
95
 
96
#define CYGNUM_HAL_EXCEPTION_RESERVED_0      CYGNUM_HAL_VECTOR_RESERVED_0
97
#define CYGNUM_HAL_EXCEPTION_MACHINE_CHECK   CYGNUM_HAL_VECTOR_MACHINE_CHECK
98
#ifdef CYGHWR_HAL_POWERPC_MPC8XX
99
// The MPC860 does not generate DSI and ISI: instead it goes to machine
100
// check, so that a software VM system can then call into vectors 0x300 or
101
// 0x400 if the address is truly invalid rather than merely not in the TLB
102
// right now.  Shades of IBM wanting to port OS/MVS here!
103
// See pp 7-9/10 in "PowerQUICC - MPC860 User's Manual"
104
# undef CYGNUM_HAL_EXCEPTION_DATA_ACCESS
105
# define CYGNUM_HAL_EXCEPTION_DATA_ACCESS    CYGNUM_HAL_VECTOR_MACHINE_CHECK
106
// do not define catchers for DSI and ISI - should never happen.
107
# undef CYGNUM_HAL_EXCEPTION_MACHINE_CHECK
108
# undef CYGNUM_HAL_EXCEPTION_CODE_ACCESS
109
#else
110
# define CYGNUM_HAL_EXCEPTION_DATA_ACCESS    CYGNUM_HAL_VECTOR_DSI
111
# define CYGNUM_HAL_EXCEPTION_CODE_ACCESS    CYGNUM_HAL_VECTOR_ISI
112
#endif
113
#define CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS  \
114
           CYGNUM_HAL_VECTOR_ALIGNMENT
115
#define CYGNUM_HAL_EXCEPTION_FPU_NOT_AVAIL   CYGNUM_HAL_VECTOR_FP_UNAVAILABLE
116
#define CYGNUM_HAL_EXCEPTION_RESERVED_A      CYGNUM_HAL_VECTOR_RESERVED_A
117
#define CYGNUM_HAL_EXCEPTION_RESERVED_B      CYGNUM_HAL_VECTOR_RESERVED_B
118
#define CYGNUM_HAL_EXCEPTION_SYSTEM_CALL     CYGNUM_HAL_VECTOR_SYSTEM_CALL
119
#define CYGNUM_HAL_EXCEPTION_TRACE           CYGNUM_HAL_VECTOR_TRACE
120
#define CYGNUM_HAL_EXCEPTION_FP_ASSIST       CYGNUM_HAL_VECTOR_FP_ASSIST
121
#define CYGNUM_HAL_EXCEPTION_RESERVED_F      CYGNUM_HAL_VECTOR_RESERVED_F
122
#define CYGNUM_HAL_EXCEPTION_SW_EMUL         CYGNUM_HAL_VECTOR_SW_EMUL
123
#define CYGNUM_HAL_EXCEPTION_CODE_TLBMISS_ACCESS  CYGNUM_HAL_VECTOR_ITLB_MISS
124
#define CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_ACCESS  CYGNUM_HAL_VECTOR_DTLB_MISS
125
#define CYGNUM_HAL_EXCEPTION_CODE_TLBERROR_ACCESS \
126
               CYGNUM_HAL_VECTOR_ITLB_ERROR
127
#define CYGNUM_HAL_EXCEPTION_DATA_TLBERROR_ACCESS \
128
           CYGNUM_HAL_VECTOR_DTLB_ERROR
129
#define CYGNUM_HAL_EXCEPTION_RESERVED_15     CYGNUM_HAL_VECTOR_RESERVED_15
130
#define CYGNUM_HAL_EXCEPTION_RESERVED_16     CYGNUM_HAL_VECTOR_RESERVED_16
131
#define CYGNUM_HAL_EXCEPTION_RESERVED_17     CYGNUM_HAL_VECTOR_RESERVED_17
132
#define CYGNUM_HAL_EXCEPTION_RESERVED_18     CYGNUM_HAL_VECTOR_RESERVED_18
133
#define CYGNUM_HAL_EXCEPTION_RESERVED_19     CYGNUM_HAL_VECTOR_RESERVED_19
134
#define CYGNUM_HAL_EXCEPTION_RESERVED_1A     CYGNUM_HAL_VECTOR_RESERVED_1A
135
#define CYGNUM_HAL_EXCEPTION_RESERVED_1B     CYGNUM_HAL_VECTOR_RESERVED_1B
136
#define CYGNUM_HAL_EXCEPTION_DATA_BP         CYGNUM_HAL_VECTOR_DATA_BP
137
#define CYGNUM_HAL_EXCEPTION_INSTRUCTION_BP  CYGNUM_HAL_VECTOR_INSTRUCTION_BP
138
#define CYGNUM_HAL_EXCEPTION_PERIPHERAL_BP   CYGNUM_HAL_VECTOR_PERIPHERAL_BP
139
#define CYGNUM_HAL_EXCEPTION_NMI             CYGNUM_HAL_VECTOR_NMI
140
 
141
#define CYGNUM_HAL_EXCEPTION_MIN             CYGNUM_HAL_EXCEPTION_RESERVED_0
142
#define CYGNUM_HAL_EXCEPTION_MAX             CYGNUM_HAL_EXCEPTION_NMI
143
 
144
#define CYGHWR_HAL_EXCEPTION_VECTORS_DEFINED
145
 
146
//-----------------------------------------------------------------------------
147
// Interrupts
148
 
149
// The first level of external interrupts
150
#define CYGNUM_HAL_INTERRUPT_SIU_IRQ0            1
151
#define CYGNUM_HAL_INTERRUPT_SIU_LVL0            2
152
#define CYGNUM_HAL_INTERRUPT_SIU_IRQ1            3
153
#define CYGNUM_HAL_INTERRUPT_SIU_LVL1            4
154
#define CYGNUM_HAL_INTERRUPT_SIU_IRQ2            5
155
#define CYGNUM_HAL_INTERRUPT_SIU_LVL2            6
156
#define CYGNUM_HAL_INTERRUPT_SIU_IRQ3            7
157
#define CYGNUM_HAL_INTERRUPT_SIU_LVL3            8
158
#define CYGNUM_HAL_INTERRUPT_SIU_IRQ4            9
159
#define CYGNUM_HAL_INTERRUPT_SIU_LVL4           10
160
#define CYGNUM_HAL_INTERRUPT_SIU_IRQ5           11
161
#define CYGNUM_HAL_INTERRUPT_SIU_LVL5           12
162
#define CYGNUM_HAL_INTERRUPT_SIU_IRQ6           13
163
#define CYGNUM_HAL_INTERRUPT_SIU_LVL6           14
164
#define CYGNUM_HAL_INTERRUPT_SIU_IRQ7           15
165
#define CYGNUM_HAL_INTERRUPT_SIU_LVL7           16
166
 
167
// Further decoded interrups
168
#define CYGNUM_HAL_INTERRUPT_SIU_TB_A           17
169
#define CYGNUM_HAL_INTERRUPT_SIU_TB_B           18
170
#define CYGNUM_HAL_INTERRUPT_SIU_PIT            19
171
#define CYGNUM_HAL_INTERRUPT_SIU_RTC_SEC        20
172
#define CYGNUM_HAL_INTERRUPT_SIU_RTC_ALR        21
173
#define CYGNUM_HAL_INTERRUPT_SIU_PCMCIA_A_IRQ   22
174
#define CYGNUM_HAL_INTERRUPT_SIU_PCMCIA_A_CHLVL 23
175
#define CYGNUM_HAL_INTERRUPT_SIU_PCMCIA_B_IRQ   24
176
#define CYGNUM_HAL_INTERRUPT_SIU_PCMCIA_B_CHLVL 25
177
#define CYGNUM_HAL_INTERRUPT_SIU_CPM            26
178
 
179
// Even further...
180
#define CYGNUM_HAL_INTERRUPT_CPM_PC15           27
181
#define CYGNUM_HAL_INTERRUPT_CPM_SCC1           28
182
#define CYGNUM_HAL_INTERRUPT_CPM_SCC2           29
183
#define CYGNUM_HAL_INTERRUPT_CPM_SCC3           30
184
#define CYGNUM_HAL_INTERRUPT_CPM_SCC4           31
185
#define CYGNUM_HAL_INTERRUPT_CPM_PC14           32
186
#define CYGNUM_HAL_INTERRUPT_CPM_TIMER1         33
187
#define CYGNUM_HAL_INTERRUPT_CPM_PC13           34
188
#define CYGNUM_HAL_INTERRUPT_CPM_PC12           35
189
#define CYGNUM_HAL_INTERRUPT_CPM_SDMA           36
190
#define CYGNUM_HAL_INTERRUPT_CPM_IDMA1          37
191
#define CYGNUM_HAL_INTERRUPT_CPM_IDMA2          38
192
#define CYGNUM_HAL_INTERRUPT_CPM_RESERVED_13    39
193
#define CYGNUM_HAL_INTERRUPT_CPM_TIMER2         40
194
#define CYGNUM_HAL_INTERRUPT_CPM_RISCTT         41
195
#define CYGNUM_HAL_INTERRUPT_CPM_I2C            42
196
#define CYGNUM_HAL_INTERRUPT_CPM_PC11           43
197
#define CYGNUM_HAL_INTERRUPT_CPM_PC10           44
198
#define CYGNUM_HAL_INTERRUPT_CPM_RESERVED_0D    45
199
#define CYGNUM_HAL_INTERRUPT_CPM_TIMER3         46
200
#define CYGNUM_HAL_INTERRUPT_CPM_PC9            47
201
#define CYGNUM_HAL_INTERRUPT_CPM_PC8            48
202
#define CYGNUM_HAL_INTERRUPT_CPM_PC7            49
203
#define CYGNUM_HAL_INTERRUPT_CPM_RESERVED_08    50
204
#define CYGNUM_HAL_INTERRUPT_CPM_TIMER4         51
205
#define CYGNUM_HAL_INTERRUPT_CPM_PC6            52
206
#define CYGNUM_HAL_INTERRUPT_CPM_SPI            53
207
#define CYGNUM_HAL_INTERRUPT_CPM_SMC1           54
208
#define CYGNUM_HAL_INTERRUPT_CPM_SMC2_PIP       55
209
#define CYGNUM_HAL_INTERRUPT_CPM_PC5            56
210
#define CYGNUM_HAL_INTERRUPT_CPM_PC4            57
211
#define CYGNUM_HAL_INTERRUPT_CPM_ERROR          58
212
 
213
#define CYGNUM_HAL_INTERRUPT_CPM_FIRST       CYGNUM_HAL_INTERRUPT_CPM_PC15
214
#define CYGNUM_HAL_INTERRUPT_CPM_LAST        CYGNUM_HAL_INTERRUPT_CPM_ERROR
215
 
216
#define CYGNUM_HAL_ISR_MAX                   CYGNUM_HAL_INTERRUPT_CPM_LAST
217
#endif
218
 
219
 
220
//--------------------------------------------------------------------------
221
// Interrupt controller access
222
 
223
#ifndef CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
224
 
225
#ifdef CYGHWR_HAL_POWERPC_MPC8XX
226
 
227
static __inline__ void
228
cyg_hal_interrupt_mask ( cyg_uint32 vector )
229
{
230
    switch (vector) {
231
    case CYGNUM_HAL_INTERRUPT_SIU_IRQ0 ... CYGNUM_HAL_INTERRUPT_SIU_LVL7:
232
    {
233
        // SIU interrupt vectors
234
        cyg_uint32 simask;
235
 
236
        HAL_READ_UINT32 (CYGARC_REG_IMM_SIMASK, simask);
237
        simask &= ~(((cyg_uint32) CYGARC_REG_IMM_SIMASK_IRQ0)
238
                    >> (vector - CYGNUM_HAL_INTERRUPT_SIU_IRQ0));
239
        HAL_WRITE_UINT32 (CYGARC_REG_IMM_SIMASK, simask);
240
        break;
241
    }
242
    case CYGNUM_HAL_INTERRUPT_SIU_TB_A:
243
    {
244
        // TimeBase A interrupt
245
        cyg_uint16 tbscr;
246
 
247
        HAL_READ_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
248
        tbscr &= ~(CYGARC_REG_IMM_TBSCR_REFAE);
249
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
250
        break;
251
    }
252
    case CYGNUM_HAL_INTERRUPT_SIU_TB_B:
253
    {
254
        // TimeBase B interrupt
255
        cyg_uint16 tbscr;
256
 
257
        HAL_READ_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
258
        tbscr &= ~(CYGARC_REG_IMM_TBSCR_REFBE);
259
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
260
        break;
261
    }
262
    case CYGNUM_HAL_INTERRUPT_SIU_PIT:
263
    {
264
        // Periodic Interrupt
265
        cyg_uint16 piscr;
266
 
267
        HAL_READ_UINT16 (CYGARC_REG_IMM_PISCR, piscr);
268
        piscr &= ~(CYGARC_REG_IMM_PISCR_PIE);
269
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_PISCR, piscr);
270
        break;
271
    }
272
    case CYGNUM_HAL_INTERRUPT_SIU_RTC_SEC:
273
    {
274
        // Real Time Clock Second
275
        cyg_uint16 rtcsc;
276
 
277
        HAL_READ_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
278
        rtcsc &= ~(CYGARC_REG_IMM_RTCSC_SIE);
279
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
280
        break;
281
    }
282
    case CYGNUM_HAL_INTERRUPT_SIU_RTC_ALR:
283
    {
284
        // Real Time Clock Alarm
285
        cyg_uint16 rtcsc;
286
 
287
        HAL_READ_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
288
        rtcsc &= ~(CYGARC_REG_IMM_RTCSC_ALE);
289
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
290
        break;
291
    }
292
    // PCMCIA_A_IRQ
293
    // PCMCIA_A_CHLVL
294
    // PCMCIA_B_IRQ
295
    // PCMCIA_B_CHLVL
296
    case CYGNUM_HAL_INTERRUPT_SIU_CPM:
297
    {
298
        // Communications Processor Module
299
        cyg_uint32 cicr;
300
 
301
        HAL_READ_UINT32 (CYGARC_REG_IMM_CICR, cicr);
302
        cicr &= ~(CYGARC_REG_IMM_CICR_IEN);
303
        HAL_WRITE_UINT32 (CYGARC_REG_IMM_CICR, cicr);
304
        break;
305
    }
306
    case CYGNUM_HAL_INTERRUPT_CPM_FIRST ... CYGNUM_HAL_INTERRUPT_CPM_LAST:
307
    {
308
        // CPM interrupts
309
        cyg_uint32 cimr;
310
 
311
        HAL_READ_UINT32 (CYGARC_REG_IMM_CIMR, cimr);
312
        cimr &= ~(((cyg_uint32) 0x80000000)
313
                  >> (vector - CYGNUM_HAL_INTERRUPT_CPM_FIRST));
314
        HAL_WRITE_UINT32 (CYGARC_REG_IMM_CIMR, cimr);
315
        break;
316
    }
317
    default:
318
        CYG_FAIL("Unknown Interrupt!!!");
319
        break;
320
    }
321
}
322
 
323
static __inline__ void
324
cyg_hal_interrupt_unmask ( cyg_uint32 vector )
325
{
326
    switch (vector) {
327
    case CYGNUM_HAL_INTERRUPT_SIU_IRQ0 ... CYGNUM_HAL_INTERRUPT_SIU_LVL7:
328
    {
329
        // SIU interrupt vectors
330
        cyg_uint32 simask;
331
 
332
        HAL_READ_UINT32 (CYGARC_REG_IMM_SIMASK, simask);
333
        simask |= (((cyg_uint32) CYGARC_REG_IMM_SIMASK_IRQ0)
334
                   >> (vector - CYGNUM_HAL_INTERRUPT_SIU_IRQ0));
335
        HAL_WRITE_UINT32 (CYGARC_REG_IMM_SIMASK, simask);
336
        break;
337
    }
338
    case CYGNUM_HAL_INTERRUPT_SIU_TB_A:
339
    {
340
        // TimeBase A interrupt
341
        cyg_uint16 tbscr;
342
 
343
        HAL_READ_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
344
        tbscr |= CYGARC_REG_IMM_TBSCR_REFAE;
345
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
346
        break;
347
    }
348
    case CYGNUM_HAL_INTERRUPT_SIU_TB_B:
349
    {
350
        // TimeBase B interrupt
351
        cyg_uint16 tbscr;
352
 
353
        HAL_READ_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
354
        tbscr |= CYGARC_REG_IMM_TBSCR_REFBE;
355
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
356
        break;
357
    }
358
    case CYGNUM_HAL_INTERRUPT_SIU_PIT:
359
    {
360
        // Periodic Interrupt
361
        cyg_uint16 piscr;
362
 
363
        HAL_READ_UINT16 (CYGARC_REG_IMM_PISCR, piscr);
364
        piscr |= CYGARC_REG_IMM_PISCR_PIE;
365
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_PISCR, piscr);
366
        break;
367
    }
368
    case CYGNUM_HAL_INTERRUPT_SIU_RTC_SEC:
369
    {
370
        // Real Time Clock Second
371
        cyg_uint16 rtcsc;
372
 
373
        HAL_READ_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
374
        rtcsc |= CYGARC_REG_IMM_RTCSC_SIE;
375
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
376
        break;
377
    }
378
    case CYGNUM_HAL_INTERRUPT_SIU_RTC_ALR:
379
    {
380
        // Real Time Clock Alarm
381
        cyg_uint16 rtcsc;
382
 
383
        HAL_READ_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
384
        rtcsc |= CYGARC_REG_IMM_RTCSC_ALE;
385
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
386
        break;
387
    }
388
    // PCMCIA_A_IRQ
389
    // PCMCIA_A_CHLVL
390
    // PCMCIA_B_IRQ
391
    // PCMCIA_B_CHLVL
392
    case CYGNUM_HAL_INTERRUPT_SIU_CPM:
393
    {
394
        // Communications Processor Module
395
        cyg_uint32 cicr;
396
 
397
        HAL_READ_UINT32 (CYGARC_REG_IMM_CICR, cicr);
398
        cicr |= CYGARC_REG_IMM_CICR_IEN;
399
        HAL_WRITE_UINT32 (CYGARC_REG_IMM_CICR, cicr);
400
        break;
401
    }
402
    case CYGNUM_HAL_INTERRUPT_CPM_FIRST ... CYGNUM_HAL_INTERRUPT_CPM_LAST:
403
    {
404
        // CPM interrupts
405
        cyg_uint32 cimr;
406
 
407
        HAL_READ_UINT32 (CYGARC_REG_IMM_CIMR, cimr);
408
        cimr |= (((cyg_uint32) 0x80000000)
409
                 >> (vector - CYGNUM_HAL_INTERRUPT_CPM_FIRST));
410
        HAL_WRITE_UINT32 (CYGARC_REG_IMM_CIMR, cimr);
411
        break;
412
    }
413
    default:
414
        CYG_FAIL("Unknown Interrupt!!!");
415
        break;
416
    }
417
}
418
 
419
static __inline__ void
420
cyg_hal_interrupt_acknowledge ( cyg_uint32 vector )
421
{
422
    switch (vector) {
423
    case CYGNUM_HAL_INTERRUPT_SIU_IRQ0 ... CYGNUM_HAL_INTERRUPT_SIU_LVL7:
424
    {
425
        // SIU interrupt vectors
426
        cyg_uint32 sipend;
427
 
428
        // When IRQx is configured as an edge interrupt it needs to be
429
        // cleared. Write to INTx and IRQ/level bits are ignore so
430
        // it's safe to do always.
431
        sipend = (((cyg_uint32) CYGARC_REG_IMM_SIPEND_IRQ0)
432
                   >> (vector - CYGNUM_HAL_INTERRUPT_SIU_IRQ0));
433
        HAL_WRITE_UINT32 (CYGARC_REG_IMM_SIPEND, sipend);
434
        break;
435
    }
436
    case CYGNUM_HAL_INTERRUPT_SIU_TB_A:
437
    {
438
        // TimeBase A interrupt
439
        cyg_uint16 tbscr;
440
 
441
        HAL_READ_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
442
        tbscr |= CYGARC_REG_IMM_TBSCR_REFA;
443
        // take care not to accidently reset potential pending REFB
444
        tbscr &= ~CYGARC_REG_IMM_TBSCR_REFB;
445
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
446
        break;
447
    }
448
    case CYGNUM_HAL_INTERRUPT_SIU_TB_B:
449
    {
450
        // TimeBase B interrupt
451
        cyg_uint16 tbscr;
452
 
453
        HAL_READ_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
454
        tbscr |= CYGARC_REG_IMM_TBSCR_REFB;
455
        // take care not to accidently reset potential pending REFA
456
        tbscr &= ~CYGARC_REG_IMM_TBSCR_REFA;
457
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
458
        break;
459
    }
460
    case CYGNUM_HAL_INTERRUPT_SIU_PIT:
461
    {
462
        // Periodic Interrupt
463
        cyg_uint16 piscr;
464
 
465
        HAL_READ_UINT16 (CYGARC_REG_IMM_PISCR, piscr);
466
        piscr |= CYGARC_REG_IMM_PISCR_PS;
467
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_PISCR, piscr);
468
        break;
469
    }
470
    case CYGNUM_HAL_INTERRUPT_SIU_RTC_SEC:
471
    {
472
        // Real Time Clock Second
473
        cyg_uint16 rtcsc;
474
 
475
        HAL_READ_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
476
        rtcsc |= CYGARC_REG_IMM_RTCSC_SEC;
477
        // take care not to accidently reset potential pending RTCSC_ALR
478
        rtcsc &= ~CYGARC_REG_IMM_RTCSC_ALR;
479
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
480
        break;
481
    }
482
    case CYGNUM_HAL_INTERRUPT_SIU_RTC_ALR:
483
    {
484
        // Real Time Clock Alarm
485
        cyg_uint16 rtcsc;
486
 
487
        HAL_READ_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
488
        rtcsc |= CYGARC_REG_IMM_RTCSC_ALR;
489
        // take care not to accidently reset potential pending RTCSC_SEC
490
        rtcsc &= ~CYGARC_REG_IMM_RTCSC_SEC;
491
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
492
        break;
493
    }
494
    // PCMCIA_A_IRQ
495
    // PCMCIA_A_CHLVL
496
    // PCMCIA_B_IRQ
497
    // PCMCIA_B_CHLVL
498
    case CYGNUM_HAL_INTERRUPT_SIU_CPM:
499
        // Communications Processor Module
500
        // The CPM interrupts must be acknowledged individually.
501
        break;
502
    case CYGNUM_HAL_INTERRUPT_CPM_FIRST ... CYGNUM_HAL_INTERRUPT_CPM_LAST:
503
    {
504
        // CPM interrupts
505
        cyg_uint32 cisr;
506
 
507
        cisr = (((cyg_uint32) 0x80000000)
508
                 >> (vector - CYGNUM_HAL_INTERRUPT_CPM_FIRST));
509
        HAL_WRITE_UINT32 (CYGARC_REG_IMM_CISR, cisr);
510
        break;
511
    }
512
    default:
513
        CYG_FAIL("Unknown Interrupt!!!");
514
        break;
515
    }
516
}
517
 
518
static __inline__ void
519
cyg_hal_interrupt_configure ( cyg_uint32 vector,
520
                              cyg_bool level,
521
                              cyg_bool up )
522
{
523
    switch (vector) {
524
    case CYGNUM_HAL_INTERRUPT_SIU_IRQ0:
525
    case CYGNUM_HAL_INTERRUPT_SIU_IRQ1:
526
    case CYGNUM_HAL_INTERRUPT_SIU_IRQ2:
527
    case CYGNUM_HAL_INTERRUPT_SIU_IRQ3:
528
    case CYGNUM_HAL_INTERRUPT_SIU_IRQ4:
529
    case CYGNUM_HAL_INTERRUPT_SIU_IRQ5:
530
    case CYGNUM_HAL_INTERRUPT_SIU_IRQ6:
531
    case CYGNUM_HAL_INTERRUPT_SIU_IRQ7:
532
    {
533
        // External interrupts
534
        cyg_uint32 siel, bit;
535
 
536
        CYG_ASSERT( level || !up, "Only falling edge is supported");
537
 
538
        bit = (((cyg_uint32) CYGARC_REG_IMM_SIEL_IRQ0)
539
               >> (vector - CYGNUM_HAL_INTERRUPT_SIU_IRQ0));
540
 
541
        HAL_READ_UINT32 (CYGARC_REG_IMM_SIEL, siel);
542
        siel &= ~bit;
543
        if (!level) {
544
            // Set edge detect bit.
545
            siel |= bit;
546
        }
547
        HAL_WRITE_UINT32 (CYGARC_REG_IMM_SIEL, siel);
548
        break;
549
    }
550
    case CYGNUM_HAL_INTERRUPT_SIU_LVL0:
551
    case CYGNUM_HAL_INTERRUPT_SIU_LVL1:
552
    case CYGNUM_HAL_INTERRUPT_SIU_LVL2:
553
    case CYGNUM_HAL_INTERRUPT_SIU_LVL3:
554
    case CYGNUM_HAL_INTERRUPT_SIU_LVL4:
555
    case CYGNUM_HAL_INTERRUPT_SIU_LVL5:
556
    case CYGNUM_HAL_INTERRUPT_SIU_LVL6:
557
    case CYGNUM_HAL_INTERRUPT_SIU_LVL7:
558
    case CYGNUM_HAL_INTERRUPT_SIU_TB_A:
559
    case CYGNUM_HAL_INTERRUPT_SIU_TB_B:
560
    case CYGNUM_HAL_INTERRUPT_SIU_PIT:
561
    case CYGNUM_HAL_INTERRUPT_SIU_RTC_SEC:
562
    case CYGNUM_HAL_INTERRUPT_SIU_RTC_ALR:
563
    // PCMCIA_A_IRQ
564
    // PCMCIA_A_CHLVL
565
    // PCMCIA_B_IRQ
566
    // PCMCIA_B_CHLVL
567
    case CYGNUM_HAL_INTERRUPT_SIU_CPM:
568
    case CYGNUM_HAL_INTERRUPT_CPM_FIRST ... CYGNUM_HAL_INTERRUPT_CPM_LAST:
569
        // These cannot be configured.
570
        break;
571
 
572
    default:
573
        CYG_FAIL("Unknown Interrupt!!!");
574
        break;
575
    }
576
}
577
 
578
static __inline__ void
579
cyg_hal_interrupt_set_level ( cyg_uint32 vector, cyg_uint32 level )
580
{
581
    // Note: highest priority has the lowest numerical value.
582
    CYG_ASSERT( level >= CYGARC_SIU_PRIORITY_HIGH, "Invalid priority");
583
    CYG_ASSERT( level <= CYGARC_SIU_PRIORITY_LOW, "Invalid priority");
584
 
585
    switch (vector) {
586
    case CYGNUM_HAL_INTERRUPT_SIU_IRQ0 ... CYGNUM_HAL_INTERRUPT_SIU_LVL7:
587
        // These cannot be configured.
588
        break;
589
    case CYGNUM_HAL_INTERRUPT_SIU_TB_A:
590
    case CYGNUM_HAL_INTERRUPT_SIU_TB_B:
591
    {
592
        // TimeBase A+B interrupt
593
        cyg_uint16 tbscr;
594
 
595
        HAL_READ_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
596
        tbscr &= ~(CYGARC_REG_IMM_TBSCR_IRQMASK);
597
        tbscr |= CYGARC_REG_IMM_TBSCR_IRQ0 >> level;
598
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_TBSCR, tbscr);
599
        break;
600
    }
601
    case CYGNUM_HAL_INTERRUPT_SIU_PIT:
602
    {
603
        // Periodic Interrupt
604
        cyg_uint16 piscr;
605
 
606
        HAL_READ_UINT16 (CYGARC_REG_IMM_PISCR, piscr);
607
        piscr &= ~(CYGARC_REG_IMM_PISCR_IRQMASK);
608
        piscr |= CYGARC_REG_IMM_PISCR_IRQ0 >> level;
609
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_PISCR, piscr);
610
        break;
611
    }
612
    case CYGNUM_HAL_INTERRUPT_SIU_RTC_SEC:
613
    case CYGNUM_HAL_INTERRUPT_SIU_RTC_ALR:
614
    {
615
        // Real Time Clock Second & Real Time Clock Alarm
616
        cyg_uint16 rtcsc;
617
 
618
        HAL_READ_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
619
        rtcsc &= ~(CYGARC_REG_IMM_RTCSC_IRQMASK);
620
        rtcsc |= CYGARC_REG_IMM_RTCSC_IRQ0 >> level;
621
        HAL_WRITE_UINT16 (CYGARC_REG_IMM_RTCSC, rtcsc);
622
        break;
623
    }
624
    // PCMCIA_A_IRQ
625
    // PCMCIA_A_CHLVL
626
    // PCMCIA_B_IRQ
627
    // PCMCIA_B_CHLVL
628
    case CYGNUM_HAL_INTERRUPT_SIU_CPM:
629
    {
630
        // Communications Processor Module
631
        cyg_uint32 cicr;
632
 
633
        HAL_READ_UINT32 (CYGARC_REG_IMM_CICR, cicr);
634
        cicr &= ~(CYGARC_REG_IMM_CICR_IRQMASK);
635
        cicr |= level << CYGARC_REG_IMM_CICR_IRQ_SHIFT;
636
        HAL_WRITE_UINT32 (CYGARC_REG_IMM_CICR, cicr);
637
        break;
638
    }
639
    case CYGNUM_HAL_INTERRUPT_CPM_FIRST ... CYGNUM_HAL_INTERRUPT_CPM_LAST:
640
        // CPM interrupt levels are for internal priority. All interrupts
641
        // fed to the CPU use the CPM level set above.
642
        // FIXME: Control of SCdP ordering.
643
        break;
644
    default:
645
        CYG_FAIL("Unknown Interrupt!!!");
646
        break;
647
    }
648
}
649
 
650
// The decrementer interrupt cannnot be masked, configured or acknowledged.
651
 
652
#define HAL_INTERRUPT_MASK( _vector_ )                    \
653
    CYG_MACRO_START                                       \
654
    if (CYGNUM_HAL_INTERRUPT_DECREMENTER != (_vector_))   \
655
        cyg_hal_interrupt_mask ( (_vector_) );            \
656
    CYG_MACRO_END
657
 
658
#define HAL_INTERRUPT_UNMASK( _vector_ )                  \
659
    CYG_MACRO_START                                       \
660
    if (CYGNUM_HAL_INTERRUPT_DECREMENTER != (_vector_))   \
661
        cyg_hal_interrupt_unmask ( (_vector_) );          \
662
    CYG_MACRO_END
663
 
664
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )             \
665
    CYG_MACRO_START                                       \
666
    if (CYGNUM_HAL_INTERRUPT_DECREMENTER != (_vector_))   \
667
        cyg_hal_interrupt_acknowledge ( (_vector_) );     \
668
    CYG_MACRO_END
669
 
670
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ )              \
671
    CYG_MACRO_START                                                     \
672
    if (CYGNUM_HAL_INTERRUPT_DECREMENTER != (_vector_))                 \
673
        cyg_hal_interrupt_configure ( (_vector_), (_level_), (_up_) );  \
674
    CYG_MACRO_END
675
 
676
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )            \
677
    CYG_MACRO_START                                             \
678
    if (CYGNUM_HAL_INTERRUPT_DECREMENTER != (_vector_))         \
679
        cyg_hal_interrupt_set_level ( (_vector_) , (_level_) ); \
680
    CYG_MACRO_END
681
 
682
#define CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
683
 
684
#endif
685
 
686
//--------------------------------------------------------------------------
687
// Interrupt arbiters
688
 
689
#ifdef CYGHWR_HAL_POWERPC_MPC8XX
690
 
691
externC cyg_uint32 hal_arbitration_isr_tb (CYG_ADDRWORD vector,
692
                                           CYG_ADDRWORD data);
693
externC cyg_uint32 hal_arbitration_isr_pit (CYG_ADDRWORD vector,
694
                                            CYG_ADDRWORD data);
695
externC cyg_uint32 hal_arbitration_isr_rtc (CYG_ADDRWORD vector,
696
                                            CYG_ADDRWORD data);
697
externC cyg_uint32 hal_arbitration_isr_cpm (CYG_ADDRWORD vector,
698
                                            CYG_ADDRWORD data);
699
 
700
#endif // ifdef CYGHWR_HAL_POWERPC_MPC8XX
701
 
702
//-----------------------------------------------------------------------------
703
// Symbols used by assembly code
704
#define CYGARC_VARIANT_DEFS                                     \
705
    DEFINE(CYGNUM_HAL_VECTOR_NMI, CYGNUM_HAL_VECTOR_NMI);
706
 
707
//-----------------------------------------------------------------------------
708
#endif // ifndef CYGONCE_VAR_INTR_H
709
// End of var_intr.h

powered by: WebSVN 2.1.0

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