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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [coldfire/] [mcf5272/] [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_HAL_VAR_INTR_H
2
#define CYGONCE_HAL_VAR_INTR_H
3
 
4
//==========================================================================
5
//
6
//      var_intr.h
7
//
8
//      MCF5272 processor variant interrupt, exception and clock support
9
//
10
//
11
//==========================================================================
12
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
13
// -------------------------------------------                              
14
// This file is part of eCos, the Embedded Configurable Operating System.   
15
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
16
//
17
// eCos is free software; you can redistribute it and/or modify it under    
18
// the terms of the GNU General Public License as published by the Free     
19
// Software Foundation; either version 2 or (at your option) any later      
20
// version.                                                                 
21
//
22
// eCos is distributed in the hope that it will be useful, but WITHOUT      
23
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
24
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
25
// for more details.                                                        
26
//
27
// You should have received a copy of the GNU General Public License        
28
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
29
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
30
//
31
// As a special exception, if other files instantiate templates or use      
32
// macros or inline functions from this file, or you compile this file      
33
// and link it with other works to produce a work based on this file,       
34
// this file does not by itself cause the resulting work to be covered by   
35
// the GNU General Public License. However the source code for this file    
36
// must still be made available in accordance with section (3) of the GNU   
37
// General Public License v2.                                               
38
//
39
// This exception does not invalidate any other reasons why a work based    
40
// on this file might be covered by the GNU General Public License.         
41
// -------------------------------------------                              
42
// ####ECOSGPLCOPYRIGHTEND####                                              
43
//==========================================================================
44
//#####DESCRIPTIONBEGIN####
45
//
46
// Author(s):     Enrico Piria
47
// Contributors:  Wade Jensen
48
// Date:          2005-25-06
49
// Purpose:       Provide interrupt, exception and clock definitions specific
50
//                to the MCF5272 processor.
51
// Usage:         Included via "hal_intr.h". Do not use directly.
52
//
53
//####DESCRIPTIONEND####
54
//========================================================================
55
 
56
#include <pkgconf/hal.h>
57
#include <cyg/infra/cyg_type.h>
58
 
59
// Include any platform specific interrupt definitions.
60
#include <cyg/hal/plf_intr.h>
61
 
62
// Include for the device addresses (MCF5272_DEVS).
63
#include <cyg/hal/var_arch.h>
64
 
65
// Include for HAL I/O macros
66
#include <cyg/hal/hal_io.h>
67
 
68
// --------------------------------------------------------------------------
69
// Interrupt controller management
70
 
71
// This chip has a programmable interrupt vector base which is different
72
// from the vector base  register (VBR). All interrupts from the interrupt
73
// controller are offset from the programmable interrupt vector register
74
// (PIVR). However, the only legal value is 64.
75
 
76
#define HAL_PROG_INT_VEC_BASE 64
77
 
78
// Vector numbers defined by the interrupt controller.
79
// These are all relative to the interrupt vector base number.
80
#define CYGNUM_HAL_INTERRUPT_USR_SPURINT       (0 + HAL_PROG_INT_VEC_BASE)
81
#define CYGNUM_HAL_INTERRUPT_EXTINT1           (1 + HAL_PROG_INT_VEC_BASE)
82
#define CYGNUM_HAL_INTERRUPT_EXTINT2           (2 + HAL_PROG_INT_VEC_BASE)
83
#define CYGNUM_HAL_INTERRUPT_EXTINT3           (3 + HAL_PROG_INT_VEC_BASE)
84
#define CYGNUM_HAL_INTERRUPT_EXTINT4           (4 + HAL_PROG_INT_VEC_BASE)
85
#define CYGNUM_HAL_INTERRUPT_TMR0              (5 + HAL_PROG_INT_VEC_BASE)
86
#define CYGNUM_HAL_INTERRUPT_TMR1              (6 + HAL_PROG_INT_VEC_BASE)
87
#define CYGNUM_HAL_INTERRUPT_TMR2              (7 + HAL_PROG_INT_VEC_BASE)
88
#define CYGNUM_HAL_INTERRUPT_TMR3              (8 + HAL_PROG_INT_VEC_BASE)
89
#define CYGNUM_HAL_INTERRUPT_UART1             (9 + HAL_PROG_INT_VEC_BASE)
90
#define CYGNUM_HAL_INTERRUPT_UART2             (10 + HAL_PROG_INT_VEC_BASE)
91
#define CYGNUM_HAL_INTERRUPT_PLIP              (11 + HAL_PROG_INT_VEC_BASE)
92
#define CYGNUM_HAL_INTERRUPT_PLIA              (12 + HAL_PROG_INT_VEC_BASE)
93
#define CYGNUM_HAL_INTERRUPT_USB0              (13 + HAL_PROG_INT_VEC_BASE)
94
#define CYGNUM_HAL_INTERRUPT_USB1              (14 + HAL_PROG_INT_VEC_BASE)
95
#define CYGNUM_HAL_INTERRUPT_USB2              (15 + HAL_PROG_INT_VEC_BASE)
96
#define CYGNUM_HAL_INTERRUPT_USB3              (16 + HAL_PROG_INT_VEC_BASE)
97
#define CYGNUM_HAL_INTERRUPT_USB4              (17 + HAL_PROG_INT_VEC_BASE)
98
#define CYGNUM_HAL_INTERRUPT_USB5              (18 + HAL_PROG_INT_VEC_BASE)
99
#define CYGNUM_HAL_INTERRUPT_USB6              (19 + HAL_PROG_INT_VEC_BASE)
100
#define CYGNUM_HAL_INTERRUPT_USB7              (20 + HAL_PROG_INT_VEC_BASE)
101
#define CYGNUM_HAL_INTERRUPT_DMA               (21 + HAL_PROG_INT_VEC_BASE)
102
#define CYGNUM_HAL_INTERRUPT_ERX               (22 + HAL_PROG_INT_VEC_BASE)
103
#define CYGNUM_HAL_INTERRUPT_ETX               (23 + HAL_PROG_INT_VEC_BASE)
104
#define CYGNUM_HAL_INTERRUPT_ENTC              (24 + HAL_PROG_INT_VEC_BASE)
105
#define CYGNUM_HAL_INTERRUPT_QSPI              (25 + HAL_PROG_INT_VEC_BASE)
106
#define CYGNUM_HAL_INTERRUPT_EXTINT5           (26 + HAL_PROG_INT_VEC_BASE)
107
#define CYGNUM_HAL_INTERRUPT_EXTINT6           (27 + HAL_PROG_INT_VEC_BASE)
108
#define CYGNUM_HAL_INTERRUPT_SWTO              (28 + HAL_PROG_INT_VEC_BASE)
109
#define CYGNUM_HAL_INTERRUPT_RES1              (29 + HAL_PROG_INT_VEC_BASE)
110
#define CYGNUM_HAL_INTERRUPT_RES2              (30 + HAL_PROG_INT_VEC_BASE)
111
#define CYGNUM_HAL_INTERRUPT_RES3              (31 + HAL_PROG_INT_VEC_BASE)
112
 
113
// -------------------------------------------------------------------------
114
// Interrupt and exception vector table definitions. We need to redifine 
115
// CYGNUM_HAL_ISR_MIN because the first usable vector is 65
116
 
117
#define CYGNUM_HAL_ISR_RANGE_DEFINED
118
#define CYGNUM_HAL_ISR_MIN                   CYGNUM_HAL_INTERRUPT_EXTINT1
119
#define CYGNUM_HAL_ISR_MAX                   CYGNUM_HAL_INTERRUPT_RES3
120
#define CYGNUM_HAL_ISR_COUNT                 (CYGNUM_HAL_ISR_MAX - CYGNUM_HAL_ISR_MIN + 1)
121
 
122
// -------------------------------------------------------------------------
123
// Spurious interrupt definition. The MCF5272 returns vector number 64,
124
// instead of 24, for spurious interrupts
125
 
126
#define CYGNUM_HAL_SPURIOUS_INTERRUPT CYGNUM_HAL_INTERRUPT_USR_SPURINT
127
 
128
// --------------------------------------------------------------------------
129
// Interrupt controller definitions.
130
 
131
// Interrupt priority tables
132
externC volatile cyg_uint8 cyg_hal_ILVL_table[CYGNUM_HAL_ISR_COUNT];
133
externC volatile cyg_uint8 cyg_hal_IMASK_table[CYGNUM_HAL_ISR_COUNT];
134
 
135
externC void hal_interrupt_set_level(int vector, int level);
136
externC void hal_interrupt_mask(int vector);
137
externC void hal_interrupt_unmask(int vector);
138
 
139
// Mask the interrupt associated with the given vector.
140
#define HAL_INTERRUPT_MASK( _vector_ ) \
141
    hal_interrupt_mask(_vector_)
142
 
143
// Unmask the interrupt associated with the given vector.
144
#define HAL_INTERRUPT_UNMASK( _vector_ ) \
145
    hal_interrupt_unmask(_vector_)
146
 
147
// Set the priority level of an interrupt.
148
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _prilevel_ ) \
149
    hal_interrupt_set_level(_vector_, _prilevel_)
150
 
151
// Acknowledge the interrupt by writing a 1 to the corresponding
152
// interrupt pending bit. Write 0 to all other interrupt pending bits. Leave
153
// all priority levels unchanged. Disable all interrupts while we access the
154
// hardware registers.
155
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )                           \
156
CYG_MACRO_START                                                         \
157
    cyg_uint32 _vec_offset = (_vector_) - HAL_PROG_INT_VEC_BASE - 1;    \
158
    cyg_uint32 _icr = _vec_offset / 8;                                  \
159
    cyg_uint32 _icr_msk = 0x80000000 >> ((_vec_offset % 8) * 4);        \
160
    cyg_uint32 _icr_oldval;                                             \
161
    CYG_INTERRUPT_STATE _intr_state;                                    \
162
                                                                        \
163
    HAL_DISABLE_INTERRUPTS(_intr_state);                                \
164
    HAL_READ_UINT32(&MCF5272_DEVS->intc.icr[_icr], _icr_oldval);        \
165
    HAL_WRITE_UINT32(&MCF5272_DEVS->intc.icr[_icr],                     \
166
        _icr_oldval & (_icr_msk | 0x77777777));                         \
167
    HAL_RESTORE_INTERRUPTS(_intr_state);                                \
168
CYG_MACRO_END
169
 
170
// Set/clear the interrupt transition register bit. Disable all
171
// interrupts while we access the hardware registers.
172
#define HAL_INTERRUPT_CONFIGURE( _vector_, _leveltriggered_, _up_ )                     \
173
CYG_MACRO_START                                                                         \
174
    if (!(_leveltriggered_))                                                            \
175
    {                                                                                   \
176
        cyg_uint32 _vec_offset = (_vector_) - HAL_PROG_INT_VEC_BASE - 1;                \
177
        cyg_uint32 _itr_bit = 0x80000000 >> _vec_offset;                                \
178
        cyg_uint32 _pitr_oldval;                                                        \
179
        CYG_INTERRUPT_STATE _intr_state;                                                \
180
                                                                                        \
181
        HAL_DISABLE_INTERRUPTS(_intr_state);                                            \
182
        HAL_READ_UINT32(&MCF5272_DEVS->intc.pitr, _pitr_oldval);                        \
183
        if (_up_)                                                                       \
184
        {                                                                               \
185
            HAL_WRITE_UINT32(&MCF5272_DEVS->intc.pitr, _pitr_oldval | _itr_bit);        \
186
        }                                                                               \
187
        else                                                                            \
188
        {                                                                               \
189
            HAL_WRITE_UINT32(&MCF5272_DEVS->intc.pitr, _pitr_oldval & (~_itr_bit));     \
190
        }                                                                               \
191
        HAL_RESTORE_INTERRUPTS(_intr_state);                                            \
192
    }                                                                                   \
193
CYG_MACRO_END
194
 
195
// --------------------------------------------------------------------------
196
// Clock control
197
 
198
// The MCF5272 has 4 timers, numbered 0...3. Define the timer number that we
199
// want to use for the OS clock.
200
#define CYGNUM_HAL_RTC_TIMER_NUM (3)
201
 
202
// The vector used by the real-time clock
203
#define CYGNUM_HAL_INTERRUPT_RTC (CYGNUM_HAL_INTERRUPT_TMR3)
204
 
205
// Initialize the timer to generate an interrupt every 10 ms. Use the
206
// system clock divided by 16 as the source. Using 10 as the prescaler
207
// gives a 2.4 us counter. When this counter reaches _period_, generate
208
// an interrupt.
209
#define HAL_CLOCK_INITIALIZE(_period_)                                          \
210
CYG_MACRO_START                                                                 \
211
HAL_WRITE_UINT16(&MCF5272_DEVS->timer[CYGNUM_HAL_RTC_TIMER_NUM].tmr,            \
212
                 0x0000);                                                       \
213
HAL_WRITE_UINT16(&MCF5272_DEVS->timer[CYGNUM_HAL_RTC_TIMER_NUM].trr,            \
214
                 (_period_));                                                   \
215
HAL_WRITE_UINT16(&MCF5272_DEVS->timer[CYGNUM_HAL_RTC_TIMER_NUM].tcn, 0);        \
216
HAL_WRITE_UINT16(&MCF5272_DEVS->timer[CYGNUM_HAL_RTC_TIMER_NUM].ter, 0x0003);   \
217
HAL_WRITE_UINT16(&MCF5272_DEVS->timer[CYGNUM_HAL_RTC_TIMER_NUM].tmr,            \
218
    (((10)-1) << MCF5272_TIMER_TMR_PS_BIT) |                                    \
219
    (0 << MCF5272_TIMER_TMR_CE_BIT) |                                           \
220
    (0 << MCF5272_TIMER_TMR_OM_BIT) |                                           \
221
    (1 << MCF5272_TIMER_TMR_ORI_BIT) |                                          \
222
    (0 << MCF5272_TIMER_TMR_FRR_BIT) |                                          \
223
    (2 << MCF5272_TIMER_TMR_CLK_BIT) |                                          \
224
    (1 << MCF5272_TIMER_TMR_RST_BIT));                                          \
225
CYG_MACRO_END
226
 
227
// We must clear the bit in the timer event register before we can get
228
// another interrupt.
229
#define HAL_CLOCK_RESET( _vector_, _period_ )                                   \
230
CYG_MACRO_START                                                                 \
231
HAL_WRITE_UINT16(&MCF5272_DEVS->timer[CYGNUM_HAL_RTC_TIMER_NUM].tcn, 0);        \
232
HAL_WRITE_UINT16(&MCF5272_DEVS->timer[CYGNUM_HAL_RTC_TIMER_NUM].ter, 0x0002);   \
233
CYG_MACRO_END
234
 
235
// Read the current counter from the timer
236
#define HAL_CLOCK_READ( _pvalue_ )                                              \
237
CYG_MACRO_START                                                                 \
238
HAL_READ_UINT16(&MCF5272_DEVS->timer[CYGNUM_HAL_RTC_TIMER_NUM].tcn,             \
239
                *(_pvalue_));                                                   \
240
CYG_MACRO_END
241
 
242
// Measure clock latency
243
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY
244
#define HAL_CLOCK_LATENCY( _pvalue_ )                                       \
245
CYG_MACRO_START                                                             \
246
    register cyg_int32 result;                                              \
247
    HAL_CLOCK_READ( &result );                                              \
248
    *_pvalue_ = result - CYGNUM_HAL_RTC_PERIOD;                             \
249
CYG_MACRO_END
250
#endif
251
 
252
// ---------------------------------------------------------------------------
253
// End of var_intr.h
254
#endif // ifndef CYGONCE_HAL_VAR_INTR_H

powered by: WebSVN 2.1.0

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