1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// var_misc.c
|
4 |
|
|
//
|
5 |
|
|
// HAL miscellaneous functions
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
16 |
|
|
//
|
17 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
18 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
20 |
|
|
// for more details.
|
21 |
|
|
//
|
22 |
|
|
// You should have received a copy of the GNU General Public License along
|
23 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
24 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
25 |
|
|
//
|
26 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
27 |
|
|
// or inline functions from this file, or you compile this file and link it
|
28 |
|
|
// with other works to produce a work based on this file, this file does not
|
29 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
30 |
|
|
// License. However the source code for this file must still be made available
|
31 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
32 |
|
|
//
|
33 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
34 |
|
|
// this file might be covered by the GNU General Public License.
|
35 |
|
|
//
|
36 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
37 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
38 |
|
|
// -------------------------------------------
|
39 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
40 |
|
|
//==========================================================================
|
41 |
|
|
//#####DESCRIPTIONBEGIN####
|
42 |
|
|
//
|
43 |
|
|
// Author(s): jskov
|
44 |
|
|
// Contributors: jskov, jlarmour, nickg
|
45 |
|
|
// Date: 1999-04-03
|
46 |
|
|
// Purpose: HAL miscellaneous functions
|
47 |
|
|
// Description: This file contains miscellaneous functions provided by the
|
48 |
|
|
// HAL.
|
49 |
|
|
//
|
50 |
|
|
//####DESCRIPTIONEND####
|
51 |
|
|
//
|
52 |
|
|
//===========================================================================
|
53 |
|
|
|
54 |
|
|
#include <pkgconf/hal.h>
|
55 |
|
|
|
56 |
|
|
#include <cyg/infra/cyg_type.h>
|
57 |
|
|
#include <cyg/infra/cyg_trac.h> // tracing macros
|
58 |
|
|
#include <cyg/infra/cyg_ass.h> // assertion macros
|
59 |
|
|
#include <cyg/infra/diag.h> // diag_printf
|
60 |
|
|
|
61 |
|
|
#include <cyg/hal/hal_arch.h> // HAL header
|
62 |
|
|
#include <cyg/hal/hal_cache.h> // HAL cache
|
63 |
|
|
#include <cyg/hal/hal_intr.h> // HAL interrupts/exceptions
|
64 |
|
|
|
65 |
|
|
//---------------------------------------------------------------------------
|
66 |
|
|
// Initial cache enabling
|
67 |
|
|
|
68 |
|
|
#ifdef CYGHWR_HAL_SH_CACHE_MODE_P0_WRITE_BACK
|
69 |
|
|
# define CACHE_MODE_P0 0
|
70 |
|
|
#else
|
71 |
|
|
# define CACHE_MODE_P0 CYGARC_REG_CCR_WT
|
72 |
|
|
#endif
|
73 |
|
|
|
74 |
|
|
#ifdef CYGHWR_HAL_SH_CACHE_MODE_P1_WRITE_BACK
|
75 |
|
|
# define CACHE_MODE_P1 CYGARC_REG_CCR_CB
|
76 |
|
|
#else
|
77 |
|
|
# define CACHE_MODE_P1 0
|
78 |
|
|
#endif
|
79 |
|
|
|
80 |
|
|
externC void
|
81 |
|
|
cyg_var_enable_caches(void)
|
82 |
|
|
{
|
83 |
|
|
// If relying on a ROM monitor do not invalidate the caches as the
|
84 |
|
|
// ROM monitor may have (non-synced) state in the caches.
|
85 |
|
|
#if !defined(CYGSEM_HAL_USE_ROM_MONITOR)
|
86 |
|
|
// Initialize cache.
|
87 |
|
|
HAL_UCACHE_INVALIDATE_ALL();
|
88 |
|
|
|
89 |
|
|
// Set cache modes
|
90 |
|
|
HAL_UCACHE_WRITE_MODE_SH(CACHE_MODE_P0|CACHE_MODE_P1);
|
91 |
|
|
#endif
|
92 |
|
|
#ifdef CYGHWR_HAL_SH_CACHE_ENABLE
|
93 |
|
|
// Enable cache.
|
94 |
|
|
HAL_UCACHE_ENABLE();
|
95 |
|
|
#endif
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
//---------------------------------------------------------------------------
|
99 |
|
|
void
|
100 |
|
|
hal_variant_init(void)
|
101 |
|
|
{
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
//---------------------------------------------------------------------------
|
105 |
|
|
// Interrupt function support
|
106 |
|
|
|
107 |
|
|
externC cyg_uint8 cyg_hal_ILVL_table[];
|
108 |
|
|
externC cyg_uint8 cyg_hal_IMASK_table[];
|
109 |
|
|
|
110 |
|
|
static void
|
111 |
|
|
hal_interrupt_update_level(int vector)
|
112 |
|
|
{
|
113 |
|
|
cyg_uint16 iprX;
|
114 |
|
|
int level;
|
115 |
|
|
|
116 |
|
|
level = cyg_hal_IMASK_table[vector] ? cyg_hal_ILVL_table[vector] : 0;
|
117 |
|
|
|
118 |
|
|
switch( (vector) ) {
|
119 |
|
|
/* IPRA */
|
120 |
|
|
case CYGNUM_HAL_INTERRUPT_TMU0_TUNI0:
|
121 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRA, iprX);
|
122 |
|
|
iprX &= ~CYGARC_REG_IPRA_TMU0_MASK;
|
123 |
|
|
iprX |= (level)*CYGARC_REG_IPRA_TMU0_PRI1;
|
124 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRA, iprX);
|
125 |
|
|
break;
|
126 |
|
|
case CYGNUM_HAL_INTERRUPT_TMU1_TUNI1:
|
127 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRA, iprX);
|
128 |
|
|
iprX &= ~CYGARC_REG_IPRA_TMU1_MASK;
|
129 |
|
|
iprX |= (level)*CYGARC_REG_IPRA_TMU1_PRI1;
|
130 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRA, iprX);
|
131 |
|
|
break;
|
132 |
|
|
case CYGNUM_HAL_INTERRUPT_TMU2_TUNI2:
|
133 |
|
|
case CYGNUM_HAL_INTERRUPT_TMU2_TICPI2:
|
134 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRA, iprX);
|
135 |
|
|
iprX &= ~CYGARC_REG_IPRA_TMU2_MASK;
|
136 |
|
|
iprX |= (level)*CYGARC_REG_IPRA_TMU2_PRI1;
|
137 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRA, iprX);
|
138 |
|
|
break;
|
139 |
|
|
case CYGNUM_HAL_INTERRUPT_RTC_ATI:
|
140 |
|
|
case CYGNUM_HAL_INTERRUPT_RTC_PRI:
|
141 |
|
|
case CYGNUM_HAL_INTERRUPT_RTC_CUI:
|
142 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRA, iprX);
|
143 |
|
|
iprX &= ~CYGARC_REG_IPRA_RTC_MASK;
|
144 |
|
|
iprX |= (level)*CYGARC_REG_IPRA_RTC_PRI1;
|
145 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRA, iprX);
|
146 |
|
|
break;
|
147 |
|
|
|
148 |
|
|
/* IPRB */
|
149 |
|
|
case CYGNUM_HAL_INTERRUPT_SCI_ERI:
|
150 |
|
|
case CYGNUM_HAL_INTERRUPT_SCI_RXI:
|
151 |
|
|
case CYGNUM_HAL_INTERRUPT_SCI_TXI:
|
152 |
|
|
case CYGNUM_HAL_INTERRUPT_SCI_TEI:
|
153 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRB, iprX);
|
154 |
|
|
iprX &= ~CYGARC_REG_IPRB_SCI_MASK;
|
155 |
|
|
iprX |= (level)*CYGARC_REG_IPRB_SCI_PRI1;
|
156 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRB, iprX);
|
157 |
|
|
break;
|
158 |
|
|
case CYGNUM_HAL_INTERRUPT_WDT_ITI:
|
159 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRB, iprX);
|
160 |
|
|
iprX &= ~CYGARC_REG_IPRB_WDT_MASK;
|
161 |
|
|
iprX |= (level)*CYGARC_REG_IPRB_WDT_PRI1;
|
162 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRB, iprX);
|
163 |
|
|
break;
|
164 |
|
|
case CYGNUM_HAL_INTERRUPT_REF_RCMI:
|
165 |
|
|
case CYGNUM_HAL_INTERRUPT_REF_ROVI:
|
166 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRB, iprX);
|
167 |
|
|
iprX &= ~CYGARC_REG_IPRB_REF_MASK;
|
168 |
|
|
iprX |= (level)*CYGARC_REG_IPRB_REF_PRI1;
|
169 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRB, iprX);
|
170 |
|
|
break;
|
171 |
|
|
|
172 |
|
|
#if (CYGARC_SH_MOD_INTC >= 2)
|
173 |
|
|
#ifndef CYGHWR_HAL_SH_IRQ_USE_IRQLVL
|
174 |
|
|
/* IPRC */
|
175 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ0:
|
176 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRC, iprX);
|
177 |
|
|
iprX &= ~CYGARC_REG_IPRC_IRQ0_MASK;
|
178 |
|
|
iprX |= (level)*CYGARC_REG_IPRC_IRQ0_PRI1;
|
179 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRC, iprX);
|
180 |
|
|
break;
|
181 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ1:
|
182 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRC, iprX);
|
183 |
|
|
iprX &= ~CYGARC_REG_IPRC_IRQ1_MASK;
|
184 |
|
|
iprX |= (level)*CYGARC_REG_IPRC_IRQ1_PRI1;
|
185 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRC, iprX);
|
186 |
|
|
break;
|
187 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ2:
|
188 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRC, iprX);
|
189 |
|
|
iprX &= ~CYGARC_REG_IPRC_IRQ2_MASK;
|
190 |
|
|
iprX |= (level)*CYGARC_REG_IPRC_IRQ2_PRI1;
|
191 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRC, iprX);
|
192 |
|
|
break;
|
193 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ3:
|
194 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRC, iprX);
|
195 |
|
|
iprX &= ~CYGARC_REG_IPRC_IRQ3_MASK;
|
196 |
|
|
iprX |= (level)*CYGARC_REG_IPRC_IRQ3_PRI1;
|
197 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRC, iprX);
|
198 |
|
|
break;
|
199 |
|
|
#endif
|
200 |
|
|
/* IPRD */
|
201 |
|
|
case CYGNUM_HAL_INTERRUPT_PINT_PINT07:
|
202 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRD, iprX);
|
203 |
|
|
iprX &= ~CYGARC_REG_IPRD_PINT07_MASK;
|
204 |
|
|
iprX |= (level)*CYGARC_REG_IPRD_PINT07_PRI1;
|
205 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRD, iprX);
|
206 |
|
|
break;
|
207 |
|
|
case CYGNUM_HAL_INTERRUPT_PINT_PINT8F:
|
208 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRD, iprX);
|
209 |
|
|
iprX &= ~CYGARC_REG_IPRD_PINT8F_MASK;
|
210 |
|
|
iprX |= (level)*CYGARC_REG_IPRD_PINT8F_PRI1;
|
211 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRD, iprX);
|
212 |
|
|
break;
|
213 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ5:
|
214 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRD, iprX);
|
215 |
|
|
iprX &= ~CYGARC_REG_IPRD_IRQ5_MASK;
|
216 |
|
|
iprX |= (level)*CYGARC_REG_IPRD_IRQ5_PRI1;
|
217 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRD, iprX);
|
218 |
|
|
break;
|
219 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ4:
|
220 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRD, iprX);
|
221 |
|
|
iprX &= ~CYGARC_REG_IPRD_IRQ4_MASK;
|
222 |
|
|
iprX |= (level)*CYGARC_REG_IPRD_IRQ4_PRI1;
|
223 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRD, iprX);
|
224 |
|
|
break;
|
225 |
|
|
|
226 |
|
|
/* IPRE */
|
227 |
|
|
case CYGNUM_HAL_INTERRUPT_DMAC_DEI0:
|
228 |
|
|
case CYGNUM_HAL_INTERRUPT_DMAC_DEI1:
|
229 |
|
|
case CYGNUM_HAL_INTERRUPT_DMAC_DEI2:
|
230 |
|
|
case CYGNUM_HAL_INTERRUPT_DMAC_DEI3:
|
231 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRE, iprX);
|
232 |
|
|
iprX &= ~CYGARC_REG_IPRE_DMAC_MASK;
|
233 |
|
|
iprX |= (level)*CYGARC_REG_IPRE_DMAC_PRI1;
|
234 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRE, iprX);
|
235 |
|
|
break;
|
236 |
|
|
case CYGNUM_HAL_INTERRUPT_IRDA_ERI1:
|
237 |
|
|
case CYGNUM_HAL_INTERRUPT_IRDA_RXI1:
|
238 |
|
|
case CYGNUM_HAL_INTERRUPT_IRDA_BRI1:
|
239 |
|
|
case CYGNUM_HAL_INTERRUPT_IRDA_TXI1:
|
240 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRE, iprX);
|
241 |
|
|
iprX &= ~CYGARC_REG_IPRE_IRDA_MASK;
|
242 |
|
|
iprX |= (level)*CYGARC_REG_IPRE_IRDA_PRI1;
|
243 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRE, iprX);
|
244 |
|
|
break;
|
245 |
|
|
case CYGNUM_HAL_INTERRUPT_SCIF_ERI2:
|
246 |
|
|
case CYGNUM_HAL_INTERRUPT_SCIF_RXI2:
|
247 |
|
|
case CYGNUM_HAL_INTERRUPT_SCIF_BRI2:
|
248 |
|
|
case CYGNUM_HAL_INTERRUPT_SCIF_TXI2:
|
249 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRE, iprX);
|
250 |
|
|
iprX &= ~CYGARC_REG_IPRE_SCIF_MASK;
|
251 |
|
|
iprX |= (level)*CYGARC_REG_IPRE_SCIF_PRI1;
|
252 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRE, iprX);
|
253 |
|
|
break;
|
254 |
|
|
case CYGNUM_HAL_INTERRUPT_ADC_ADI:
|
255 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRE, iprX);
|
256 |
|
|
iprX &= ~CYGARC_REG_IPRE_ADC_MASK;
|
257 |
|
|
iprX |= (level)*CYGARC_REG_IPRE_ADC_PRI1;
|
258 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRE, iprX);
|
259 |
|
|
break;
|
260 |
|
|
#endif // (CYGARC_SH_MOD_INTC >= 2)
|
261 |
|
|
|
262 |
|
|
#if (CYGARC_SH_MOD_INTC >= 3)
|
263 |
|
|
/* IPRF */
|
264 |
|
|
case CYGNUM_HAL_INTERRUPT_LCDC_LCDI:
|
265 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRF, iprX);
|
266 |
|
|
iprX &= ~CYGARC_REG_IPRF_LCDI_MASK;
|
267 |
|
|
iprX |= (level)*CYGARC_REG_IPRF_LCDI_PRI1;
|
268 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRF, iprX);
|
269 |
|
|
break;
|
270 |
|
|
case CYGNUM_HAL_INTERRUPT_PCC_PCC0:
|
271 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRF, iprX);
|
272 |
|
|
iprX &= ~CYGARC_REG_IPRF_PCC0_MASK;
|
273 |
|
|
iprX |= (level)*CYGARC_REG_IPRF_PCC0_PRI1;
|
274 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRF, iprX);
|
275 |
|
|
break;
|
276 |
|
|
case CYGNUM_HAL_INTERRUPT_PCC_PCC1:
|
277 |
|
|
HAL_READ_UINT16(CYGARC_REG_IPRF, iprX);
|
278 |
|
|
iprX &= ~CYGARC_REG_IPRF_PCC1_MASK;
|
279 |
|
|
iprX |= (level)*CYGARC_REG_IPRF_PCC1_PRI1;
|
280 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_IPRF, iprX);
|
281 |
|
|
break;
|
282 |
|
|
#endif // (CYGARC_SH_MOD_INTC >= 3)
|
283 |
|
|
|
284 |
|
|
case CYGNUM_HAL_INTERRUPT_RESERVED_1E0:
|
285 |
|
|
case CYGNUM_HAL_INTERRUPT_RESERVED_3E0:
|
286 |
|
|
/* Do nothing for these reserved vectors. */
|
287 |
|
|
break;
|
288 |
|
|
|
289 |
|
|
// Platform extensions
|
290 |
|
|
CYGPRI_HAL_INTERRUPT_UPDATE_LEVEL_PLF(vector, level)
|
291 |
|
|
|
292 |
|
|
default:
|
293 |
|
|
CYG_FAIL("Unknown interrupt vector");
|
294 |
|
|
break;
|
295 |
|
|
}
|
296 |
|
|
}
|
297 |
|
|
|
298 |
|
|
void
|
299 |
|
|
hal_interrupt_set_level(int vector, int level)
|
300 |
|
|
{
|
301 |
|
|
CYG_ASSERT((0 <= (level) && 15 >= (level)), "Illegal level");
|
302 |
|
|
CYG_ASSERT((CYGNUM_HAL_ISR_MIN <= (vector)
|
303 |
|
|
&& CYGNUM_HAL_ISR_MAX >= (vector)), "Illegal vector");
|
304 |
|
|
|
305 |
|
|
cyg_hal_ILVL_table[vector] = level;
|
306 |
|
|
|
307 |
|
|
hal_interrupt_update_level(vector);
|
308 |
|
|
}
|
309 |
|
|
|
310 |
|
|
void
|
311 |
|
|
hal_interrupt_mask(int vector)
|
312 |
|
|
{
|
313 |
|
|
switch( (vector) ) {
|
314 |
|
|
case CYGNUM_HAL_INTERRUPT_NMI:
|
315 |
|
|
/* fall through */
|
316 |
|
|
case CYGNUM_HAL_INTERRUPT_LVL0 ... CYGNUM_HAL_INTERRUPT_LVL14:
|
317 |
|
|
/* Normally can only be masked by fiddling Imask in SR,
|
318 |
|
|
but some platforms use external interrupt controller,
|
319 |
|
|
so allow regular handling. */
|
320 |
|
|
// fall through
|
321 |
|
|
case CYGNUM_HAL_INTERRUPT_TMU0_TUNI0 ... CYGNUM_HAL_ISR_MAX:
|
322 |
|
|
cyg_hal_IMASK_table[vector] = 0;
|
323 |
|
|
hal_interrupt_update_level(vector);
|
324 |
|
|
break;
|
325 |
|
|
case CYGNUM_HAL_INTERRUPT_RESERVED_1E0:
|
326 |
|
|
case CYGNUM_HAL_INTERRUPT_RESERVED_3E0:
|
327 |
|
|
/* Do nothing for these reserved vectors. */
|
328 |
|
|
break;
|
329 |
|
|
default:
|
330 |
|
|
CYG_FAIL("Unknown interrupt vector");
|
331 |
|
|
break;
|
332 |
|
|
}
|
333 |
|
|
}
|
334 |
|
|
|
335 |
|
|
void
|
336 |
|
|
hal_interrupt_unmask(int vector)
|
337 |
|
|
{
|
338 |
|
|
switch( (vector) ) {
|
339 |
|
|
case CYGNUM_HAL_INTERRUPT_NMI:
|
340 |
|
|
/* fall through */
|
341 |
|
|
case CYGNUM_HAL_INTERRUPT_LVL0 ... CYGNUM_HAL_INTERRUPT_LVL14:
|
342 |
|
|
/* Normally can only be masked by fiddling Imask in SR,
|
343 |
|
|
but some platforms use external interrupt controller,
|
344 |
|
|
so allow regular handling. */
|
345 |
|
|
// fall through
|
346 |
|
|
case CYGNUM_HAL_INTERRUPT_TMU0_TUNI0 ... CYGNUM_HAL_ISR_MAX:
|
347 |
|
|
cyg_hal_IMASK_table[vector] = 1;
|
348 |
|
|
hal_interrupt_update_level(vector);
|
349 |
|
|
break;
|
350 |
|
|
case CYGNUM_HAL_INTERRUPT_RESERVED_1E0:
|
351 |
|
|
case CYGNUM_HAL_INTERRUPT_RESERVED_3E0:
|
352 |
|
|
/* Do nothing for these reserved vectors. */
|
353 |
|
|
break;
|
354 |
|
|
default:
|
355 |
|
|
CYG_FAIL("Unknown interrupt vector");
|
356 |
|
|
break;
|
357 |
|
|
}
|
358 |
|
|
}
|
359 |
|
|
|
360 |
|
|
void
|
361 |
|
|
hal_interrupt_acknowledge(int vector)
|
362 |
|
|
{
|
363 |
|
|
#if (CYGARC_SH_MOD_INTC >= 2)
|
364 |
|
|
if ( (vector) >= CYGNUM_HAL_INTERRUPT_IRQ_IRQ0
|
365 |
|
|
&& (vector) <= CYGNUM_HAL_INTERRUPT_IRQ_IRQ5) {
|
366 |
|
|
|
367 |
|
|
cyg_uint8 irr0;
|
368 |
|
|
|
369 |
|
|
HAL_READ_UINT8(CYGARC_REG_IRR0, irr0);
|
370 |
|
|
switch ( vector ) {
|
371 |
|
|
#ifndef CYGHWR_HAL_SH_IRQ_USE_IRQLVL
|
372 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ0:
|
373 |
|
|
irr0 &= ~CYGARC_REG_IRR0_IRQ0;
|
374 |
|
|
break;
|
375 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ1:
|
376 |
|
|
irr0 &= ~CYGARC_REG_IRR0_IRQ1;
|
377 |
|
|
break;
|
378 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ2:
|
379 |
|
|
irr0 &= ~CYGARC_REG_IRR0_IRQ2;
|
380 |
|
|
break;
|
381 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ3:
|
382 |
|
|
irr0 &= ~CYGARC_REG_IRR0_IRQ3;
|
383 |
|
|
break;
|
384 |
|
|
#endif
|
385 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ4:
|
386 |
|
|
irr0 &= ~CYGARC_REG_IRR0_IRQ4;
|
387 |
|
|
break;
|
388 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ5:
|
389 |
|
|
irr0 &= ~CYGARC_REG_IRR0_IRQ5;
|
390 |
|
|
break;
|
391 |
|
|
default:
|
392 |
|
|
CYG_FAIL("Unhandled interrupt vector");
|
393 |
|
|
}
|
394 |
|
|
HAL_WRITE_UINT8(CYGARC_REG_IRR0, irr0);
|
395 |
|
|
}
|
396 |
|
|
#endif
|
397 |
|
|
|
398 |
|
|
CYGPRI_HAL_INTERRUPT_ACKNOWLEDGE_PLF(vector);
|
399 |
|
|
}
|
400 |
|
|
|
401 |
|
|
// Note: The PINTs can be masked and configured individually, even
|
402 |
|
|
// though there are only two vectors. Maybe add some fake vectors just
|
403 |
|
|
// for masking/configuring?
|
404 |
|
|
void
|
405 |
|
|
hal_interrupt_configure(int vector, int level, int up)
|
406 |
|
|
{
|
407 |
|
|
#if (CYGARC_SH_MOD_INTC >= 2)
|
408 |
|
|
if ( (vector) >= CYGNUM_HAL_INTERRUPT_IRQ_IRQ0
|
409 |
|
|
&& (vector) <= CYGNUM_HAL_INTERRUPT_IRQ_IRQ5) {
|
410 |
|
|
|
411 |
|
|
cyg_uint16 icr1, ss, mask;
|
412 |
|
|
ss = 0;
|
413 |
|
|
mask = CYGARC_REG_ICR1_SENSE_UP|CYGARC_REG_ICR1_SENSE_LEVEL;
|
414 |
|
|
if (up) ss |= CYGARC_REG_ICR1_SENSE_UP;
|
415 |
|
|
if (level) ss |= CYGARC_REG_ICR1_SENSE_LEVEL;
|
416 |
|
|
CYG_ASSERT(!(up && level), "Cannot trigger on high level!");
|
417 |
|
|
|
418 |
|
|
switch( (vector) ) {
|
419 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ5:
|
420 |
|
|
ss <<= CYGARC_REG_ICR1_SENSE_IRQ5_shift;
|
421 |
|
|
mask <<= CYGARC_REG_ICR1_SENSE_IRQ5_shift;
|
422 |
|
|
break;
|
423 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ4:
|
424 |
|
|
ss <<= CYGARC_REG_ICR1_SENSE_IRQ4_shift;
|
425 |
|
|
mask <<= CYGARC_REG_ICR1_SENSE_IRQ4_shift;
|
426 |
|
|
break;
|
427 |
|
|
#ifndef CYGHWR_HAL_SH_IRQ_USE_IRQLVL
|
428 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ3:
|
429 |
|
|
ss <<= CYGARC_REG_ICR1_SENSE_IRQ3_shift;
|
430 |
|
|
mask <<= CYGARC_REG_ICR1_SENSE_IRQ3_shift;
|
431 |
|
|
break;
|
432 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ2:
|
433 |
|
|
ss <<= CYGARC_REG_ICR1_SENSE_IRQ2_shift;
|
434 |
|
|
mask <<= CYGARC_REG_ICR1_SENSE_IRQ2_shift;
|
435 |
|
|
break;
|
436 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ1:
|
437 |
|
|
ss <<= CYGARC_REG_ICR1_SENSE_IRQ1_shift;
|
438 |
|
|
mask <<= CYGARC_REG_ICR1_SENSE_IRQ1_shift;
|
439 |
|
|
break;
|
440 |
|
|
case CYGNUM_HAL_INTERRUPT_IRQ_IRQ0:
|
441 |
|
|
ss <<= CYGARC_REG_ICR1_SENSE_IRQ0_shift;
|
442 |
|
|
mask <<= CYGARC_REG_ICR1_SENSE_IRQ0_shift;
|
443 |
|
|
break;
|
444 |
|
|
#endif
|
445 |
|
|
default:
|
446 |
|
|
CYG_FAIL("Unhandled interrupt vector");
|
447 |
|
|
}
|
448 |
|
|
|
449 |
|
|
HAL_READ_UINT16(CYGARC_REG_ICR1, icr1);
|
450 |
|
|
icr1 &= ~mask;
|
451 |
|
|
icr1 |= ss;
|
452 |
|
|
HAL_WRITE_UINT16(CYGARC_REG_ICR1, icr1);
|
453 |
|
|
}
|
454 |
|
|
#endif
|
455 |
|
|
|
456 |
|
|
CYGPRI_HAL_INTERRUPT_CONFIGURE_PLF(vector, level, up);
|
457 |
|
|
}
|
458 |
|
|
|
459 |
|
|
//---------------------------------------------------------------------------
|
460 |
|
|
// End of hal_misc.c
|