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