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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [ecos-2.0/] [packages/] [hal/] [calmrisc16/] [arch/] [v2_0/] [include/] [hal_intr.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1254 phoenix
#ifndef CYGONCE_HAL_HAL_INTR_H
2
#define CYGONCE_HAL_HAL_INTR_H
3
 
4
//==========================================================================
5
//
6
//      hal_intr.h
7
//
8
//      HAL 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 Red Hat, 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 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):    nickg
47
// Contributors: nickg, jskov,
48
//               gthomas, jlarmour, msalter
49
// Date:         1999-02-16
50
// Purpose:      Define Interrupt support
51
// Description:  The macros defined here provide the HAL APIs for handling
52
//               interrupts and the clock.
53
//              
54
// Usage:
55
//              #include <cyg/hal/hal_intr.h>
56
//              ...
57
//              
58
//
59
//####DESCRIPTIONEND####
60
//
61
//==========================================================================
62
 
63
#include <pkgconf/hal.h>
64
 
65
#include <cyg/infra/cyg_type.h>
66
#include <cyg/hal/hal_io.h>
67
 
68
#include <cyg/hal/var_intr.h>
69
 
70
//--------------------------------------------------------------------------
71
// MIPS vectors. 
72
 
73
// These are the exception codes presented in the Cause register and
74
// correspond to VSRs. These values are the ones to use for HAL_VSR_GET/SET
75
 
76
 
77
#define CYGNUM_HAL_VECTOR_RESET    0  // Reset
78
#define CYGNUM_HAL_VECTOR_FIQ      1  // External Fast Interrupt
79
#define CYGNUM_HAL_VECTOR_IRQ      2  // External Interrupt
80
#define CYGNUM_HAL_VECTOR_TRACE    3  // Trace Request
81
#define CYGNUM_HAL_VECTOR_SWI      4  // SWI
82
 
83
#define CYGNUM_HAL_VSR_MIN                     0
84
#define CYGNUM_HAL_VSR_MAX                     4
85
#define CYGNUM_HAL_VSR_COUNT                   5
86
 
87
// Min/Max exception numbers and how many there are
88
#define CYGNUM_HAL_EXCEPTION_MIN                0
89
#define CYGNUM_HAL_EXCEPTION_MAX                CYGNUM_HAL_VSR_MAX
90
 
91
#define CYGNUM_HAL_EXCEPTION_COUNT           \
92
                 ( CYGNUM_HAL_EXCEPTION_MAX - CYGNUM_HAL_EXCEPTION_MIN + 1 )
93
 
94
 
95
#ifndef CYGHWR_HAL_INTERRUPT_VECTORS_DEFINED
96
#define CYGNUM_HAL_FAST_INTERRUPT           0
97
#define CYGNUM_HAL_INTERRUPT                1
98
 
99
// Min/Max ISR numbers and how many there are
100
#define CYGNUM_HAL_ISR_MIN                     0
101
#define CYGNUM_HAL_ISR_MAX                     1
102
#define CYGNUM_HAL_ISR_COUNT                   2
103
 
104
#define CYGHWR_HAL_INTERRUPT_VECTORS_DEFINED
105
#endif
106
 
107
//--------------------------------------------------------------------------
108
// Static data used by HAL
109
 
110
// ISR tables
111
externC volatile CYG_ADDRESS    hal_interrupt_handlers[CYGNUM_HAL_ISR_COUNT];
112
externC volatile CYG_ADDRWORD   hal_interrupt_data[CYGNUM_HAL_ISR_COUNT];
113
externC volatile CYG_ADDRESS    hal_interrupt_objects[CYGNUM_HAL_ISR_COUNT];
114
 
115
// VSR table
116
externC volatile CYG_ADDRESS    hal_vsr_table[CYGNUM_HAL_VSR_MAX+1];
117
 
118
//--------------------------------------------------------------------------
119
// Default ISR
120
// The #define is used to test whether this routine exists, and to allow
121
// us to call it.
122
 
123
externC cyg_uint32 hal_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
124
 
125
#define HAL_DEFAULT_ISR hal_default_isr
126
 
127
//--------------------------------------------------------------------------
128
// Interrupt state storage
129
 
130
typedef cyg_uint32 CYG_INTERRUPT_STATE;
131
 
132
//--------------------------------------------------------------------------
133
// Interrupt control macros
134
// Beware of nops in this code. They fill delay slots and avoid CP0 hazards
135
// that might otherwise cause following code to run in the wrong state or
136
// cause a resource conflict.
137
 
138
#define HAL_DISABLE_INTERRUPTS(_old_)
139
#define HAL_ENABLE_INTERRUPTS()
140
#define HAL_RESTORE_INTERRUPTS(_old_)
141
#define HAL_QUERY_INTERRUPTS( _state_ )
142
 
143
//--------------------------------------------------------------------------
144
// Routine to execute DSRs using separate interrupt stack
145
 
146
#ifdef  CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
147
externC void hal_interrupt_stack_call_pending_DSRs(void);
148
#define HAL_INTERRUPT_STACK_CALL_PENDING_DSRS() \
149
    hal_interrupt_stack_call_pending_DSRs()
150
 
151
// these are offered solely for stack usage testing
152
// if they are not defined, then there is no interrupt stack.
153
#define HAL_INTERRUPT_STACK_BASE cyg_interrupt_stack_base
154
#define HAL_INTERRUPT_STACK_TOP  cyg_interrupt_stack
155
// use them to declare these extern however you want:
156
//       extern char HAL_INTERRUPT_STACK_BASE[];
157
//       extern char HAL_INTERRUPT_STACK_TOP[];
158
// is recommended
159
#endif
160
 
161
//--------------------------------------------------------------------------
162
// Vector translation.
163
// For chained interrupts we only have a single vector though which all
164
// are passed. For unchained interrupts we have a vector per interrupt.
165
 
166
#ifndef HAL_TRANSLATE_VECTOR
167
 
168
#if defined(CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN)
169
 
170
#define HAL_TRANSLATE_VECTOR(_vector_,_index_) (_index_) = 0
171
 
172
#else
173
 
174
#define HAL_TRANSLATE_VECTOR(_vector_,_index_) (_index_) = (_vector_)
175
 
176
#endif
177
 
178
#endif
179
 
180
//--------------------------------------------------------------------------
181
// Interrupt and VSR attachment macros
182
 
183
#define HAL_INTERRUPT_IN_USE( _vector_, _state_)                          \
184
    CYG_MACRO_START                                                       \
185
    cyg_uint32 _index_;                                                   \
186
    HAL_TRANSLATE_VECTOR ((_vector_), _index_);                           \
187
                                                                          \
188
    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)HAL_DEFAULT_ISR ) \
189
        (_state_) = 0;                                                    \
190
    else                                                                  \
191
        (_state_) = 1;                                                    \
192
    CYG_MACRO_END
193
 
194
#define HAL_INTERRUPT_ATTACH( _vector_, _isr_, _data_, _object_ )           \
195
{                                                                           \
196
    cyg_uint32 _index_;                                                     \
197
    HAL_TRANSLATE_VECTOR( _vector_, _index_ );                              \
198
                                                                            \
199
    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)HAL_DEFAULT_ISR )   \
200
    {                                                                       \
201
        hal_interrupt_handlers[_index_] = (CYG_ADDRESS)_isr_;               \
202
        hal_interrupt_data[_index_] = (CYG_ADDRWORD)_data_;                 \
203
        hal_interrupt_objects[_index_] = (CYG_ADDRESS)_object_;             \
204
    }                                                                       \
205
}
206
 
207
#define HAL_INTERRUPT_DETACH( _vector_, _isr_ )                         \
208
{                                                                       \
209
    cyg_uint32 _index_;                                                 \
210
    HAL_TRANSLATE_VECTOR( _vector_, _index_ );                          \
211
                                                                        \
212
    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)_isr_ )         \
213
    {                                                                   \
214
        hal_interrupt_handlers[_index_] = (CYG_ADDRESS)HAL_DEFAULT_ISR; \
215
        hal_interrupt_data[_index_] = 0;                                \
216
        hal_interrupt_objects[_index_] = 0;                             \
217
    }                                                                   \
218
}
219
 
220
#define HAL_VSR_GET( _vector_, _pvsr_ )                 \
221
    *(_pvsr_) = (void (*)())hal_vsr_table[_vector_];
222
 
223
 
224
#define HAL_VSR_SET( _vector_, _vsr_, _poldvsr_ ) CYG_MACRO_START         \
225
    if( (void*)_poldvsr_ != NULL)                                         \
226
        *(CYG_ADDRESS *)_poldvsr_ = (CYG_ADDRESS)hal_vsr_table[_vector_]; \
227
    hal_vsr_table[_vector_] = (CYG_ADDRESS)_vsr_;                         \
228
CYG_MACRO_END
229
 
230
// This is an ugly name, but what it means is: grab the VSR back to eCos
231
// internal handling, or if you like, the default handler.  But if
232
// cooperating with GDB and CygMon, the default behaviour is to pass most
233
// exceptions to CygMon.  This macro undoes that so that eCos handles the
234
// exception.  So use it with care.
235
 
236
externC void __default_exception_vsr(void);
237
externC void __default_interrupt_vsr(void);
238
externC void __break_vsr_springboard(void);
239
 
240
#define HAL_VSR_SET_TO_ECOS_HANDLER( _vector_, _poldvsr_ ) CYG_MACRO_START  \
241
    HAL_VSR_SET( _vector_, _vector_ == CYGNUM_HAL_VECTOR_INTERRUPT          \
242
                              ? (CYG_ADDRESS)__default_interrupt_vsr        \
243
                              : _vector_ == CYGNUM_HAL_VECTOR_BREAKPOINT    \
244
                                ? (CYG_ADDRESS)__break_vsr_springboard      \
245
                                : (CYG_ADDRESS)__default_exception_vsr,     \
246
                 _poldvsr_ );                                               \
247
CYG_MACRO_END
248
 
249
//--------------------------------------------------------------------------
250
// Interrupt controller access
251
// The default code here simply uses the fields present in the CP0 status
252
// and cause registers to implement this functionality.
253
// Beware of nops in this code. They fill delay slots and avoid CP0 hazards
254
// that might otherwise cause following code to run in the wrong state or
255
// cause a resource conflict.
256
 
257
#ifndef CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
258
 
259
#define HAL_INTERRUPT_MASK( _vector_ )
260
 
261
#define HAL_INTERRUPT_UNMASK( _vector_ )
262
 
263
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )
264
 
265
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ )
266
 
267
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )
268
 
269
#define CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
270
 
271
#endif
272
 
273
//--------------------------------------------------------------------------
274
// Clock control.
275
// This code uses the count and compare registers that are present in many
276
// MIPS variants.
277
// Beware of nops in this code. They fill delay slots and avoid CP0 hazards
278
// that might otherwise cause following code to run in the wrong state or
279
// cause a resource conflict.
280
 
281
#ifndef CYGHWR_HAL_CLOCK_CONTROL_DEFINED
282
 
283
externC CYG_WORD32 cyg_hal_clock_period;
284
#define CYGHWR_HAL_CLOCK_PERIOD_DEFINED
285
 
286
#define HAL_CLOCK_INITIALIZE( _period_ )
287
 
288
#define HAL_CLOCK_RESET( _vector_, _period_ )
289
 
290
#define HAL_CLOCK_READ( _pvalue_ )
291
 
292
#define CYGHWR_HAL_CLOCK_CONTROL_DEFINED
293
 
294
#endif
295
 
296
 
297
//--------------------------------------------------------------------------
298
#endif // ifndef CYGONCE_HAL_HAL_INTR_H
299
// End of hal_intr.h

powered by: WebSVN 2.1.0

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