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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_HAL_INTR_H
2
#define CYGONCE_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):    nickg, gthomas
46
// Contributors: nickg, gthomas,
47
//               jlarmour
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:        #include <cyg/hal/hal_intr.h>
54
//               ...
55
//              
56
//
57
//####DESCRIPTIONEND####
58
//
59
//==========================================================================
60
 
61
#include <pkgconf/hal.h>
62
 
63
#include <cyg/infra/cyg_type.h>
64
 
65
// This is to allow a variant to decide that there is no platform-specific
66
// interrupts file; and that in turn can be overridden by a platform that
67
// refines the variant's ideas.
68
#ifdef    CYGBLD_HAL_PLF_INTS_H
69
# include CYGBLD_HAL_PLF_INTS_H // should include variant data as required
70
#else 
71
# ifdef    CYGBLD_HAL_VAR_INTS_H
72
#  include CYGBLD_HAL_VAR_INTS_H
73
# else
74
#  include <cyg/hal/plf_ints.h> // default less-complex platforms
75
# endif
76
#endif
77
 
78
// Spurious interrupt (no interrupt source could be found)
79
#define CYGNUM_HAL_INTERRUPT_NONE -1
80
 
81
//--------------------------------------------------------------------------
82
// FUJITSU exception vectors.
83
 
84
// The Fujitsu FR-V architecture supports up to 256 interrupt/exceptions.
85
// Each vectors to a specific VSR which is 16 bytes (4 instructions) long.
86
 
87
// These vectors correspond to VSRs. These values are the ones to use for
88
// HAL_VSR_GET/SET
89
 
90
#define CYGNUM_HAL_VECTOR_RESET                       0x00
91
#define CYGNUM_HAL_VECTOR_INSTR_ACCESS_MMU_MISS       0x01
92
#define CYGNUM_HAL_VECTOR_INSTR_ACCESS_ERROR          0x02
93
#define CYGNUM_HAL_VECTOR_INSTR_ACCESS_EXCEPTION      0x03
94
#define CYGNUM_HAL_VECTOR_PRIVELEDGED_INSTRUCTION     0x06
95
#define CYGNUM_HAL_VECTOR_ILLEGAL_INSTRUCTION         0x07
96
#define CYGNUM_HAL_VECTOR_REGISTER_EXCEPTION          0x08
97
#define CYGNUM_HAL_VECTOR_FP_DISABLED                 0x0A
98
#define CYGNUM_HAL_VECTOR_MP_DISABLED                 0x0B
99
#define CYGNUM_HAL_VECTOR_FP_EXCEPTION                0x0D
100
#define CYGNUM_HAL_VECTOR_MP_EXCEPTION                0x0E
101
#define CYGNUM_HAL_VECTOR_MEMORY_ADDRESS_NOT_ALIGNED  0x10
102
#define CYGNUM_HAL_VECTOR_DATA_ACCESS_ERROR           0x11
103
#define CYGNUM_HAL_VECTOR_DATA_ACCESS_MMU_MISS        0x12
104
#define CYGNUM_HAL_VECTOR_DATA_ACCESS_EXCEPTION       0x13
105
#define CYGNUM_HAL_VECTOR_DATA_STORE_ERROR            0x14
106
#define CYGNUM_HAL_VECTOR_DIVISION_EXCEPTION          0x17
107
#define CYGNUM_HAL_VECTOR_COMMIT_EXCEPTION            0x19
108
#define CYGNUM_HAL_VECTOR_COMPOUND_EXCEPTION          0x20
109
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_1  0x21
110
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_2  0x22
111
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_3  0x23
112
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_4  0x24
113
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_5  0x25
114
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_6  0x26
115
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_7  0x27
116
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_8  0x28
117
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_9  0x29
118
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_10 0x2A
119
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_11 0x2B
120
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_12 0x2C
121
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_13 0x2D
122
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_14 0x2E
123
#define CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_15 0x2F
124
#define CYGNUM_HAL_VECTOR_SYSCALL                     0x80  // tira gr0,#0
125
#define CYGNUM_HAL_VECTOR_BREAKPOINT_TRAP             0x81  // tira gr0,#1
126
#define CYGNUM_HAL_VECTOR_BREAKPOINT                  0xFF  // break
127
 
128
#define CYGNUM_HAL_VSR_MIN                     0
129
#define CYGNUM_HAL_VSR_MAX                   255
130
#define CYGNUM_HAL_VSR_COUNT                 256
131
#define CYGNUM_HAL_ISR_COUNT                 256  // 1-1 mapping
132
 
133
// Exception vectors. These are the values used when passed out to an
134
// external exception handler using cyg_hal_deliver_exception()
135
 
136
#define CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION \
137
          CYGNUM_HAL_VECTOR_ILLEGAL_INSTRUCTION
138
#define CYGNUM_HAL_EXCEPTION_INTERRUPT \
139
          CYGNUM_HAL_VECTOR_SOFTWARE_INTERRUPT
140
 
141
#define CYGNUM_HAL_EXCEPTION_CODE_ACCESS    CYGNUM_HAL_VECTOR_INSTR_ACCESS_ERROR
142
#define CYGNUM_HAL_EXCEPTION_DATA_ACCESS    CYGNUM_HAL_VECTOR_DATA_ACCESS_ERROR
143
 
144
#define CYGNUM_HAL_EXCEPTION_MIN     CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION
145
#define CYGNUM_HAL_EXCEPTION_MAX     CYGNUM_HAL_EXCEPTION_DATA_ACCESS
146
#define CYGNUM_HAL_EXCEPTION_COUNT   (CYGNUM_HAL_EXCEPTION_MAX - \
147
                                      CYGNUM_HAL_EXCEPTION_MIN + 1)
148
 
149
#define CYGNUM_HAL_ISR_MIN CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_1
150
#define CYGNUM_HAL_ISR_MAX CYGNUM_HAL_VECTOR_EXTERNAL_INTERRUPT_LEVEL_15
151
 
152
//--------------------------------------------------------------------------
153
// Static data used by HAL
154
 
155
// ISR tables
156
externC CYG_ADDRESS    hal_interrupt_handlers[CYGNUM_HAL_ISR_COUNT];
157
externC CYG_ADDRWORD   hal_interrupt_data[CYGNUM_HAL_ISR_COUNT];
158
externC CYG_ADDRESS    hal_interrupt_objects[CYGNUM_HAL_ISR_COUNT];
159
 
160
// VSR table
161
externC CYG_ADDRESS    hal_vsr_table[CYGNUM_HAL_VSR_COUNT];
162
 
163
// Platform setup memory size (0 if unknown by hardware)
164
externC CYG_ADDRWORD   hal_dram_size;
165
// what, if anything, this means, is platform dependent:
166
externC CYG_ADDRWORD   hal_dram_type;
167
 
168
#if CYGINT_HAL_FRV_MEM_REAL_REGION_TOP
169
 
170
externC cyg_uint8 *hal_frv_mem_real_region_top( cyg_uint8 *_regionend_ );
171
 
172
# define HAL_MEM_REAL_REGION_TOP( _regionend_ ) \
173
    hal_frv_mem_real_region_top( _regionend_ )
174
#endif
175
 
176
//--------------------------------------------------------------------------
177
// Default ISR
178
// The #define is used to test whether this routine exists, and to allow
179
// code outside the HAL to call it.
180
 
181
externC cyg_uint32 hal_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
182
 
183
#define HAL_DEFAULT_ISR hal_default_isr
184
 
185
//--------------------------------------------------------------------------
186
// Interrupt state storage
187
 
188
typedef cyg_uint32 CYG_INTERRUPT_STATE;
189
 
190
//--------------------------------------------------------------------------
191
// Interrupt control macros
192
 
193
externC cyg_uint32 hal_disable_interrupts(void);
194
externC void       hal_enable_interrupts(void);
195
externC void       hal_restore_interrupts(cyg_uint32);
196
externC cyg_uint32 hal_query_interrupts(void);
197
 
198
// On this processor, interrupts are controlled by level.  Since eCos
199
// only has the notion of "off" and "on", this will be emulated by
200
// NONE-level and ALL-level.
201
#define HAL_DISABLE_INTERRUPTS(_old_)           \
202
CYG_MACRO_START                                 \
203
    register cyg_uint32 reg;                    \
204
    asm volatile (                              \
205
        "movsg psr,%0\n"                        \
206
        "\tsetlos (0x0F<<3),gr5\n"              \
207
        "\tor %0,gr5,gr5\n"                     \
208
        "\tmovgs gr5,psr\n"                     \
209
        : "=r" (reg)                            \
210
        :                                       \
211
        : "gr5" /* Clobber list */              \
212
        );                                      \
213
    (_old_) = (reg);                            \
214
CYG_MACRO_END
215
 
216
#define HAL_ENABLE_INTERRUPTS()                 \
217
CYG_MACRO_START                                 \
218
    asm volatile (                              \
219
        "movsg psr,gr4\n"                       \
220
        "\tsetlos (0x0F<<3),gr5\n"              \
221
        "\tnot gr5,gr5\n"                       \
222
        "\tand gr4,gr5,gr5\n"                   \
223
        "\tmovgs gr5,psr\n"                     \
224
        :                                       \
225
        :                                       \
226
        : "gr4","gr5" /* Clobber list */        \
227
        );                                      \
228
CYG_MACRO_END
229
 
230
// This should work, but breaks compiler
231
#if 0
232
#define HAL_RESTORE_INTERRUPTS(_old_)           \
233
CYG_MACRO_START                                 \
234
    asm volatile (                              \
235
        "movsg psr,gr4\n"                       \
236
        "\tsetlos 1,gr5\n"                      \
237
        "\tand %0,gr5,gr5\n"                    \
238
        "\tor gr5,gr4,gr4\n"                    \
239
        "\tmovgs gr4,psr\n"                     \
240
        :                                       \
241
        : "g" (_old_)                           \
242
        : "gr4","gr5" /* Clobber list */        \
243
        );                                      \
244
CYG_MACRO_END
245
#else
246
#define HAL_RESTORE_INTERRUPTS(_old_)           \
247
   hal_restore_interrupts(_old_)
248
#endif
249
 
250
#define HAL_QUERY_INTERRUPTS(_old_)             \
251
  _old_ = hal_query_interrupts()
252
 
253
//--------------------------------------------------------------------------
254
// Routine to execute DSRs using separate interrupt stack
255
 
256
#ifdef  CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
257
externC void hal_interrupt_stack_call_pending_DSRs(void);
258
#define HAL_INTERRUPT_STACK_CALL_PENDING_DSRS() \
259
    hal_interrupt_stack_call_pending_DSRs()
260
 
261
#if 0 // Interrupt stacks not implemented yet
262
// these are offered solely for stack usage testing
263
// if they are not defined, then there is no interrupt stack.
264
#define HAL_INTERRUPT_STACK_BASE cyg_interrupt_stack_base
265
#define HAL_INTERRUPT_STACK_TOP  cyg_interrupt_stack
266
// use them to declare these extern however you want:
267
//       extern char HAL_INTERRUPT_STACK_BASE[];
268
//       extern char HAL_INTERRUPT_STACK_TOP[];
269
// is recommended
270
#endif // 0
271
#endif
272
 
273
//--------------------------------------------------------------------------
274
// Vector translation.
275
 
276
#ifndef HAL_TRANSLATE_VECTOR
277
#define HAL_TRANSLATE_VECTOR(_vector_,_index_) \
278
    (_index_) = (_vector_)
279
#endif
280
 
281
//--------------------------------------------------------------------------
282
// Interrupt and VSR attachment macros
283
 
284
#define HAL_INTERRUPT_IN_USE( _vector_, _state_)                          \
285
    CYG_MACRO_START                                                       \
286
    cyg_uint32 _index_;                                                   \
287
    HAL_TRANSLATE_VECTOR ((_vector_), _index_);                           \
288
                                                                          \
289
    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)hal_default_isr ) \
290
        (_state_) = 0;                                                    \
291
    else                                                                  \
292
        (_state_) = 1;                                                    \
293
    CYG_MACRO_END
294
 
295
#define HAL_INTERRUPT_ATTACH( _vector_, _isr_, _data_, _object_ )          \
296
    CYG_MACRO_START                                                        \
297
    if( hal_interrupt_handlers[_vector_] == (CYG_ADDRESS)hal_default_isr ) \
298
    {                                                                      \
299
        hal_interrupt_handlers[_vector_] = (CYG_ADDRESS)_isr_;             \
300
        hal_interrupt_data[_vector_] = (CYG_ADDRWORD) _data_;              \
301
        hal_interrupt_objects[_vector_] = (CYG_ADDRESS)_object_;           \
302
    }                                                                      \
303
    CYG_MACRO_END
304
 
305
#define HAL_INTERRUPT_DETACH( _vector_, _isr_ )                            \
306
    CYG_MACRO_START                                                        \
307
    if( hal_interrupt_handlers[_vector_] == (CYG_ADDRESS)_isr_ )           \
308
    {                                                                      \
309
        hal_interrupt_handlers[_vector_] = (CYG_ADDRESS)hal_default_isr;   \
310
        hal_interrupt_data[_vector_] = 0;                                  \
311
        hal_interrupt_objects[_vector_] = 0;                               \
312
    }                                                                      \
313
    CYG_MACRO_END
314
 
315
#define HAL_VSR_GET( _vector_, _pvsr_ )                         \
316
    *(CYG_ADDRESS *)(_pvsr_) = hal_vsr_table[_vector_];
317
 
318
 
319
#define HAL_VSR_SET( _vector_, _vsr_, _poldvsr_ )               \
320
    CYG_MACRO_START                                             \
321
    if( _poldvsr_ != NULL )                                     \
322
        *(CYG_ADDRESS *)_poldvsr_ = hal_vsr_table[_vector_];    \
323
    hal_vsr_table[_vector_] = (CYG_ADDRESS)_vsr_;               \
324
    CYG_MACRO_END
325
 
326
//--------------------------------------------------------------------------
327
// Interrupt controller access
328
 
329
externC void hal_interrupt_mask(int);
330
externC void hal_interrupt_unmask(int);
331
externC void hal_interrupt_acknowledge(int);
332
externC void hal_interrupt_configure(int, int, int);
333
externC void hal_interrupt_set_level(int, int);
334
 
335
#define HAL_INTERRUPT_MASK( _vector_ )                     \
336
    hal_interrupt_mask( _vector_ )
337
#define HAL_INTERRUPT_UNMASK( _vector_ )                   \
338
    hal_interrupt_unmask( _vector_ )
339
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )              \
340
    hal_interrupt_acknowledge( _vector_ )
341
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ ) \
342
    hal_interrupt_configure( _vector_, _level_, _up_ )
343
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )       \
344
    hal_interrupt_set_level( _vector_, _level_ )
345
 
346
//--------------------------------------------------------------------------
347
// Clock control
348
 
349
externC void hal_clock_initialize(cyg_uint32);
350
externC void hal_clock_read(cyg_uint32 *);
351
externC void hal_clock_reset(cyg_uint32, cyg_uint32);
352
 
353
#define HAL_CLOCK_INITIALIZE( _period_ )   hal_clock_initialize( _period_ )
354
#define HAL_CLOCK_RESET( _vec_, _period_ ) hal_clock_reset( _vec_, _period_ )
355
#define HAL_CLOCK_READ( _pvalue_ )         hal_clock_read( _pvalue_ )
356
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY
357
# ifndef HAL_CLOCK_LATENCY
358
#  define HAL_CLOCK_LATENCY( _pvalue_ )    HAL_CLOCK_READ( (cyg_uint32 *)_pvalue_ )
359
# endif
360
#endif
361
 
362
//--------------------------------------------------------------------------
363
#endif // ifndef CYGONCE_HAL_INTR_H
364
// 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.