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

Subversion Repositories openrisc_me

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

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
//      hal_intr.h
6
//
7
//      HAL Interrupt and clock support
8
//
9
//==========================================================================
10
//####ECOSGPLCOPYRIGHTBEGIN####
11
// -------------------------------------------
12
// This file is part of eCos, the Embedded Configurable Operating System.
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under
16
// the terms of the GNU General Public License as published by the Free
17
// Software Foundation; either version 2 or (at your option) any later version.
18
//
19
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22
// for more details.
23
//
24
// You should have received a copy of the GNU General Public License along
25
// with eCos; if not, write to the Free Software Foundation, Inc.,
26
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27
//
28
// As a special exception, if other files instantiate templates or use macros
29
// or inline functions from this file, or you compile this file and link it
30
// with other works to produce a work based on this file, this file does not
31
// by itself cause the resulting work to be covered by the GNU General Public
32
// License. However the source code for this file must still be made available
33
// in accordance with section (3) of the GNU General Public License.
34
//
35
// This exception does not invalidate any other reasons why a work based on
36
// this file might be covered by the GNU General Public License.
37
//
38
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39
// at http://sources.redhat.com/ecos/ecos-license/
40
// -------------------------------------------
41
//####ECOSGPLCOPYRIGHTEND####
42
//==========================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):    yoshinori sato
46
// Contributors: yoshinori sato
47
// Date:         2002-02-13
48
// Purpose:      Define Interrupt support
49
// Description:  The macros defined here provide the HAL APIs for handling
50
//               interrupts and the clock.
51
// Usage:
52
//               #include <cyg/hal/hal_intr.h>
53
//               ...
54
//              
55
//
56
//####DESCRIPTIONEND####
57
//
58
//==========================================================================
59
 
60
#include <pkgconf/hal.h>
61
 
62
#include <cyg/infra/cyg_type.h>
63
#include <cyg/hal/hal_io.h>
64
 
65
#include <cyg/hal/var_intr.h>
66
 
67
//--------------------------------------------------------------------------
68
// Static data used by HAL
69
 
70
// ISR tables
71
externC volatile CYG_ADDRESS    hal_interrupt_handlers[CYGNUM_HAL_ISR_COUNT];
72
externC volatile CYG_ADDRWORD   hal_interrupt_data[CYGNUM_HAL_ISR_COUNT];
73
externC volatile CYG_ADDRESS    hal_interrupt_objects[CYGNUM_HAL_ISR_COUNT];
74
 
75
// VSR table
76
externC volatile CYG_ADDRESS    hal_vsr_table[CYGNUM_HAL_VSR_COUNT];
77
 
78
//--------------------------------------------------------------------------
79
// Default ISR
80
// The #define is used to test whether this routine exists, and to allow
81
// us to call it.
82
 
83
externC cyg_uint32 hal_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
84
 
85
#define HAL_DEFAULT_ISR hal_default_isr
86
 
87
//--------------------------------------------------------------------------
88
// Interrupt state storage
89
 
90
typedef cyg_uint32 CYG_INTERRUPT_STATE;
91
 
92
//--------------------------------------------------------------------------
93
 
94
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
95
 
96
// Routine to execute DSRs using separate interrupt stack
97
externC void hal_interrupt_stack_call_pending_DSRs(void);
98
#define HAL_INTERRUPT_STACK_CALL_PENDING_DSRS() \
99
    hal_interrupt_stack_call_pending_DSRs()
100
 
101
// these are offered solely for stack usage testing
102
// if they are not defined, then there is no interrupt stack.
103
#define HAL_INTERRUPT_STACK_BASE cyg_interrupt_stack_base
104
#define HAL_INTERRUPT_STACK_TOP  cyg_interrupt_stack
105
// use them to declare these extern however you want:
106
//       extern char HAL_INTERRUPT_STACK_BASE[];
107
//       extern char HAL_INTERRUPT_STACK_TOP[];
108
// is recommended
109
 
110
#endif
111
 
112
//--------------------------------------------------------------------------
113
// Interrupt control macros
114
 
115
#define HAL_DISABLE_INTERRUPTS(_old_)   \
116
        asm volatile (                  \
117
            "sub.l er0,er0\n\t"         \
118
            "stc ccr,r0l\n\t"           \
119
            "orc #0x80,ccr\n\t"        \
120
            "and.b #0xc0,r0l\n\t"       \
121
            "mov.l er0,%0"          \
122
            : "=r"(_old_)               \
123
            :                           \
124
            : "er0"                      \
125
            );
126
 
127
#define HAL_ENABLE_INTERRUPTS()         \
128
        asm volatile (                  \
129
            "andc #0x3f,ccr"             \
130
            );
131
 
132
#define HAL_RESTORE_INTERRUPTS(_old_)   \
133
        asm volatile (                  \
134
            "mov.l %0,er0\n\t"          \
135
            "and.b #0xc0,r0l\n\t"       \
136
            "stc ccr,r0h\n\t"           \
137
            "and.b #0x3f,r0h\n\t"       \
138
            "or.b r0h,r0l\n\t"          \
139
            "ldc r0l,ccr"               \
140
            :                           \
141
            : "r"(_old_)                \
142
            : "er0"                     \
143
            );
144
 
145
#define HAL_QUERY_INTERRUPTS(_old_)     \
146
        asm volatile (                  \
147
            "sub.l er0,er0\n\t"         \
148
            "stc ccr,r0l\n\t"           \
149
            "and.b #0xc0,r0l\n\t"       \
150
            "mov.l er0,%0"              \
151
            : "=r"(_old_)               \
152
            );
153
 
154
#ifndef HAL_TRANSLATE_VECTOR
155
 
156
#define HAL_TRANSLATE_VECTOR(_vector_,_index_) _index_ = (_vector_)
157
 
158
#endif
159
 
160
//--------------------------------------------------------------------------
161
// Interrupt and VSR attachment macros
162
 
163
#define HAL_INTERRUPT_IN_USE( _vector_, _state_)                                \
164
CYG_MACRO_START                                                                 \
165
    cyg_uint32 _index_;                                                         \
166
    HAL_TRANSLATE_VECTOR ((_vector_), _index_);                                 \
167
                                                                                \
168
    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)HAL_DEFAULT_ISR )       \
169
        (_state_) = 0;                                                          \
170
    else                                                                        \
171
        (_state_) = 1;                                                          \
172
CYG_MACRO_END
173
 
174
#define HAL_INTERRUPT_ATTACH( _vector_, _isr_, _data_, _object_ )               \
175
CYG_MACRO_START                                                                 \
176
    cyg_uint32 _index_;                                                         \
177
    HAL_TRANSLATE_VECTOR(_vector_,_index_);                                     \
178
                                                                                \
179
    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)HAL_DEFAULT_ISR )       \
180
    {                                                                           \
181
        hal_interrupt_handlers[_index_] = (CYG_ADDRESS)_isr_;                   \
182
        hal_interrupt_data[_index_] = (CYG_ADDRWORD)_data_;                     \
183
        hal_interrupt_objects[_index_] = (CYG_ADDRESS)_object_;                 \
184
    }                                                                           \
185
CYG_MACRO_END
186
 
187
#define HAL_INTERRUPT_DETACH( _vector_, _isr_ )                         \
188
CYG_MACRO_START                                                         \
189
    cyg_uint32 _index_;                                                 \
190
    HAL_TRANSLATE_VECTOR(_vector_,_index_);                             \
191
                                                                        \
192
    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)_isr_ )         \
193
    {                                                                   \
194
        hal_interrupt_handlers[_index_] = (CYG_ADDRESS)HAL_DEFAULT_ISR; \
195
        hal_interrupt_data[_index_] = 0;                                \
196
        hal_interrupt_objects[_index_] = 0;                             \
197
    }                                                                   \
198
CYG_MACRO_END
199
 
200
#define HAL_VSR_GET( _vector_, _pvsr_ )                                 \
201
    *((CYG_ADDRESS *)_pvsr_) = hal_vsr_table[_vector_];
202
 
203
 
204
#define HAL_VSR_SET( _vector_, _vsr_, _poldvsr_ )                       \
205
    if( _poldvsr_ != NULL )                                             \
206
        *(CYG_ADDRESS *)_poldvsr_ = hal_vsr_table[_vector_];            \
207
    hal_vsr_table[_vector_] = (CYG_ADDRESS)_vsr_;
208
 
209
 
210
//--------------------------------------------------------------------------
211
// Interrupt controller access
212
// Read interrupt control registers back after writing to them. This
213
// ensures that the written value is not sitting in the store buffers
214
// when interrupts are re-enabled.
215
 
216
#define HAL_INTERRUPT_MASK( _vector_ )                          \
217
        hal_interrupt_mask( _vector_ )
218
 
219
#define HAL_INTERRUPT_UNMASK( _vector_ )                        \
220
        hal_interrupt_unmask( _vector_ )
221
 
222
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )                   \
223
        hal_interrupt_acknowledge( _vector_ )
224
 
225
#if !defined(HAL_INTERRUPT_CONFIGURE)
226
 
227
#error HAL_INTERRUPT_CONFIGURE not defined by variant
228
 
229
#endif
230
 
231
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )            \
232
        hal_interrupt_set_level( _vector_, _level_ )
233
 
234
 
235
externC void hal_interrupt_mask(int vector);
236
externC void hal_interrupt_unmask(int vector);
237
externC void hal_interrupt_acknowledge(int vector);
238
externC void hal_interrupt_set_level(int vector,int level);
239
//--------------------------------------------------------------------------
240
// Clock control.
241
// This is almost all handled in the var_intr.h.
242
 
243
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY
244
#define HAL_CLOCK_LATENCY(_pvalue_) HAL_CLOCK_READ(_pvalue_)
245
#endif
246
 
247
//--------------------------------------------------------------------------
248
#endif // ifndef CYGONCE_HAL_HAL_INTR_H
249
// EOF hal_intr.h

powered by: WebSVN 2.1.0

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