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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mn10300/] [am31/] [current/] [include/] [var_intr.h] - Blame information for rev 853

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

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_HAL_VAR_INTR_H
2
#define CYGONCE_HAL_VAR_INTR_H
3
 
4
//==========================================================================
5
//
6
//      var_intr.h
7
//
8
//      AM31 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
48
// Date:         1999-02-16
49
// Purpose:      AM31 Interrupt support
50
// Description:  The macros defined here provide the HAL APIs for handling
51
//               interrupts and the clock for AM31 variants of the MN10300
52
//               architecture.
53
//              
54
// Usage:
55
//              #include <cyg/hal/var_intr.h>
56
//              ...
57
//              
58
//
59
//####DESCRIPTIONEND####
60
//
61
//==========================================================================
62
 
63
#include <pkgconf/hal.h>
64
 
65
#include <cyg/infra/cyg_type.h>
66
 
67
#include <cyg/hal/plf_intr.h>
68
 
69
//--------------------------------------------------------------------------
70
 
71
// The MN10300 has a somewhat complex interrupt structure. Besides the
72
// reset and NMI vectors there are seven maskable interrupt vectors
73
// which must point to code in the 64k starting at 0x40000000. There
74
// are also 25 Interrupt control groups, each of which can have 4
75
// interrupt lines attached, for a theoretical total of 100 interrupts
76
// (!). Some of these are dedicated to specific devices, other to
77
// external pins, and others are not connected to anything, resulting
78
// in only 45 that can actually be delivered. Each control group may
79
// be assigned one of seven interrupt levels, and is delivered to the
80
// corresponding vector. Software can then use a register to determine
81
// the delivering group and detect from there which interrupt has been
82
// delivered.
83
//
84
// The approach we will adopt at present is for the code attached to
85
// each vector to save state and jump via a table to a VSR. The
86
// default VSR will fully decode the delivered interrupt into a table
87
// of isr/data/object entries. VSR replacement will operate on the
88
// first level indirection table rather than the hardware
89
// vectors. This is the fastest mechanism, however it needs 100*3*4 +
90
// 7*4 = 1228 bytes for the tables.
91
// 
92
 
93
//--------------------------------------------------------------------------
94
// Interrupt vectors.
95
 
96
// The level-specific hardware vectors
97
// These correspond to VSRs and are the values to use for HAL_VSR_GET/SET
98
#define CYGNUM_HAL_VECTOR_0                    0
99
#define CYGNUM_HAL_VECTOR_1                    1
100
#define CYGNUM_HAL_VECTOR_2                    2
101
#define CYGNUM_HAL_VECTOR_3                    3
102
#define CYGNUM_HAL_VECTOR_4                    4
103
#define CYGNUM_HAL_VECTOR_5                    5
104
#define CYGNUM_HAL_VECTOR_6                    6
105
#define CYGNUM_HAL_VECTOR_NMI_ENTRY            7
106
#define CYGNUM_HAL_VECTOR_TRAP                 8
107
#define CYGNUM_HAL_VECTOR_NMI                  9
108
#define CYGNUM_HAL_VECTOR_WATCHDOG             10
109
#define CYGNUM_HAL_VECTOR_SYSTEM_ERROR         11
110
 
111
#define CYGNUM_HAL_VSR_MIN                     0
112
#define CYGNUM_HAL_VSR_MAX                     11
113
#define CYGNUM_HAL_VSR_COUNT                   12
114
 
115
// Exception numbers. These are the values used when passed out to an
116
// external exception handler using cyg_hal_deliver_exception()
117
 
118
#define CYGNUM_HAL_EXCEPTION_NMI               CYGNUM_HAL_VECTOR_NMI
119
#define CYGNUM_HAL_EXCEPTION_WATCHDOG          CYGNUM_HAL_VECTOR_WATCHDOG
120
#define CYGNUM_HAL_EXCEPTION_SYSTEM_ERROR      CYGNUM_HAL_VECTOR_SYSTEM_ERROR
121
 
122
#define CYGNUM_HAL_EXCEPTION_DATA_ACCESS       CYGNUM_HAL_EXCEPTION_SYSTEM_ERROR
123
 
124
#define CYGNUM_HAL_EXCEPTION_MIN               CYGNUM_HAL_VSR_MIN
125
#define CYGNUM_HAL_EXCEPTION_MAX               CYGNUM_HAL_VSR_MAX
126
#define CYGNUM_HAL_EXCEPTION_COUNT             CYGNUM_HAL_VSR_COUNT
127
 
128
// The decoded interrupts
129
 
130
#define CYGNUM_HAL_INTERRUPT_NMIRQ                0
131
#define CYGNUM_HAL_INTERRUPT_WATCHDOG             1
132
#define CYGNUM_HAL_INTERRUPT_SYSTEM_ERROR         2
133
#define CYGNUM_HAL_INTERRUPT_RESERVED_3           3
134
 
135
#define CYGNUM_HAL_INTERRUPT_RESERVED_4           4
136
#define CYGNUM_HAL_INTERRUPT_RESERVED_5           5
137
#define CYGNUM_HAL_INTERRUPT_RESERVED_6           6
138
#define CYGNUM_HAL_INTERRUPT_RESERVED_7           7
139
 
140
#define CYGNUM_HAL_INTERRUPT_TIMER_0              8
141
#define CYGNUM_HAL_INTERRUPT_RESERVED_9           9
142
#define CYGNUM_HAL_INTERRUPT_RESERVED_10          10
143
#define CYGNUM_HAL_INTERRUPT_RESERVED_11          11
144
 
145
#define CYGNUM_HAL_INTERRUPT_TIMER_1              12
146
#define CYGNUM_HAL_INTERRUPT_RESERVED_13          13
147
#define CYGNUM_HAL_INTERRUPT_RESERVED_14          14
148
#define CYGNUM_HAL_INTERRUPT_RESERVED_15          15
149
 
150
#define CYGNUM_HAL_INTERRUPT_TIMER_2              16
151
#define CYGNUM_HAL_INTERRUPT_RESERVED_17          17
152
#define CYGNUM_HAL_INTERRUPT_RESERVED_18          18
153
#define CYGNUM_HAL_INTERRUPT_RESERVED_19          19
154
 
155
#define CYGNUM_HAL_INTERRUPT_TIMER_3              20
156
#define CYGNUM_HAL_INTERRUPT_RESERVED_21          21
157
#define CYGNUM_HAL_INTERRUPT_RESERVED_22          22
158
#define CYGNUM_HAL_INTERRUPT_RESERVED_23          23
159
 
160
#define CYGNUM_HAL_INTERRUPT_TIMER_4              24
161
#define CYGNUM_HAL_INTERRUPT_RESERVED_25          25
162
#define CYGNUM_HAL_INTERRUPT_RESERVED_26          26
163
#define CYGNUM_HAL_INTERRUPT_RESERVED_27          27
164
 
165
#define CYGNUM_HAL_INTERRUPT_TIMER_5              28
166
#define CYGNUM_HAL_INTERRUPT_RESERVED_29          29
167
#define CYGNUM_HAL_INTERRUPT_RESERVED_30          30
168
#define CYGNUM_HAL_INTERRUPT_RESERVED_31          31
169
 
170
#define CYGNUM_HAL_INTERRUPT_TIMER_6              32
171
#define CYGNUM_HAL_INTERRUPT_RESERVED_33          33
172
#define CYGNUM_HAL_INTERRUPT_RESERVED_34          34
173
#define CYGNUM_HAL_INTERRUPT_RESERVED_35          35
174
 
175
#define CYGNUM_HAL_INTERRUPT_TIMER_6_COMPARE_A    36
176
#define CYGNUM_HAL_INTERRUPT_RESERVED_37          37
177
#define CYGNUM_HAL_INTERRUPT_RESERVED_38          38
178
#define CYGNUM_HAL_INTERRUPT_RESERVED_39          39
179
 
180
#define CYGNUM_HAL_INTERRUPT_TIMER_6_COMPARE_B    40
181
#define CYGNUM_HAL_INTERRUPT_RESERVED_41          41
182
#define CYGNUM_HAL_INTERRUPT_RESERVED_42          42
183
#define CYGNUM_HAL_INTERRUPT_RESERVED_43          43
184
 
185
#define CYGNUM_HAL_INTERRUPT_RESERVED_44          44
186
#define CYGNUM_HAL_INTERRUPT_RESERVED_45          45
187
#define CYGNUM_HAL_INTERRUPT_RESERVED_46          46
188
#define CYGNUM_HAL_INTERRUPT_RESERVED_47          47
189
 
190
#define CYGNUM_HAL_INTERRUPT_DMA0                 48
191
#define CYGNUM_HAL_INTERRUPT_RESERVED_49          49
192
#define CYGNUM_HAL_INTERRUPT_RESERVED_50          50
193
#define CYGNUM_HAL_INTERRUPT_RESERVED_51          51
194
 
195
#define CYGNUM_HAL_INTERRUPT_DMA1                 52
196
#define CYGNUM_HAL_INTERRUPT_RESERVED_53          53
197
#define CYGNUM_HAL_INTERRUPT_RESERVED_54          54
198
#define CYGNUM_HAL_INTERRUPT_RESERVED_55          55
199
 
200
#define CYGNUM_HAL_INTERRUPT_DMA2                 56
201
#define CYGNUM_HAL_INTERRUPT_RESERVED_57          57
202
#define CYGNUM_HAL_INTERRUPT_RESERVED_58          58
203
#define CYGNUM_HAL_INTERRUPT_RESERVED_59          59
204
 
205
#define CYGNUM_HAL_INTERRUPT_DMA3                 60
206
#define CYGNUM_HAL_INTERRUPT_RESERVED_61          61
207
#define CYGNUM_HAL_INTERRUPT_RESERVED_62          62
208
#define CYGNUM_HAL_INTERRUPT_RESERVED_63          63
209
 
210
#define CYGNUM_HAL_INTERRUPT_SERIAL_0_RX          64
211
#define CYGNUM_HAL_INTERRUPT_RESERVED_65          65
212
#define CYGNUM_HAL_INTERRUPT_RESERVED_66          66
213
#define CYGNUM_HAL_INTERRUPT_RESERVED_67          67
214
 
215
#define CYGNUM_HAL_INTERRUPT_SERIAL_0_TX          68
216
#define CYGNUM_HAL_INTERRUPT_RESERVED_69          69
217
#define CYGNUM_HAL_INTERRUPT_RESERVED_70          70
218
#define CYGNUM_HAL_INTERRUPT_RESERVED_71          71
219
 
220
#define CYGNUM_HAL_INTERRUPT_SERIAL_1_RX          72
221
#define CYGNUM_HAL_INTERRUPT_RESERVED_73          73
222
#define CYGNUM_HAL_INTERRUPT_RESERVED_74          74
223
#define CYGNUM_HAL_INTERRUPT_RESERVED_75          75
224
 
225
#define CYGNUM_HAL_INTERRUPT_SERIAL_1_TX          76
226
#define CYGNUM_HAL_INTERRUPT_RESERVED_77          77
227
#define CYGNUM_HAL_INTERRUPT_RESERVED_78          78
228
#define CYGNUM_HAL_INTERRUPT_RESERVED_79          79
229
 
230
#define CYGNUM_HAL_INTERRUPT_SERIAL_2_RX          80
231
#define CYGNUM_HAL_INTERRUPT_RESERVED_81          81
232
#define CYGNUM_HAL_INTERRUPT_RESERVED_82          82
233
#define CYGNUM_HAL_INTERRUPT_RESERVED_83          83
234
 
235
#define CYGNUM_HAL_INTERRUPT_SERIAL_2_TX          84
236
#define CYGNUM_HAL_INTERRUPT_RESERVED_85          85
237
#define CYGNUM_HAL_INTERRUPT_RESERVED_86          86
238
#define CYGNUM_HAL_INTERRUPT_RESERVED_87          87
239
 
240
#define CYGNUM_HAL_INTERRUPT_RESERVED_88          88
241
#define CYGNUM_HAL_INTERRUPT_RESERVED_89          89
242
#define CYGNUM_HAL_INTERRUPT_RESERVED_90          90
243
#define CYGNUM_HAL_INTERRUPT_RESERVED_91          91
244
 
245
#define CYGNUM_HAL_INTERRUPT_EXTERNAL_0           92
246
#define CYGNUM_HAL_INTERRUPT_RESERVED_93          93
247
#define CYGNUM_HAL_INTERRUPT_RESERVED_94          94
248
#define CYGNUM_HAL_INTERRUPT_RESERVED_95          95
249
 
250
#define CYGNUM_HAL_INTERRUPT_EXTERNAL_1           96
251
#define CYGNUM_HAL_INTERRUPT_RESERVED_97          97
252
#define CYGNUM_HAL_INTERRUPT_RESERVED_98          98
253
#define CYGNUM_HAL_INTERRUPT_RESERVED_99          99
254
 
255
#define CYGNUM_HAL_INTERRUPT_EXTERNAL_2           100
256
#define CYGNUM_HAL_INTERRUPT_RESERVED_101         101
257
#define CYGNUM_HAL_INTERRUPT_RESERVED_102         102
258
#define CYGNUM_HAL_INTERRUPT_RESERVED_103         103
259
 
260
#define CYGNUM_HAL_INTERRUPT_EXTERNAL_3           104
261
#define CYGNUM_HAL_INTERRUPT_RESERVED_105         105
262
#define CYGNUM_HAL_INTERRUPT_RESERVED_106         106
263
#define CYGNUM_HAL_INTERRUPT_RESERVED_107         107
264
 
265
#define CYGNUM_HAL_INTERRUPT_EXTERNAL_4           108
266
#define CYGNUM_HAL_INTERRUPT_RESERVED_109         109
267
#define CYGNUM_HAL_INTERRUPT_RESERVED_110         110
268
#define CYGNUM_HAL_INTERRUPT_RESERVED_111         111
269
 
270
#define CYGNUM_HAL_INTERRUPT_EXTERNAL_5           112
271
#define CYGNUM_HAL_INTERRUPT_RESERVED_113         113
272
#define CYGNUM_HAL_INTERRUPT_RESERVED_114         114
273
#define CYGNUM_HAL_INTERRUPT_RESERVED_115         115
274
 
275
#define CYGNUM_HAL_INTERRUPT_EXTERNAL_6           116
276
#define CYGNUM_HAL_INTERRUPT_RESERVED_117         117
277
#define CYGNUM_HAL_INTERRUPT_RESERVED_118         118
278
#define CYGNUM_HAL_INTERRUPT_RESERVED_119         119
279
 
280
#define CYGNUM_HAL_INTERRUPT_EXTERNAL_7           120
281
#define CYGNUM_HAL_INTERRUPT_RESERVED_121         121
282
#define CYGNUM_HAL_INTERRUPT_RESERVED_122         122
283
#define CYGNUM_HAL_INTERRUPT_RESERVED_123         123
284
 
285
#define CYGNUM_HAL_ISR_MIN                     0
286
#define CYGNUM_HAL_ISR_MAX                     123
287
 
288
#define CYGNUM_HAL_ISR_COUNT                   (3+((CYGNUM_HAL_ISR_MAX+1)/4))
289
 
290
// The vector used by the Real time clock
291
 
292
#define CYGNUM_HAL_INTERRUPT_RTC                CYGNUM_HAL_INTERRUPT_TIMER_5
293
 
294
//--------------------------------------------------------------------------
295
// Interrupt vector translation.
296
 
297
#if !defined(HAL_TRANSLATE_VECTOR) && !defined(CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN)
298
 
299
#define HAL_TRANSLATE_VECTOR(_vector_,_index_)                             \
300
              _index_ = (((_vector_)<=CYGNUM_HAL_INTERRUPT_SYSTEM_ERROR) ? \
301
                         (_vector_) :                                      \
302
                         (((_vector_)>>2)+CYGNUM_HAL_INTERRUPT_RESERVED_3))
303
 
304
#endif
305
 
306
//--------------------------------------------------------------------------
307
// MN10300 specific version of HAL_INTERRUPT_CONFIGURE
308
 
309
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ )      \
310
CYG_MACRO_START                                                 \
311
    if( _vector_ >= CYGNUM_HAL_INTERRUPT_EXTERNAL_0 )           \
312
    {                                                           \
313
        cyg_uint32 _v_ = _vector_;                              \
314
        cyg_uint16 _val_ = 0;                                   \
315
        cyg_uint16 _reg_;                                       \
316
                                                                \
317
        /* adjust vector to bit offset in EXTMD */              \
318
        _v_ -= CYGNUM_HAL_INTERRUPT_EXTERNAL_0;                 \
319
        _v_ >>= 1;                                              \
320
                                                                \
321
        /* set bits according to requirements */                \
322
        if( _up_ ) _val_ |= 1;                                  \
323
        if( !(_level_) ) _val_ |= 2;                            \
324
                                                                \
325
        /* get EXTMD */                                         \
326
        _reg_ = mn10300_interrupt_control[0x180>>1];            \
327
                                                                \
328
        /* clear old value and set new */                       \
329
        _reg_ &= ~(3<<_v_);                                     \
330
        _reg_ |= _val_<<_v_;                                    \
331
                                                                \
332
        /* restore EXTMD */                                     \
333
        mn10300_interrupt_control[0x180>>1] = _reg_;            \
334
    }                                                           \
335
CYG_MACRO_END
336
 
337
#define HAL_INTERRUPT_CONFIGURE_DEFINED
338
 
339
//--------------------------------------------------------------------------
340
// Timer control registers.
341
// On the mn103002 we use timers 4 and 5
342
 
343
#define TIMER4_CR        0x340010a0
344
#define TIMER4_BR        0x34001090
345
#define TIMER4_MD        0x34001080
346
 
347
#define TIMER5_CR        0x340010a2
348
#define TIMER5_BR        0x34001092
349
#define TIMER5_MD        0x34001082
350
 
351
#define TIMER_CR        TIMER5_CR
352
#define TIMER_BR        TIMER5_BR
353
#define TIMER_MD        TIMER5_MD
354
 
355
#define TIMER0_MD       0x34001000
356
#define TIMER0_BR       0x34001010
357
#define TIMER0_CR       0x34001020
358
 
359
//--------------------------------------------------------------------------
360
// Clock control.
361
 
362
#define HAL_CLOCK_INITIALIZE( _period_ )                                \
363
{                                                                       \
364
    volatile cyg_uint16 *timer4_br      = (cyg_uint16 *)TIMER4_BR;      \
365
    volatile cyg_uint8 *timer4_md       = (cyg_uint8 *)TIMER4_MD;       \
366
    volatile cyg_uint16 *timer5_br      = (cyg_uint16 *)TIMER5_BR;      \
367
    volatile cyg_uint8 *timer5_md       = (cyg_uint8 *)TIMER5_MD;       \
368
                                                                        \
369
    /* Set timers 4 and 5 into cascade mode */                          \
370
                                                                        \
371
    *timer5_br = (_period_)>>16;                                        \
372
                                                                        \
373
    *timer5_md = 0x40;                                                  \
374
    *timer5_md = 0x83;                                                  \
375
                                                                        \
376
    *timer4_br = (_period_)&0x0000FFFF;                                 \
377
                                                                        \
378
    *timer4_md = 0x40;                                                  \
379
    *timer4_md = 0x80;                                                  \
380
}
381
 
382
#define HAL_CLOCK_RESET( _vector_, _period_ )
383
 
384
#define HAL_CLOCK_READ( _pvalue_ )                                      \
385
{                                                                       \
386
    volatile cyg_uint16 *timer4_cr = (cyg_uint16 *)TIMER4_CR;           \
387
    volatile cyg_uint16 *timer5_cr = (cyg_uint16 *)TIMER5_CR;           \
388
                                                                        \
389
    cyg_uint16 t5;                                                      \
390
    cyg_uint16 t4;                                                      \
391
                                                                        \
392
    /* Loop reading the two timers until we can read t5 twice   */      \
393
    /* with the same value. This avoids getting silly times if  */      \
394
    /* the timers carry between reading the two regs.           */      \
395
    do {                                                                \
396
        t5 = *timer5_cr;                                                \
397
        t4 = *timer4_cr;                                                \
398
    } while( t5 != *timer5_cr );                                        \
399
                                                                        \
400
    *(_pvalue_) = CYGNUM_KERNEL_COUNTERS_RTC_PERIOD - ((t5<<16) + t4);  \
401
}
402
 
403
// FIXME: above line should not use CYGNUM_KERNEL_COUNTERS_RTC_PERIOD since
404
// this means the HAL gets configured by kernel options even when the
405
// kernel is disabled!
406
 
407
 
408
//--------------------------------------------------------------------------
409
#endif // ifndef CYGONCE_HAL_VAR_INTR_H
410
// End of var_intr.h

powered by: WebSVN 2.1.0

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