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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [synth/] [arch/] [current/] [include/] [hal_intr.h] - Blame information for rev 817

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

Line No. Rev Author Line
1 786 skrzyp
#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 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):    proven
46
// Contributors: proven, jskov, pjo, nickg, bartv
47
// Date:         1999-02-20
48
// Purpose:      Define Interrupt support
49
// Description:  The macros defined here provide the HAL APIs for handling
50
//               interrupts and the clock.
51
//              
52
// Usage:
53
//               #include <cyg/hal/hal_intr.h>
54
//               ...
55
//
56
//####DESCRIPTIONEND####
57
//
58
//==========================================================================
59
 
60
// Interrupt and exception handling in the synthetic target is very much
61
// tied up with POSIX signal handling.
62
//
63
// There are two interrupt sources to consider. The system clock is
64
// provided most conveniently by a timer signal SIGALRM. All other
65
// interrupts are handled by communication with the auxiliary program
66
// and involve SIGIO. The model that is actually presented to
67
// higher-level code is a single VSR, and 32 ISRs. ISR 0 is
68
// arbitrarily assigned to the clock. The remaining 31 ISRs correspond
69
// to devices managed through the auxiliary, effectively providing an
70
// interrupt controller. A single VSR suffices because it is passed
71
// the signal number as argument.
72
//
73
// Exceptions also correspond to signals, but are not handled through
74
// the same VSR: slightly different processing is needed for
75
// interrupts vs. exceptions, for example the latter does not involve
76
// calling interrupt_end(). The exceptions of interest are SIGILL,
77
// SIGBUS, SIGFPE, and SIGSEGV. SIGBUS and SIGSEGV are treated as a
78
// single exception. Obviously there are other signals but they do not
79
// have obvious meanings in the context of the synthetic target. NOTE:
80
// SIGSTKFLT may be needed as well at some point.
81
 
82
#define CYGNUM_HAL_INTERRUPT_RTC        0
83
#define CYGNUM_HAL_ISR_MIN              0
84
#define CYGNUM_HAL_ISR_MAX              31
85
#define CYGNUM_HAL_ISR_COUNT            (CYGNUM_HAL_ISR_MAX + 1)
86
 
87
#define CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION        0
88
#define CYGNUM_HAL_EXCEPTION_DATA_ACCESS                1
89
#define CYGNUM_HAL_EXCEPTION_FPU                        2
90
 
91
#define CYGNUM_HAL_EXCEPTION_MIN        0
92
#define CYGNUM_HAL_EXCEPTION_MAX        CYGNUM_HAL_EXCEPTION_FPU
93
#define CYGNUM_HAL_EXCEPTION_COUNT      (CYGNUM_HAL_EXCEPTION_MAX + 1)
94
 
95
#define CYGNUM_HAL_VECTOR_SIGNAL        0
96
#define CYGNUM_HAL_VSR_MIN              0
97
#define CYGNUM_HAL_VSR_MAX              CYGNUM_HAL_VECTOR_SIGNAL
98
#define CYGNUM_HAL_VSR_COUNT            (CYGNUM_HAL_VSR_MAX + 1)
99
 
100
// These #include's cannot happen until after the above are defined.
101
// There are dependencies on e.g. CYGNUM_HAL_EXCEPTION_COUNT.
102
// Basic data types
103
#include <cyg/infra/cyg_type.h>
104
 
105
// cyg_vector_t etc., supplied either by the kernel or the common HAL
106
#include <cyg/hal/drv_api.h>
107
 
108
// Nearly all interrupt state control happens via functions. This
109
// facilitates debugging, for example it is easier to set breakpoints
110
// that way, at the cost of performance. However performance is not a
111
// critical issue for the synthetic target, Instead it is intended to
112
// facilitate application development, and hence debugability has a
113
// higher priority. There is one exception: the sequence
114
// disable_interrupts() followed by restore_interrupts() occurs
115
// frequently and is worth some inlining.
116
//
117
// Note: some of the details such as the existence of a global
118
// variable hal_interrupts_enabled are known to the context switch
119
// code in the variant HAL.
120
typedef cyg_bool_t          CYG_INTERRUPT_STATE;
121
externC volatile cyg_bool_t hal_interrupts_enabled;
122
externC void                hal_enable_interrupts(void);
123
externC cyg_bool_t          hal_interrupt_in_use(cyg_vector_t);
124
externC void                hal_interrupt_attach(cyg_vector_t, cyg_ISR_t*, CYG_ADDRWORD, CYG_ADDRESS);
125
externC void                hal_interrupt_detach(cyg_vector_t, cyg_ISR_t*);
126
externC void                (*hal_vsr_get(cyg_vector_t))(void);
127
externC void                hal_vsr_set(cyg_vector_t, void (*)(void), void (**)(void));
128
externC void                hal_interrupt_mask(cyg_vector_t);
129
externC void                hal_interrupt_unmask(cyg_vector_t);
130
externC void                hal_interrupt_acknowledge(cyg_vector_t);
131
externC void                hal_interrupt_configure(cyg_vector_t, cyg_bool_t, cyg_bool_t);
132
externC void                hal_interrupt_set_level(cyg_vector_t, cyg_priority_t);
133
 
134
 
135
#define HAL_ENABLE_INTERRUPTS()                 \
136
    CYG_MACRO_START                             \
137
    hal_enable_interrupts();                    \
138
    CYG_MACRO_END
139
 
140
#define HAL_DISABLE_INTERRUPTS(_old_)           \
141
    CYG_MACRO_START                             \
142
    _old_ = hal_interrupts_enabled;             \
143
    hal_interrupts_enabled = false;             \
144
    CYG_MACRO_END
145
 
146
#define HAL_RESTORE_INTERRUPTS(_old_)           \
147
    CYG_MACRO_START                             \
148
    if (!_old_) {                               \
149
        hal_interrupts_enabled = false;         \
150
    } else if (!hal_interrupts_enabled) {       \
151
        hal_enable_interrupts();                \
152
    }                                           \
153
    CYG_MACRO_END
154
 
155
#define HAL_QUERY_INTERRUPTS(_old_)             \
156
    CYG_MACRO_START                             \
157
    _old_ = hal_interrupts_enabled;             \
158
    CYG_MACRO_END
159
 
160
#define HAL_TRANSLATE_VECTOR(_vector_, _index_) \
161
    CYG_MACRO_START                             \
162
    (_index_) = (_vector_);                     \
163
    CYG_MACRO_END
164
 
165
#define HAL_INTERRUPT_IN_USE(_vector_, _state_)                         \
166
    CYG_MACRO_START                                                     \
167
    (_state_) = hal_interrupt_in_use(_vector_);                         \
168
    CYG_MACRO_END
169
 
170
#define HAL_INTERRUPT_ATTACH(_vector_, _isr_, _data_, _object_ )        \
171
    CYG_MACRO_START                                                     \
172
    hal_interrupt_attach(_vector_, _isr_, (CYG_ADDRWORD) _data_, (CYG_ADDRESS) _object_); \
173
    CYG_MACRO_END
174
 
175
#define HAL_INTERRUPT_DETACH(_vector_, _isr_)                           \
176
    CYG_MACRO_START                                                     \
177
    hal_interrupt_detach(_vector_, _isr_);                              \
178
    CYG_MACRO_END
179
 
180
#define HAL_VSR_GET(_vector_, _vsr_)                                    \
181
    CYG_MACRO_START                                                     \
182
    (*_vsr_) = hal_vsr_get(_vector_);                                   \
183
    CYG_MACRO_END
184
 
185
#define HAL_VSR_SET(_vector_, _vsr_, _poldvsr_)                         \
186
    CYG_MACRO_START                                                     \
187
    hal_vsr_set(_vector_, _vsr_, _poldvsr_);                            \
188
    CYG_MACRO_END
189
 
190
#define HAL_INTERRUPT_MASK(_vector_)            \
191
    CYG_MACRO_START                             \
192
    hal_interrupt_mask(_vector_);               \
193
    CYG_MACRO_END
194
 
195
#define HAL_INTERRUPT_UNMASK(_vector_)          \
196
    CYG_MACRO_START                             \
197
    hal_interrupt_unmask(_vector_);             \
198
    CYG_MACRO_END
199
 
200
#define HAL_INTERRUPT_ACKNOWLEDGE(_vector_)     \
201
    CYG_MACRO_START                             \
202
    hal_interrupt_acknowledge(_vector_);        \
203
    CYG_MACRO_END
204
 
205
#define HAL_INTERRUPT_CONFIGURE(_vector_, _level_, _up_)        \
206
    CYG_MACRO_START                                             \
207
    hal_interrupt_configure(_vector_, _level_, _up_);           \
208
    CYG_MACRO_END
209
 
210
#define HAL_INTERRUPT_SET_LEVEL(_vector_, _level_)              \
211
    CYG_MACRO_START                                             \
212
    hal_interrupt_set_level(_vector_, _level_);                 \
213
    CYG_MACRO_END
214
 
215
// Additional data exported by the synthetic target interrupt handling
216
// subsystem. These two variables correspond to typical interrupt
217
// status and mask registers.
218
extern volatile cyg_uint32   synth_pending_isrs;
219
extern volatile cyg_uint32   synth_masked_isrs;
220
 
221
// ----------------------------------------------------------------------------
222
// The clock support
223
externC void            hal_clock_initialize(cyg_uint32);
224
externC cyg_uint32      hal_clock_read(void);
225
 
226
#define HAL_CLOCK_INITIALIZE( _period_ )                        \
227
    CYG_MACRO_START                                             \
228
    hal_clock_initialize(_period_);                             \
229
    CYG_MACRO_END
230
 
231
// No special action is needed for reset.
232
#define HAL_CLOCK_RESET( _vector_, _period_ )                   \
233
    CYG_EMPTY_STATEMENT
234
 
235
#define HAL_CLOCK_READ(_pvalue_)                                \
236
    CYG_MACRO_START                                             \
237
    *(_pvalue_) = hal_clock_read();                             \
238
    CYG_MACRO_END
239
 
240
// ----------------------------------------------------------------------------
241
// HAL_DELAY_US() support. The macro is provided by the processor-specific
242
// HAL, but the bogomips rating is provided by the architectural code.
243
extern int hal_bogomips;
244
#include <cyg/hal/var_intr.h>
245
 
246
// ----------------------------------------------------------------------------
247
// Resetting the Synth target is not possible, but existing the process is.
248
externC void            cyg_hal_sys_exit(int);
249
#define HAL_PLATFORM_RESET()                                    \
250
    CYG_MACRO_START                                             \
251
    cyg_hal_sys_exit(0);                                        \
252
    CYG_MACRO_END
253
 
254
// ----------------------------------------------------------------------------
255
// Test case exit support.
256
#define CYGHWR_TEST_PROGRAM_EXIT()                              \
257
    CYG_MACRO_START                                             \
258
    cyg_hal_sys_exit(0);                                        \
259
    CYG_MACRO_END
260
//---------------------------------------------------------------------------
261
#endif // ifndef CYGONCE_HAL_HAL_INTR_H
262
// 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.