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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [powerpc/] [mpc8260/] [v2_0/] [include/] [var_intr.h] - Blame information for rev 249

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#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 Red Hat, Inc.
14
// Copyright (C) 2002 Gary Thomas
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):   mtek, pfine
47
// Contributors:nickg, jskov, jlarmour, hmt
48
// Date:        2001-12-12
49
// Purpose:     Variant interrupt support
50
// Description: The macros defined here provide the HAL APIs for handling
51
//              interrupts and the clock on the MPC8260 PowerQUICCII CPU.
52
// Usage:       Is included via the architecture interrupt header:
53
//              #include <cyg/hal/hal_intr.h>
54
//              ...
55
//
56
//####DESCRIPTIONEND####
57
//
58
//=============================================================================
59
#include <pkgconf/hal.h>
60
#include <cyg/hal/plf_intr.h>
61
#include <cyg/hal/mpc8260.h>            // Memory map
62
#include <cyg/infra/cyg_type.h>         // types
63
#include <cyg/hal/hal_io.h>             // io macros
64
#include <cyg/infra/cyg_ass.h>          // CYG_FAIL
65
 
66
#define CYGARC_IMM_BASE      0x04700000
67
 
68
// Interrupts
69
 
70
// The first level of external interrupts
71
#define CYGNUM_HAL_INTERRUPT_I2C                 1
72
#define CYGNUM_HAL_INTERRUPT_SPI                 2
73
#define CYGNUM_HAL_INTERRUPT_RISC_TIMERS         3
74
#define CYGNUM_HAL_INTERRUPT_SMC1                4
75
#define CYGNUM_HAL_INTERRUPT_SMC2                5
76
#define CYGNUM_HAL_INTERRUPT_IDMA1               6
77
#define CYGNUM_HAL_INTERRUPT_IDMA2               7
78
#define CYGNUM_HAL_INTERRUPT_IDMA3               8
79
#define CYGNUM_HAL_INTERRUPT_IDMA4               9
80
#define CYGNUM_HAL_INTERRUPT_SDMA               10
81
 
82
#define CYGNUM_HAL_INTERRUPT_TIMER1             12
83
#define CYGNUM_HAL_INTERRUPT_TIMER2             13
84
#define CYGNUM_HAL_INTERRUPT_TIMER3             14
85
#define CYGNUM_HAL_INTERRUPT_TIMER4             15
86
#define CYGNUM_HAL_INTERRUPT_TMCNT              16
87
#define CYGNUM_HAL_INTERRUPT_PIT                17
88
 
89
#define CYGNUM_HAL_INTERRUPT_IRQ1               19
90
#define CYGNUM_HAL_INTERRUPT_IRQ2               20
91
#define CYGNUM_HAL_INTERRUPT_IRQ3               21
92
#define CYGNUM_HAL_INTERRUPT_IRQ4               22
93
#define CYGNUM_HAL_INTERRUPT_IRQ5               23
94
#define CYGNUM_HAL_INTERRUPT_IRQ6               24
95
#define CYGNUM_HAL_INTERRUPT_IRQ7               25
96
 
97
#define CYGNUM_HAL_INTERRUPT_FCC1               32
98
#define CYGNUM_HAL_INTERRUPT_FCC2               33
99
#define CYGNUM_HAL_INTERRUPT_FCC3               34
100
 
101
#define CYGNUM_HAL_INTERRUPT_MCC1               36
102
#define CYGNUM_HAL_INTERRUPT_MCC2               37
103
 
104
#define CYGNUM_HAL_INTERRUPT_SCC1               40
105
#define CYGNUM_HAL_INTERRUPT_SCC2               41
106
#define CYGNUM_HAL_INTERRUPT_SCC3               42
107
#define CYGNUM_HAL_INTERRUPT_SCC4               43
108
 
109
#define CYGNUM_HAL_INTERRUPT_PC15               48
110
#define CYGNUM_HAL_INTERRUPT_PC14               49
111
#define CYGNUM_HAL_INTERRUPT_PC13               50
112
#define CYGNUM_HAL_INTERRUPT_PC12               51
113
#define CYGNUM_HAL_INTERRUPT_PC11               52
114
#define CYGNUM_HAL_INTERRUPT_PC10               53
115
#define CYGNUM_HAL_INTERRUPT_PC9                54
116
#define CYGNUM_HAL_INTERRUPT_PC8                55
117
#define CYGNUM_HAL_INTERRUPT_PC7                56
118
#define CYGNUM_HAL_INTERRUPT_PC6                57
119
#define CYGNUM_HAL_INTERRUPT_PC5                58
120
#define CYGNUM_HAL_INTERRUPT_PC4                59
121
#define CYGNUM_HAL_INTERRUPT_PC3                60
122
#define CYGNUM_HAL_INTERRUPT_PC2                61
123
#define CYGNUM_HAL_INTERRUPT_PC1                62
124
#define CYGNUM_HAL_INTERRUPT_PC0                63
125
 
126
#define CYGNUM_HAL_INTERRUPT_ERROR          0
127
 
128
#define CYGNUM_HAL_ISR_MAX                   CYGNUM_HAL_INTERRUPT_PC0
129
 
130
//--------------------------------------------------------------------------
131
// Interrupt controller access
132
 
133
#ifndef CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
134
#ifdef CYGPKG_HAL_POWERPC_MPC8260
135
 
136
 
137
 
138
static __inline__ void
139
cyg_hal_interrupt_mask ( cyg_uint32 vector )
140
{
141
  volatile t_PQ2IMM    *IMM = (volatile t_PQ2IMM *) CYGARC_IMM_BASE;
142
  cyg_uint32 *reg_simr_h = (cyg_uint32 *) &(IMM->ic_simr_h);
143
  cyg_uint32 *reg_simr_l = (cyg_uint32 *) &(IMM->ic_simr_l);
144
 
145
  switch (vector) {
146
 
147
  case CYGNUM_HAL_INTERRUPT_PC15 ... CYGNUM_HAL_INTERRUPT_PC0:
148
    *reg_simr_h &= ~( (0x00010000) << (vector - CYGNUM_HAL_INTERRUPT_PC15) );
149
    break;
150
 
151
  case CYGNUM_HAL_INTERRUPT_IRQ1 ... CYGNUM_HAL_INTERRUPT_IRQ7:
152
    *reg_simr_h &= ~( (0x00004000) >> (vector - CYGNUM_HAL_INTERRUPT_IRQ1) );
153
    break;
154
 
155
  case CYGNUM_HAL_INTERRUPT_TMCNT:
156
    *reg_simr_h &= ~(0x00000004);
157
    break;
158
 
159
  case CYGNUM_HAL_INTERRUPT_PIT:
160
    *reg_simr_h &= ~(0x00000002);
161
    break;
162
 
163
  case CYGNUM_HAL_INTERRUPT_FCC1 ... CYGNUM_HAL_INTERRUPT_FCC3:
164
    *reg_simr_l &= ~( (0x20000000) << (CYGNUM_HAL_INTERRUPT_FCC3 - vector) );
165
    break;
166
 
167
  case CYGNUM_HAL_INTERRUPT_MCC1 ... CYGNUM_HAL_INTERRUPT_MCC2:
168
    *reg_simr_l &= ~( (0x08000000) >> (vector - CYGNUM_HAL_INTERRUPT_MCC1) );
169
    break;
170
 
171
  case CYGNUM_HAL_INTERRUPT_SCC1 ... CYGNUM_HAL_INTERRUPT_SCC4:
172
    *reg_simr_l &= ~( (0x00800000) >> (vector - CYGNUM_HAL_INTERRUPT_SCC1) );
173
    break;
174
 
175
  case  CYGNUM_HAL_INTERRUPT_I2C ... CYGNUM_HAL_INTERRUPT_SDMA:
176
    *reg_simr_l &= ~( (0x00008000) >> (vector - CYGNUM_HAL_INTERRUPT_I2C) );
177
    break;
178
 
179
  case CYGNUM_HAL_INTERRUPT_TIMER1 ... CYGNUM_HAL_INTERRUPT_TIMER4:
180
    *reg_simr_l &= ~( (0x00000010) >> (vector - CYGNUM_HAL_INTERRUPT_TIMER1) );
181
    break;
182
 
183
  default:
184
    CYG_FAIL("Unknown Interrupt in mask !!!");
185
    break;
186
  }
187
 
188
}
189
 
190
static __inline__ void
191
cyg_hal_interrupt_unmask ( cyg_uint32 vector )
192
{
193
 
194
  volatile t_PQ2IMM    *IMM = (volatile t_PQ2IMM *) CYGARC_IMM_BASE;
195
  cyg_uint32 *reg_simr_h = (cyg_uint32 *) &(IMM->ic_simr_h);
196
  cyg_uint32 *reg_simr_l = (cyg_uint32 *) &(IMM->ic_simr_l);
197
 
198
  switch (vector) {
199
 
200
  case CYGNUM_HAL_INTERRUPT_PC15 ... CYGNUM_HAL_INTERRUPT_PC0:
201
    *reg_simr_h |= ( (0x00010000) << (vector - CYGNUM_HAL_INTERRUPT_PC15) );
202
    break;
203
 
204
  case CYGNUM_HAL_INTERRUPT_IRQ1 ... CYGNUM_HAL_INTERRUPT_IRQ7:
205
    *reg_simr_h |= ( (0x00004000) >> (vector - CYGNUM_HAL_INTERRUPT_IRQ1) );
206
    break;
207
 
208
  case CYGNUM_HAL_INTERRUPT_TMCNT:
209
    *reg_simr_h |= (0x00000004);
210
    break;
211
 
212
  case CYGNUM_HAL_INTERRUPT_PIT:
213
    *reg_simr_h |= (0x00000002);
214
    break;
215
 
216
  case CYGNUM_HAL_INTERRUPT_FCC1 ... CYGNUM_HAL_INTERRUPT_FCC3:
217
    *reg_simr_l |= ( (0x20000000) << (CYGNUM_HAL_INTERRUPT_FCC3 - vector) );
218
    break;
219
 
220
  case CYGNUM_HAL_INTERRUPT_MCC1 ... CYGNUM_HAL_INTERRUPT_MCC2:
221
    *reg_simr_l |= ( (0x08000000) >> (vector - CYGNUM_HAL_INTERRUPT_MCC1) );
222
    break;
223
 
224
  case CYGNUM_HAL_INTERRUPT_SCC1 ... CYGNUM_HAL_INTERRUPT_SCC4:
225
    *reg_simr_l |= ( (0x00800000) >> (vector - CYGNUM_HAL_INTERRUPT_SCC1) );
226
    break;
227
 
228
  case  CYGNUM_HAL_INTERRUPT_I2C ... CYGNUM_HAL_INTERRUPT_SDMA:
229
    *reg_simr_l |= ( (0x00008000) >> (vector - CYGNUM_HAL_INTERRUPT_I2C) );
230
    break;
231
 
232
  case CYGNUM_HAL_INTERRUPT_TIMER1 ... CYGNUM_HAL_INTERRUPT_TIMER4:
233
    *reg_simr_l |= ( (0x00000010) >> (vector - CYGNUM_HAL_INTERRUPT_TIMER1) );
234
    break;
235
 
236
  default:
237
    CYG_FAIL("Unknown Interrupt in unmask !!!");
238
    break;
239
  }
240
 
241
}
242
 
243
static __inline__ void
244
cyg_hal_interrupt_acknowledge ( cyg_uint32 vector )
245
{
246
 
247
  volatile t_PQ2IMM    *IMM = (volatile t_PQ2IMM *) CYGARC_IMM_BASE;
248
  cyg_uint32 *reg_sipnr_h = (cyg_uint32 *) &(IMM->ic_sipnr_h);
249
  cyg_uint32 *reg_sipnr_l = (cyg_uint32 *) &(IMM->ic_sipnr_l);
250
 
251
  switch (vector) {
252
 
253
  case CYGNUM_HAL_INTERRUPT_PC15 ... CYGNUM_HAL_INTERRUPT_PC0:
254
    *reg_sipnr_h |= ( (0x00010000) << (vector - CYGNUM_HAL_INTERRUPT_PC15) );
255
    break;
256
 
257
  case CYGNUM_HAL_INTERRUPT_IRQ1 ... CYGNUM_HAL_INTERRUPT_IRQ7:
258
    *reg_sipnr_h |= ( (0x00004000) >> (vector - CYGNUM_HAL_INTERRUPT_IRQ1) );
259
    break;
260
 
261
  case CYGNUM_HAL_INTERRUPT_TMCNT:
262
    *reg_sipnr_h |= (0x00000004);
263
    break;
264
 
265
  case CYGNUM_HAL_INTERRUPT_PIT:
266
    *reg_sipnr_h |= (0x00000002);
267
    break;
268
 
269
  case CYGNUM_HAL_INTERRUPT_FCC1 ... CYGNUM_HAL_INTERRUPT_FCC3:
270
    *reg_sipnr_l |= ( (0x20000000) << (CYGNUM_HAL_INTERRUPT_FCC3 - vector) );
271
    break;
272
 
273
  case CYGNUM_HAL_INTERRUPT_MCC1 ... CYGNUM_HAL_INTERRUPT_MCC2:
274
    *reg_sipnr_l |= ( (0x08000000) >> (vector - CYGNUM_HAL_INTERRUPT_MCC1) );
275
    break;
276
 
277
  case CYGNUM_HAL_INTERRUPT_SCC1 ... CYGNUM_HAL_INTERRUPT_SCC4:
278
    *reg_sipnr_l |= ( (0x00800000) >> (vector - CYGNUM_HAL_INTERRUPT_SCC1) );
279
    break;
280
 
281
  case  CYGNUM_HAL_INTERRUPT_I2C ... CYGNUM_HAL_INTERRUPT_SDMA:
282
    *reg_sipnr_l |= ( (0x00008000) >> (vector - CYGNUM_HAL_INTERRUPT_I2C) );
283
    break;
284
 
285
  case CYGNUM_HAL_INTERRUPT_TIMER1 ... CYGNUM_HAL_INTERRUPT_TIMER4:
286
    *reg_sipnr_l |= ( (0x00000010) >> (vector - CYGNUM_HAL_INTERRUPT_TIMER1) );
287
    break;
288
 
289
  default:
290
    CYG_FAIL("Unknown Interrupt in unmask !!!");
291
    break;
292
  }
293
 
294
}
295
 
296
static __inline__ void
297
cyg_hal_interrupt_configure ( cyg_uint32 vector,
298
                              cyg_bool level,
299
                              cyg_bool up )
300
{
301
  // NOT IMPLEMENTED ...
302
}
303
 
304
 
305
static __inline__ void
306
cyg_hal_interrupt_set_level ( cyg_uint32 vector, cyg_uint32 level )
307
{
308
 
309
  // NOT IMPLEMENTED  ....
310
  // FACT : USER should not program the same interrupt to more than
311
  // one priority position. 
312
  // FACT : Every interrupt has an assigned default priority.
313
 
314
  // PROBLEM : One has to find the previous priority of the given vector
315
  // and swap(?) it with the requested priority owner (Not nice because
316
  // it changes another interrupt's priority inadvertently)
317
 
318
}
319
 
320
// The decrementer interrupt cannnot be masked, configured or acknowledged.
321
 
322
#define HAL_INTERRUPT_MASK( _vector_ )                    \
323
    CYG_MACRO_START                                       \
324
    if (CYGNUM_HAL_INTERRUPT_DECREMENTER != (_vector_))   \
325
        cyg_hal_interrupt_mask ( (_vector_) );            \
326
    CYG_MACRO_END
327
 
328
#define HAL_INTERRUPT_UNMASK( _vector_ )                  \
329
    CYG_MACRO_START                                       \
330
    if (CYGNUM_HAL_INTERRUPT_DECREMENTER != (_vector_))   \
331
        cyg_hal_interrupt_unmask ( (_vector_) );          \
332
    CYG_MACRO_END
333
 
334
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )             \
335
    CYG_MACRO_START                                       \
336
    if (CYGNUM_HAL_INTERRUPT_DECREMENTER != (_vector_))   \
337
        cyg_hal_interrupt_acknowledge ( (_vector_) );     \
338
    CYG_MACRO_END
339
 
340
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ )              \
341
    CYG_MACRO_START                                                     \
342
    if (CYGNUM_HAL_INTERRUPT_DECREMENTER != (_vector_))                 \
343
        cyg_hal_interrupt_configure ( (_vector_), (_level_), (_up_) );  \
344
    CYG_MACRO_END
345
 
346
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )            \
347
    CYG_MACRO_START                                             \
348
    if (CYGNUM_HAL_INTERRUPT_DECREMENTER != (_vector_))         \
349
        cyg_hal_interrupt_set_level ( (_vector_) , (_level_) ); \
350
    CYG_MACRO_END
351
 
352
#define CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
353
 
354
#endif
355
#endif
356
 
357
 
358
 
359
//-----------------------------------------------------------------------------
360
#endif // ifndef CYGONCE_VAR_INTR_H
361
// 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.