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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [mn10300/] [am31/] [v2_0/] [include/] [variant.inc] - Blame information for rev 587

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

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_HAL_VARIANT_INC
2
#define CYGONCE_HAL_VARIANT_INC
3
##=============================================================================
4
##
5
##      variant.inc
6
##
7
##      AM31 assembler header file
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):   nickg
46
## Contributors:        nickg
47
## Date:        1999-04-06
48
## Purpose:     AM31 definitions.
49
## Description: This file contains various definitions and macros that are
50
##              useful for writing assembly code for the AM31 CPU variant.
51
## Usage:
52
##              #include 
53
##              ...
54
##
55
##
56
######DESCRIPTIONEND####
57
##
58
##=============================================================================
59
 
60
#include 
61
 
62
#include 
63
 
64
 
65
#------------------------------------------------------------------------------
66
# Register definitions
67
 
68
#define NMICR   0x34000100      // NMI control register
69
#define DCR     0x20000030      // Debug control register
70
#define ISR     0x20000034      // Interrupt control register
71
 
72
#define DCR_DE  0x0010          // DE bit in DCR
73
 
74
#------------------------------------------------------------------------------
75
# CPU state save and restore macros
76
 
77
        .macro  hal_cpu_save_all
78
        movm    [d2,d3,a2,a3,other],(sp)                # push all registers
79
        .endm
80
 
81
        .macro  hal_cpu_load_all
82
        movm    (sp),[d2,d3,a2,a3,other]                # pop regs
83
        .endm
84
 
85
        .macro  hal_cpu_get_psw reg
86
        mov     psw,\reg
87
        .endm
88
 
89
        .macro  hal_cpu_set_psw reg
90
        mov     \reg,psw
91
        .endm
92
 
93
# Location of PC in saved register context (HAL_SavedRegisters)
94
#define SAVED_CONTEXT_PC_OFFSET          56
95
 
96
##-----------------------------------------------------------------------------
97
# It appears that there is an undocumented extra bit
98
# in the PSW that masks the delivery of NMIs. It is in
99
# the upper 16 bits of the register that we cannot access
100
# directly. So, to clear it, we must set up a fake interrupt
101
# state and do an RTI to load the PSW. We need to do this if
102
# we are going to be able to set breakpoints in NMI handlers.
103
# Note that the AM33 has a documented NMID at bit 17 of the
104
# extended PSW (along with instructions to access it).
105
 
106
        .macro  hal_cpu_clear_nmid
107
        mov     PSW,d3                          # D3 = PSW
108
        and     0xFFFF,d3
109
        mov     nmid\@,d2                       # D2 = Next PC
110
        movm    [d2,d3],(sp)                    # Push
111
        rti                                     # and load into CPU
112
nmid\@:
113
        .endm
114
 
115
 
116
##-----------------------------------------------------------------------------
117
## Register addresses and initialization values
118
 
119
        .equ    IOBCTR  ,0x32000010
120
        .equ    MEMCTR0 ,0x32000020
121
        .equ    MEMCTR1 ,0x32000022
122
        .equ    MEMCTR2 ,0x32000024
123
        .equ    MEMCTR3 ,0x32000026
124
        .equ    MEMCTR4 ,0x32000028
125
        .equ    MEMCTR5 ,0x3200002a
126
        .equ    MEMCTR6 ,0x3200002c
127
        .equ    MEMCTR7 ,0x3200002e
128
        .equ    DRAMCTR ,0x32000040
129
        .equ    REFCNT  ,0x32000042
130
 
131
        .equ    INIT_MEMCTR0,0x1200     # 2wait
132
        .equ    INIT_MEMCTR1,0x0120     # 1wait-32bit-
133
        .equ    INIT_MEMCTR2,0x0065
134
        .equ    INIT_DRAMCTR,0x0287
135
        .equ    INIT_REFCNT,0x00eb
136
 
137
        .equ    P2OUT   ,0x36008004
138
        .equ    P2MD    ,0x36008024
139
        .equ    P2SS    ,0x36008044
140
        .equ    P2DIR   ,0x36008064
141
 
142
        .equ    INIT_P2MD,0xf0
143
        .equ    INIT_P2DIR,0xff
144
 
145
#------------------------------------------------------------------------------
146
# MEMC macros.
147
 
148
#ifndef CYGPKG_HAL_MN10300_MEMC_DEFINED
149
 
150
        .macro  hal_memc_init
151
        mov     INIT_MEMCTR0,d2
152
        movhu   d2,(MEMCTR0)
153
 
154
        mov     INIT_MEMCTR1,d2
155
        movhu   d2,(MEMCTR1)
156
 
157
        mov     INIT_MEMCTR2,d2
158
        movhu   d2,(MEMCTR2)
159
 
160
        mov     INIT_REFCNT,d2
161
        movhu   d2,(REFCNT)
162
 
163
        mov     INIT_DRAMCTR,d2
164
        movhu   d2,(DRAMCTR)
165
        .endm
166
 
167
#define CYGPKG_HAL_MN10300_MEMC_DEFINED
168
 
169
#endif
170
 
171
##-----------------------------------------------------------------------------
172
# Default interrupt decoding macros.
173
 
174
#ifndef CYGPKG_HAL_MN10300_INTC_DEFINED
175
 
176
 
177
 
178
        # initialize all interrupts to disabled
179
        .macro  hal_intc_init
180
        .endm
181
 
182
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
183
 
184
#define CYG_ISR_TABLE_SIZE      10
185
 
186
        .macro  hal_intc_decode dreg,areg,dreg1
187
        mov     _mn10300_interrupt_control,\areg
188
        movhu   (0x100,\areg),\dreg1            # dreg1 = IAGR
189
        mov     (0,a2),\dreg                    # dreg = vector priority
190
        mov     \dreg1,(0,a2)                   # store real vector in saved state
191
        asl     2,\dreg                         # dreg = byte index of isr
192
        add     12,\dreg                        # skip NMI vectors
193
        .endm
194
 
195
#define CYGPKG_HAL_MN10300_INTC_DECODE_DEFINED
196
 
197
#else
198
 
199
#define CYG_ISR_TABLE_SIZE       34
200
 
201
        # decode the interrupt
202
        .macro  hal_intc_decode dreg,areg,dreg1
203
        mov     _mn10300_interrupt_control,\areg
204
        movhu   (0x100,\areg),\dreg             # dreg = IAGR
205
        mov     \dreg,(0,a2)                    # store real vector in saved state
206
        add     12,\dreg                        # skip NMI vectors
207
        .endm
208
 
209
#define CYGPKG_HAL_MN10300_INTC_DECODE_DEFINED
210
 
211
#endif
212
 
213
#define CYGPKG_HAL_MN10300_INTC_DEFINED
214
 
215
#endif
216
 
217
 
218
#------------------------------------------------------------------------------
219
# Diagnostics macros.
220
 
221
#ifndef CYGPKG_HAL_MN10300_DIAG_DEFINED
222
 
223
        .macro  hal_diag_init
224
        # Set up LED
225
        mov     INIT_P2MD,d2
226
        movbu   d2,(P2MD)
227
        mov     INIT_P2DIR,d2
228
        movbu   d2,(P2DIR)
229
        .endm
230
 
231
        .macro  hal_diag_excpt_start
232
        .endm
233
 
234
        .macro  hal_diag_intr_start
235
        .endm
236
 
237
        .macro  hal_diag_restore
238
        .endm
239
 
240
        .macro  hal_diag_led val
241
        movm    [d2],(sp)
242
        mov     \val,d2
243
        asl     4,d2
244
        movbu   d2,(P2OUT)
245
        movm    (sp),[d2]
246
        .endm
247
 
248
 
249
        .macro  hal_diag_data
250
led_count:      .long 0
251
led_value:      .byte 0x40
252
led_foo1:       .byte 0x00 # Keep alignment to work around compiler/linker bug
253
led_foo2:       .byte 0x00
254
led_foo3:       .byte 0x00
255
        .endm
256
 
257
#define CYGPKG_HAL_MN10300_DIAG_DEFINED
258
 
259
#endif
260
 
261
#------------------------------------------------------------------------------
262
# Monitor initialization.
263
 
264
#ifndef CYGPKG_HAL_MN10300_MON_DEFINED
265
 
266
        .macro  hal_mon_init
267
        hal_mon_init_vectors
268
        hal_mon_init_vsr
269
        .endm
270
 
271
#if defined(CYG_HAL_STARTUP_ROM) ||             \
272
    defined(CYGPKG_HAL_MN10300_AM31_SIM)
273
        .macro  hal_mon_init_vectors
274
        mov     _mn10300_interrupt_vectors,a0
275
        mov     __hardware_vector_0,d0
276
        movhu   d0,(0,a0)
277
        mov     __hardware_vector_1,d0
278
        movhu   d0,(4,a0)
279
        mov     __hardware_vector_2,d0
280
        movhu   d0,(8,a0)
281
        mov     __hardware_vector_3,d0
282
        movhu   d0,(12,a0)
283
        mov     __hardware_vector_4,d0
284
        movhu   d0,(16,a0)
285
        mov     __hardware_vector_5,d0
286
        movhu   d0,(20,a0)
287
        mov     __hardware_vector_6,d0
288
        movhu   d0,(24,a0)
289
        .endm
290
#else
291
        .macro  hal_mon_init_vectors
292
        .endm
293
#endif
294
 
295
#if defined(CYG_HAL_STARTUP_RAM)
296
 
297
        # init vsr table in SRAM where the ROM
298
        # vectors the interrupts.
299
 
300
        .macro  hal_mon_init_vsr
301
        mov     _hal_vsr_table,a0
302
        mov     __default_interrupt_vsr,d0
303
        mov     d0,(0,a0)
304
        mov     d0,(4,a0)
305
        mov     d0,(8,a0)
306
#ifndef CYGSEM_HAL_USE_ROM_MONITOR_CygMon
307
        # When using Cygmon, leave level 3 for GDB
308
        # Ctrl-C interrupts.
309
        mov     d0,(12,a0)
310
#endif
311
        mov     d0,(16,a0)
312
        mov     d0,(20,a0)
313
        mov     d0,(24,a0)
314
        mov     __default_nmi_vsr,d0
315
        mov     d0,(28,a0)
316
        mov     __default_trap_vsr,d0
317
        mov     d0,(32,a0)
318
        .endm
319
 
320
#else
321
        .macro  hal_mon_init_vsr
322
        .endm
323
#endif
324
 
325
#if !(defined(CYG_HAL_STARTUP_ROM)              || \
326
        defined(CYGPKG_HAL_MN10300_AM31_SIM)    || \
327
        !defined(CYGSEM_HAL_USE_ROM_MONITOR))
328
 
329
#define CYG_HAL_MN10300_VSR_TABLE_DEFINED
330
 
331
#endif
332
 
333
 
334
 
335
#define CYGPKG_HAL_MN10300_MON_DEFINED
336
 
337
#endif
338
 
339
 
340
 
341
#------------------------------------------------------------------------------
342
#endif // ifndef CYGONCE_HAL_VARIANT_INC
343
# end of variant.inc

powered by: WebSVN 2.1.0

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