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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [v85x/] [arch/] [v2_0/] [include/] [hal_intr.h] - Blame information for rev 344

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

Line No. Rev Author Line
1 27 unneback
#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
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
#include <pkgconf/hal_v85x.h>
65
 
66
#include <cyg/infra/cyg_type.h>
67
#include <cyg/hal/hal_io.h>
68
 
69
#include <cyg/hal/var_intr.h>
70
 
71
//--------------------------------------------------------------------------
72
// Static data used by HAL
73
 
74
// ISR tables
75
externC CYG_ADDRESS    hal_interrupt_handlers[CYGNUM_HAL_ISR_COUNT];
76
externC CYG_ADDRWORD   hal_interrupt_data[CYGNUM_HAL_ISR_COUNT];
77
externC CYG_ADDRESS    hal_interrupt_objects[CYGNUM_HAL_ISR_COUNT];
78
 
79
// VSR table
80
externC CYG_ADDRESS    hal_vsr_table[CYGNUM_HAL_VSR_COUNT];
81
 
82
//--------------------------------------------------------------------------
83
// Default ISR
84
// The #define is used to test whether this routine exists, and to allow
85
// us to call it.
86
 
87
externC cyg_uint32 hal_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
88
 
89
#define HAL_DEFAULT_ISR hal_default_isr
90
 
91
//--------------------------------------------------------------------------
92
// Interrupt state storage
93
 
94
typedef cyg_uint32 CYG_INTERRUPT_STATE;
95
 
96
//--------------------------------------------------------------------------
97
// Interrupt control macros
98
 
99
externC cyg_uint32 hal_disable_interrupts(void);
100
externC void       hal_enable_interrupts(void);
101
externC void       hal_restore_interrupts(cyg_uint32);
102
externC cyg_uint32 hal_query_interrupts(void);
103
 
104
#ifdef CYGSEM_HAL_NEC_INLINE_INTERRUPT_FUNCTIONS        
105
#define HAL_DISABLE_INTERRUPTS(_old_)                   \
106
    CYG_MACRO_START                                     \
107
    asm volatile (                                      \
108
        "stsr  PSW,%0;"                                 \
109
        "di"                                            \
110
        : "=r"(_old_));                                 \
111
    CYG_MACRO_END
112
 
113
#define HAL_ENABLE_INTERRUPTS()                         \
114
    CYG_MACRO_START                                     \
115
    asm volatile (                                      \
116
        "ei"                                            \
117
        : );                                            \
118
    CYG_MACRO_END
119
 
120
#define HAL_RESTORE_INTERRUPTS(_old_)           \
121
    CYG_MACRO_START                             \
122
    asm volatile (                              \
123
        "ldsr   %0,PSW"                         \
124
        :                                       \
125
        : "r" (_old_));                         \
126
    CYG_MACRO_END
127
#else
128
#define HAL_DISABLE_INTERRUPTS(_old_)   _old_ = hal_disable_interrupts()
129
#define HAL_ENABLE_INTERRUPTS()         hal_enable_interrupts()
130
#define HAL_RESTORE_INTERRUPTS(_old_)   hal_restore_interrupts(_old_)
131
#endif
132
 
133
#define HAL_QUERY_INTERRUPTS( _state_ )         _state_ = hal_query_interrupts()
134
 
135
//--------------------------------------------------------------------------
136
// Routine to execute DSRs using separate interrupt stack
137
 
138
#ifdef  CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
139
externC void hal_interrupt_stack_call_pending_DSRs(void);
140
#define HAL_INTERRUPT_STACK_CALL_PENDING_DSRS() \
141
    hal_interrupt_stack_call_pending_DSRs()
142
 
143
// these are offered solely for stack usage testing
144
// if they are not defined, then there is no interrupt stack.
145
#define HAL_INTERRUPT_STACK_BASE cyg_interrupt_stack_base
146
#define HAL_INTERRUPT_STACK_TOP  cyg_interrupt_stack
147
// use them to declare these extern however you want:
148
//       extern char HAL_INTERRUPT_STACK_BASE[];
149
//       extern char HAL_INTERRUPT_STACK_TOP[];
150
// is recommended
151
#endif
152
 
153
//--------------------------------------------------------------------------
154
// Vector translation.
155
// For chained interrupts we only have a single vector though which all
156
// are passed. For unchained interrupts we have a vector per interrupt.
157
// Note: this hardware does not have/support chained interrupts.
158
 
159
//--------------------------------------------------------------------------
160
// Vector translation.
161
// For chained interrupts we only have a single vector though which all
162
// are passed. For unchained interrupts we have a vector per interrupt.
163
 
164
#ifndef HAL_TRANSLATE_VECTOR
165
#if defined(CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN)
166
#define HAL_TRANSLATE_VECTOR(_vector_,_index_) (_index_) = 0
167
#else
168
#define HAL_TRANSLATE_VECTOR(_vector_,_index_) (_index_) = (_vector_-CYGNUM_HAL_ISR_MIN)
169
#endif
170
#endif
171
 
172
#ifndef HAL_TRANSLATE_VECTOR
173
#define HAL_TRANSLATE_VECTOR(_vector_,_index_) (_index_) = (_vector_-CYGNUM_HAL_ISR_MIN)
174
#endif
175
 
176
//--------------------------------------------------------------------------
177
// Interrupt and VSR attachment macros
178
 
179
#define HAL_INTERRUPT_IN_USE( _vector_, _state_)                          \
180
    CYG_MACRO_START                                                       \
181
    cyg_uint32 _index_;                                                   \
182
    HAL_TRANSLATE_VECTOR ((_vector_), _index_);                           \
183
                                                                          \
184
    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)HAL_DEFAULT_ISR ) \
185
        (_state_) = 0;                                                    \
186
    else                                                                  \
187
        (_state_) = 1;                                                    \
188
    CYG_MACRO_END
189
 
190
#define HAL_INTERRUPT_ATTACH( _vector_, _isr_, _data_, _object_ )           \
191
{                                                                           \
192
    cyg_uint32 _index_;                                                     \
193
    HAL_TRANSLATE_VECTOR( _vector_, _index_ );                              \
194
                                                                            \
195
    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)HAL_DEFAULT_ISR )   \
196
    {                                                                       \
197
        hal_interrupt_handlers[_index_] = (CYG_ADDRESS)_isr_;               \
198
        hal_interrupt_data[_index_] = (CYG_ADDRWORD)_data_;                 \
199
        hal_interrupt_objects[_index_] = (CYG_ADDRESS)_object_;             \
200
    }                                                                       \
201
}
202
 
203
#define HAL_INTERRUPT_DETACH( _vector_, _isr_ )                         \
204
{                                                                       \
205
    cyg_uint32 _index_;                                                 \
206
    HAL_TRANSLATE_VECTOR( _vector_, _index_ );                          \
207
                                                                        \
208
    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)_isr_ )         \
209
    {                                                                   \
210
        hal_interrupt_handlers[_index_] = (CYG_ADDRESS)HAL_DEFAULT_ISR; \
211
        hal_interrupt_data[_index_] = 0;                                \
212
        hal_interrupt_objects[_index_] = 0;                             \
213
    }                                                                   \
214
}
215
 
216
#define HAL_VSR_GET( _vector_, _pvsr_ )                 \
217
    *(_pvsr_) = (void (*)())hal_vsr_table[_vector_];
218
 
219
 
220
#define HAL_VSR_SET( _vector_, _vsr_, _poldvsr_ ) CYG_MACRO_START         \
221
    if( _poldvsr_ != NULL)                                                \
222
        *(CYG_ADDRESS *)_poldvsr_ = (CYG_ADDRESS)hal_vsr_table[_vector_]; \
223
    hal_vsr_table[_vector_] = (CYG_ADDRESS)_vsr_;                         \
224
CYG_MACRO_END
225
 
226
// This is an ugly name, but what it means is: grab the VSR back to eCos
227
// internal handling, or if you like, the default handler.  But if
228
// cooperating with GDB and CygMon, the default behaviour is to pass most
229
// exceptions to CygMon.  This macro undoes that so that eCos handles the
230
// exception.  So use it with care.
231
 
232
externC void __default_exception_vsr(void);
233
externC void __default_interrupt_vsr(void);
234
 
235
#define HAL_VSR_SET_TO_ECOS_HANDLER( _vector_, _poldvsr_ ) CYG_MACRO_START  \
236
    HAL_VSR_SET( _vector_, _vector_ == CYGNUM_HAL_VECTOR_INTERRUPT          \
237
                              ? (CYG_ADDRESS)__default_interrupt_vsr        \
238
                              : (CYG_ADDRESS)__default_exception_vsr,       \
239
                 _poldvsr_ );                                               \
240
CYG_MACRO_END
241
 
242
//--------------------------------------------------------------------------
243
// Interrupt controller access
244
 
245
externC void hal_interrupt_mask(int);
246
externC void hal_interrupt_unmask(int);
247
externC void hal_interrupt_acknowledge(int);
248
 
249
#define HAL_INTERRUPT_MASK( _vector_ )          hal_interrupt_mask(_vector_)
250
#define HAL_INTERRUPT_UNMASK( _vector_ )        hal_interrupt_unmask(_vector_)
251
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )   hal_interrupt_acknowledge(_vector_)
252
 
253
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ )
254
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )
255
 
256
//--------------------------------------------------------------------------
257
// Clock control.
258
 
259
externC CYG_WORD32 cyg_hal_clock_period;
260
externC void hal_clock_initialize(cyg_int32);
261
externC void hal_clock_reset(int, cyg_uint32);
262
externC cyg_uint32 hal_clock_read(void);
263
 
264
#define HAL_CLOCK_INITIALIZE( _period_ )        hal_clock_initialize(_period_)
265
#define HAL_CLOCK_RESET( _vector_, _period_ )   hal_clock_reset(_vector_,_period_)
266
#define HAL_CLOCK_READ( _pvalue_ )              *(_pvalue_) = hal_clock_read()
267
 
268
#if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY) && \
269
    !defined(HAL_CLOCK_LATENCY)
270
#define HAL_CLOCK_LATENCY( _pvalue_ )           HAL_CLOCK_READ(_pvalue_)
271
#endif
272
 
273
//--------------------------------------------------------------------------
274
// Reset.
275
 
276
#ifndef HAL_PLATFORM_RESET
277
extern void hal_reset_board(void);
278
#define HAL_PLATFORM_RESET()             hal_reset_board()
279
#define HAL_PLATFORM_RESET_ENTRY         0x00000000
280
#endif
281
 
282
//--------------------------------------------------------------------------
283
#endif // ifndef CYGONCE_HAL_HAL_INTR_H
284
// End of hal_intr.h

powered by: WebSVN 2.1.0

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