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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [sh/] [sh4/] [v2_0/] [src/] [var_misc.c] - Blame information for rev 773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
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_DCACHE_INVALIDATE_ALL();
88
    HAL_ICACHE_INVALIDATE_ALL();
89
 
90
    // Set cache modes
91
    HAL_DCACHE_WRITE_MODE_SH(CACHE_MODE_P0|CACHE_MODE_P1);
92
#endif
93
#ifdef CYGHWR_HAL_SH_CACHE_ENABLE
94
    // Enable cache.
95
    HAL_ICACHE_ENABLE();
96
    HAL_DCACHE_ENABLE();
97
#endif
98
}
99
 
100
//---------------------------------------------------------------------------
101
void
102
hal_variant_init(void)
103
{
104
}
105
 
106
//---------------------------------------------------------------------------
107
 
108
externC cyg_uint8 cyg_hal_ILVL_table[];
109
externC cyg_uint8 cyg_hal_IMASK_table[];
110
 
111
static void
112
hal_interrupt_update_level(int vector)
113
{
114
    cyg_uint16 iprX;
115
    int level;
116
 
117
    level = cyg_hal_IMASK_table[vector] ? cyg_hal_ILVL_table[vector] : 0;
118
 
119
    switch( (vector) ) {
120
    /* IPRA */
121
    case CYGNUM_HAL_INTERRUPT_TMU0_TUNI0:
122
        HAL_READ_UINT16(CYGARC_REG_IPRA, iprX);
123
        iprX &= ~CYGARC_REG_IPRA_TMU0_MASK;
124
        iprX |= (level)*CYGARC_REG_IPRA_TMU0_PRI1;
125
        HAL_WRITE_UINT16(CYGARC_REG_IPRA, iprX);
126
        break;
127
    case CYGNUM_HAL_INTERRUPT_TMU1_TUNI1:
128
        HAL_READ_UINT16(CYGARC_REG_IPRA, iprX);
129
        iprX &= ~CYGARC_REG_IPRA_TMU1_MASK;
130
        iprX |= (level)*CYGARC_REG_IPRA_TMU1_PRI1;
131
        HAL_WRITE_UINT16(CYGARC_REG_IPRA, iprX);
132
        break;
133
    case CYGNUM_HAL_INTERRUPT_TMU2_TUNI2:
134
    case CYGNUM_HAL_INTERRUPT_TMU2_TICPI2:
135
        HAL_READ_UINT16(CYGARC_REG_IPRA, iprX);
136
        iprX &= ~CYGARC_REG_IPRA_TMU2_MASK;
137
        iprX |= (level)*CYGARC_REG_IPRA_TMU2_PRI1;
138
        HAL_WRITE_UINT16(CYGARC_REG_IPRA, iprX);
139
        break;
140
    case CYGNUM_HAL_INTERRUPT_RTC_ATI:
141
    case CYGNUM_HAL_INTERRUPT_RTC_PRI:
142
    case CYGNUM_HAL_INTERRUPT_RTC_CUI:
143
        HAL_READ_UINT16(CYGARC_REG_IPRA, iprX);
144
        iprX &= ~CYGARC_REG_IPRA_RTC_MASK;
145
        iprX |= (level)*CYGARC_REG_IPRA_RTC_PRI1;
146
        HAL_WRITE_UINT16(CYGARC_REG_IPRA, iprX);
147
        break;
148
 
149
    /* IPRB */
150
    case CYGNUM_HAL_INTERRUPT_SCI_ERI:
151
    case CYGNUM_HAL_INTERRUPT_SCI_RXI:
152
    case CYGNUM_HAL_INTERRUPT_SCI_TXI:
153
    case CYGNUM_HAL_INTERRUPT_SCI_TEI:
154
        HAL_READ_UINT16(CYGARC_REG_IPRB, iprX);
155
        iprX &= ~CYGARC_REG_IPRB_SCI_MASK;
156
        iprX |= (level)*CYGARC_REG_IPRB_SCI_PRI1;
157
        HAL_WRITE_UINT16(CYGARC_REG_IPRB, iprX);
158
        break;
159
    case CYGNUM_HAL_INTERRUPT_WDT_ITI:
160
        HAL_READ_UINT16(CYGARC_REG_IPRB, iprX);
161
        iprX &= ~CYGARC_REG_IPRB_WDT_MASK;
162
        iprX |= (level)*CYGARC_REG_IPRB_WDT_PRI1;
163
        HAL_WRITE_UINT16(CYGARC_REG_IPRB, iprX);
164
        break;
165
    case CYGNUM_HAL_INTERRUPT_REF_RCMI:
166
    case CYGNUM_HAL_INTERRUPT_REF_ROVI:
167
        HAL_READ_UINT16(CYGARC_REG_IPRB, iprX);
168
        iprX &= ~CYGARC_REG_IPRB_REF_MASK;
169
        iprX |= (level)*CYGARC_REG_IPRB_REF_PRI1;
170
        HAL_WRITE_UINT16(CYGARC_REG_IPRB, iprX);
171
        break;
172
 
173
    /* IPRC */
174
    case CYGNUM_HAL_INTERRUPT_HUDI:
175
        HAL_READ_UINT16(CYGARC_REG_IPRC, iprX);
176
        iprX &= ~CYGARC_REG_IPRC_HUDI_MASK;
177
        iprX |= (level)*CYGARC_REG_IPRC_HUDI_PRI1;
178
        HAL_WRITE_UINT16(CYGARC_REG_IPRC, iprX);
179
        break;
180
    case CYGNUM_HAL_INTERRUPT_GPIO:
181
        HAL_READ_UINT16(CYGARC_REG_IPRC, iprX);
182
        iprX &= ~CYGARC_REG_IPRC_GPIO_MASK;
183
        iprX |= (level)*CYGARC_REG_IPRC_GPIO_PRI1;
184
        HAL_WRITE_UINT16(CYGARC_REG_IPRC, iprX);
185
        break;
186
    case CYGNUM_HAL_INTERRUPT_DMAC_DMTE0:
187
    case CYGNUM_HAL_INTERRUPT_DMAC_DMTE1:
188
    case CYGNUM_HAL_INTERRUPT_DMAC_DMTE2:
189
    case CYGNUM_HAL_INTERRUPT_DMAC_DMTE3:
190
    case CYGNUM_HAL_INTERRUPT_DMAC_DMAE:
191
        HAL_READ_UINT16(CYGARC_REG_IPRC, iprX);
192
        iprX &= ~CYGARC_REG_IPRC_DMAC_MASK;
193
        iprX |= (level)*CYGARC_REG_IPRC_DMAC_PRI1;
194
        HAL_WRITE_UINT16(CYGARC_REG_IPRC, iprX);
195
        break;
196
    case CYGNUM_HAL_INTERRUPT_SCIF_ERI:
197
    case CYGNUM_HAL_INTERRUPT_SCIF_RXI:
198
    case CYGNUM_HAL_INTERRUPT_SCIF_BRI:
199
    case CYGNUM_HAL_INTERRUPT_SCIF_TXI:
200
        HAL_READ_UINT16(CYGARC_REG_IPRC, iprX);
201
        iprX &= ~CYGARC_REG_IPRC_SCIF_MASK;
202
        iprX |= (level)*CYGARC_REG_IPRC_SCIF_PRI1;
203
        HAL_WRITE_UINT16(CYGARC_REG_IPRC, iprX);
204
        break;
205
#if (CYGARC_SH_MOD_INTC == 2)
206
#ifndef CYGHWR_HAL_SH_IRQ_USE_IRQLVL
207
    case CYGNUM_HAL_INTERRUPT_IRL0:
208
        HAL_READ_UINT16(CYGARC_REG_IPRD, iprX);
209
        iprX &= ~CYGARC_REG_IPRD_IRL0_MASK;
210
        iprX |= (level)*CYGARC_REG_IPRD_IRL0_PRI1;
211
        HAL_WRITE_UINT16(CYGARC_REG_IPRD, iprX);
212
        break;
213
    case CYGNUM_HAL_INTERRUPT_IRL1:
214
        HAL_READ_UINT16(CYGARC_REG_IPRD, iprX);
215
        iprX &= ~CYGARC_REG_IPRD_IRL1_MASK;
216
        iprX |= (level)*CYGARC_REG_IPRD_IRL1_PRI1;
217
        HAL_WRITE_UINT16(CYGARC_REG_IPRD, iprX);
218
        break;
219
    case CYGNUM_HAL_INTERRUPT_IRL2:
220
        HAL_READ_UINT16(CYGARC_REG_IPRD, iprX);
221
        iprX &= ~CYGARC_REG_IPRD_IRL2_MASK;
222
        iprX |= (level)*CYGARC_REG_IPRD_IRL2_PRI1;
223
        HAL_WRITE_UINT16(CYGARC_REG_IPRD, iprX);
224
        break;
225
    case CYGNUM_HAL_INTERRUPT_IRL3:
226
        HAL_READ_UINT16(CYGARC_REG_IPRD, iprX);
227
        iprX &= ~CYGARC_REG_IPRD_IRL3_MASK;
228
        iprX |= (level)*CYGARC_REG_IPRD_IRL3_PRI1;
229
        HAL_WRITE_UINT16(CYGARC_REG_IPRD, iprX);
230
        break;
231
#endif
232
    case CYGNUM_HAL_INTERRUPT_PCISERR:
233
    {
234
        cyg_uint32 intpri;
235
        HAL_READ_UINT32(CYGARC_REG_INTPRI00, intpri);
236
        intpri &= ~CYGARC_REG_INTPRI00_PCISERR_MASK;
237
        intpri |= (level)*CYGARC_REG_INTPRI00_PCISERR_PRI1;
238
        HAL_WRITE_UINT32(CYGARC_REG_INTPRI00, intpri);
239
        break;
240
    }
241
    case CYGNUM_HAL_INTERRUPT_PCIDMA3 ... CYGNUM_HAL_INTERRUPT_PCIERR:
242
    {
243
        cyg_uint32 intpri;
244
        HAL_READ_UINT32(CYGARC_REG_INTPRI00, intpri);
245
        intpri &= ~CYGARC_REG_INTPRI00_PCIERR_MASK;
246
        intpri |= (level)*CYGARC_REG_INTPRI00_PCIERR_PRI1;
247
        HAL_WRITE_UINT32(CYGARC_REG_INTPRI00, intpri);
248
        break;
249
    }
250
    case CYGNUM_HAL_INTERRUPT_TUNI3:
251
    {
252
        cyg_uint32 intpri;
253
        HAL_READ_UINT32(CYGARC_REG_INTPRI00, intpri);
254
        intpri &= ~CYGARC_REG_INTPRI00_TUNI3_MASK;
255
        intpri |= (level)*CYGARC_REG_INTPRI00_TUNI3_PRI1;
256
        HAL_WRITE_UINT32(CYGARC_REG_INTPRI00, intpri);
257
        break;
258
    }
259
    case CYGNUM_HAL_INTERRUPT_TUNI4:
260
    {
261
        cyg_uint32 intpri;
262
        HAL_READ_UINT32(CYGARC_REG_INTPRI00, intpri);
263
        intpri &= ~CYGARC_REG_INTPRI00_TUNI4_MASK;
264
        intpri |= (level)*CYGARC_REG_INTPRI00_TUNI4_PRI1;
265
        HAL_WRITE_UINT32(CYGARC_REG_INTPRI00, intpri);
266
        break;
267
    }
268
#endif // CYGARC_SH_MOD_INTC
269
    case CYGNUM_HAL_INTERRUPT_RESERVED_1E0:
270
    case CYGNUM_HAL_INTERRUPT_RESERVED_3E0:
271
    case CYGNUM_HAL_INTERRUPT_RESERVED_5C0:
272
    case CYGNUM_HAL_INTERRUPT_RESERVED_5E0:
273
    case CYGNUM_HAL_INTERRUPT_RESERVED_6E0:
274
        /* Do nothing for these reserved vectors. */
275
        break;
276
 
277
    // Platform extensions
278
    CYGPRI_HAL_INTERRUPT_UPDATE_LEVEL_PLF(vector, level)
279
 
280
    default:
281
        CYG_FAIL("Unknown interrupt vector");
282
        break;
283
    }
284
}
285
 
286
void
287
hal_interrupt_set_level(int vector, int level)
288
{
289
    CYG_ASSERT((0 <= (level) && 15 >= (level)), "Illegal level");
290
    CYG_ASSERT((CYGNUM_HAL_ISR_MIN <= (vector)
291
                && CYGNUM_HAL_ISR_MAX >= (vector)), "Illegal vector");
292
 
293
    cyg_hal_ILVL_table[vector] = level;
294
 
295
    hal_interrupt_update_level(vector);
296
}
297
 
298
void
299
hal_interrupt_mask(int vector)
300
{
301
#ifdef CYGPKG_HAL_SH_7751
302
    if (vector >= CYGNUM_HAL_INTERRUPT_PCISERR && vector <= CYGNUM_HAL_INTERRUPT_TUNI4) {
303
        HAL_WRITE_UINT32(CYGARC_REG_INTMSK00, 1 << (vector - CYGNUM_HAL_INTERRUPT_PCISERR));
304
        return;
305
    }
306
#endif
307
 
308
    switch( vector ) {
309
    case CYGNUM_HAL_INTERRUPT_NMI:
310
        break;
311
    case CYGNUM_HAL_INTERRUPT_LVL0 ... CYGNUM_HAL_INTERRUPT_LVL14:
312
        /* Normally can only be masked by fiddling Imask in SR,
313
           but some platforms use external interrupt controller,
314
           so allow regular handling. */
315
        // fall through
316
    case CYGNUM_HAL_INTERRUPT_TMU0_TUNI0 ... CYGNUM_HAL_ISR_MAX:
317
        cyg_hal_IMASK_table[vector] = 0;
318
        hal_interrupt_update_level(vector);
319
        break;
320
    case CYGNUM_HAL_INTERRUPT_RESERVED_1E0:
321
    case CYGNUM_HAL_INTERRUPT_RESERVED_3E0:
322
        /* Do nothing for these reserved vectors. */
323
        break;
324
    default:
325
        CYG_FAIL("Unknown interrupt vector");
326
        break;
327
    }
328
}
329
 
330
void
331
hal_interrupt_unmask(int vector)
332
{
333
#ifdef CYGPKG_HAL_SH_7751
334
    if (vector >= CYGNUM_HAL_INTERRUPT_PCISERR && vector <= CYGNUM_HAL_INTERRUPT_TUNI4) {
335
        HAL_WRITE_UINT32(CYGARC_REG_INTMSKCLR00, 1 << (vector - CYGNUM_HAL_INTERRUPT_PCISERR));
336
        return;
337
    }
338
#endif
339
 
340
    switch( (vector) ) {
341
    case CYGNUM_HAL_INTERRUPT_NMI:
342
        break;
343
    case CYGNUM_HAL_INTERRUPT_LVL0 ... CYGNUM_HAL_INTERRUPT_LVL14:
344
        /* Normally can only be masked by fiddling Imask in SR,
345
           but some platforms use external interrupt controller,
346
           so allow regular handling. */
347
        // fall through
348
    case CYGNUM_HAL_INTERRUPT_TMU0_TUNI0 ... CYGNUM_HAL_ISR_MAX:
349
        cyg_hal_IMASK_table[vector] = 1;
350
        hal_interrupt_update_level(vector);
351
        break;
352
    case CYGNUM_HAL_INTERRUPT_RESERVED_1E0:
353
    case CYGNUM_HAL_INTERRUPT_RESERVED_3E0:
354
        /* Do nothing for these reserved vectors. */
355
        break;
356
    default:
357
        CYG_FAIL("Unknown interrupt vector");
358
        break;
359
    }
360
}
361
 
362
void
363
hal_interrupt_acknowledge(int vector)
364
{
365
    CYGPRI_HAL_INTERRUPT_ACKNOWLEDGE_PLF(vector);
366
}
367
 
368
void
369
hal_interrupt_configure(int vector, int level, int up)
370
{
371
    CYGPRI_HAL_INTERRUPT_CONFIGURE_PLF(vector, level, up);
372
}

powered by: WebSVN 2.1.0

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