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

Subversion Repositories openrisc

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

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