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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mn10300/] [am31/] [current/] [include/] [variant.inc] - Blame information for rev 786

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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