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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mn10300/] [am33/] [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
##      AM33 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, dmoseley
46
## Date:        1999-04-06
47
## Purpose:     AM33 definitions.
48
## Description: This file contains various definitions and macros that are
49
##              useful for writing assembly code for the AM33 CPU variant.
50
## Usage:
51
##              #include 
52
##              ...
53
##
54
##
55
######DESCRIPTIONEND####
56
##
57
##=============================================================================
58
 
59
#include 
60
 
61
        .am33           # Enable AM33 instruction set
62
 
63
#include 
64
 
65
#include CYGHWR_MEMORY_LAYOUT_H
66
 
67
#------------------------------------------------------------------------------
68
# Register definitions
69
 
70
#define NMICR   0xD4000000      // NMI control register
71
#define DCR     0xC0000030      // Debug control register
72
#define ISR     0xC0000034      // Interrupt control register
73
#define TBR     0xC0000024      // Trap Base Register
74
#define CHCTR   0xC0000070      // Cache Control Register
75
 
76
#define DCR_DE  0x0001          // DE bit in DCR
77
 
78
##-----------------------------------------------------------------------------
79
## Register addresses and initialization values
80
 
81
#define SDRAMCONFIG             0xDA000000
82
 
83
#define INIT_SDRAMCONFIG        0x0000002f
84
 
85
#define SC0ICR                  0xD4002004
86
#define SC1ICR                  0xD4002014
87
#define SC2ICR                  0xD4002024
88
#define TM0MD                   0xD4003000
89
#define TM1MD                   0xD4003001
90
#define TM2MD                   0xD4003002
91
#define TM3MD                   0xD4003003
92
#define TM4MD                   0xD4003080
93
#define TM5MD                   0xD4003082
94
#define TM6MD                   0xD4003084
95
#define TM7MD                   0xD4003086
96
#define TM8MD                   0xD4003088
97
#define TM9MD                   0xD400308A
98
#define TM10MD                  0xD400308C
99
#define TM11MD                  0xD400308E
100
#define DM0CTR                  0xD2000000
101
#define DM1CTR                  0xD2000100
102
#define DM2CTR                  0xD2000200
103
#define DM3CTR                  0xD2000300
104
#define WDCTR                   0xC0001002
105
#define RTCRB                   0xD860000B
106
 
107
#------------------------------------------------------------------------------
108
# AM33 specific CPU initialization:
109
 
110
        # Initialize CPU
111
        .macro  hal_cpu_init
112
        # Set up the PSW
113
#if CYGHWR_HAL_MN10300_AM33_REVISION == 2
114
        mov     0x00100700,d0           # Enable the FPU
115
#else
116
        mov     0x00000700,d0
117
#endif
118
        mov     d0,epsw
119
#ifndef CYGSEM_HAL_USE_ROM_MONITOR
120
// Don't change TBR for RAM startup if RAM base is not aligned for TBR.
121
// In that case, the only option is to rely on ROM startup TBR and patch
122
// into vectors through the hal_vsr_table.
123
//
124
#if !(defined(CYG_HAL_STARTUP_RAM) && (CYGMEM_REGION_ram & 0xffffff))
125
        mov     reset_vector,a0         # set TBR to vector table
126
        mov     a0,(TBR)
127
#endif
128
#endif
129
 
130
        # stop as many internal interrupt sources as possible
131
        mov     0,d0
132
        movhu   d0,(SC0ICR)
133
        movhu   d0,(SC1ICR)
134
        movhu   d0,(SC2ICR)
135
        movbu   d0,(TM0MD)
136
        movbu   d0,(TM1MD)
137
        movbu   d0,(TM2MD)
138
        movbu   d0,(TM3MD)
139
        movbu   d0,(TM4MD)
140
        movbu   d0,(TM5MD)
141
        movhu   d0,(TM6MD)
142
        movbu   d0,(TM7MD)
143
        movbu   d0,(TM8MD)
144
        movbu   d0,(TM9MD)
145
        movbu   d0,(TM10MD)
146
        movbu   d0,(TM11MD)
147
        movhu   d0,(WDCTR)
148
 
149
        movbu   (RTCRB),d0
150
        and     0x8F,d0
151
        movbu   d0,(RTCRB)
152
 
153
        mov     0x80000000,d0
154
        mov     d0,(DM0CTR)
155
        mov     d0,(DM1CTR)
156
        mov     d0,(DM2CTR)
157
        mov     d0,(DM3CTR)
158
 
159
        # disable all interrupts
160
        mov     _mn10300_interrupt_control,a0
161
        mov     _mn10300_interrupt_control+(41*4),a1
162
        mov     0x0010,d0
163
1:      movhu   d0,(a0)
164
        add     4,a0
165
        cmp     a0,a1
166
        bcc     1b
167
        .endm
168
 
169
#define CYGPKG_HAL_MN10300_CPU_INIT_DEFINED
170
 
171
#------------------------------------------------------------------------------
172
# CPU state save and restore macros
173
 
174
        .macro  hal_cpu_save_all
175
        movm    [all],(sp)                              # push all registers
176
        .endm
177
 
178
        .macro  hal_cpu_load_all
179
        movm    (sp),[all]                              # pop regs
180
        .endm
181
 
182
        .macro  hal_cpu_get_psw reg
183
        mov     epsw,\reg
184
        .endm
185
 
186
        .macro  hal_cpu_set_psw reg
187
        mov     \reg,epsw
188
        .endm
189
 
190
# Location of PC in saved context (HAL_SavedRegisters)
191
#define SAVED_CONTEXT_PC_OFFSET          104
192
 
193
#-----------------------------------------------------------------------------
194
# Clear the NMID bit in the epsw to allow NMIs to be delivered again.
195
 
196
        .macro  hal_cpu_clear_nmid
197
        and     0xFFFDFFFF,epsw                 # clear NMID bit
198
        .endm
199
 
200
 
201
#------------------------------------------------------------------------------
202
# MEMC macros.
203
 
204
#ifndef CYGPKG_HAL_MN10300_MEMC_DEFINED
205
 
206
        .macro  hal_memc_init
207
        mov     INIT_SDRAMCONFIG,d0
208
        mov     d0,(SDRAMCONFIG)
209
        .endm
210
 
211
#define CYGPKG_HAL_MN10300_MEMC_DEFINED
212
 
213
#endif
214
 
215
#------------------------------------------------------------------------------
216
# Cache macros.
217
 
218
#ifndef CYGPKG_HAL_MN10300_CACHE_DEFINED
219
 
220
        .macro  hal_cache_init
221
 
222
#if defined(CYG_HAL_STARTUP_ROM)
223
    # Note that the hardware seems to come up with the
224
    # caches containing random data. Hence they must be
225
    # invalidated before being enabled.
226
    # However, we only do this if we are in ROM. If we are
227
    # in RAM, then we leave the caches in the state chosen
228
    # by the ROM monitor. If we enable them when the monitor
229
    # is not expecting it, we can end up breaking things if the
230
    # monitor is not doing cache flushes.
231
        mov     CHCTR,a0
232
        mov     0x0030,d0
233
        mov     d0,(a0)                         # Invalidate the ICACHE and DCACHE
234
        mov     0x0003,d0
235
        mov     d0,(a0)                         # Enable both caches
236
#else
237
        nop
238
#endif
239
        .endm
240
 
241
#define CYGPKG_HAL_MN10300_CACHE_DEFINED
242
 
243
#endif
244
 
245
##-----------------------------------------------------------------------------
246
# Default interrupt decoding macros.
247
 
248
#ifndef CYGPKG_HAL_MN10300_INTC_DEFINED
249
 
250
 
251
 
252
        # initialize all interrupts to disabled
253
        .macro  hal_intc_init
254
        .endm
255
 
256
#define CYGPKG_HAL_MN10300_INTC_DEFINED
257
 
258
#endif
259
 
260
#ifndef CYGPKG_HAL_MN10300_INTC_DECODE_DEFINED
261
 
262
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
263
 
264
#define CYG_ISR_TABLE_SIZE      10
265
 
266
        .macro  hal_intc_decode dreg,areg,dreg1
267
        mov     _mn10300_interrupt_control,\areg
268
        movhu   (0x100,\areg),\dreg1            # dreg1 = IAGR
269
        mov     (0,a2),\dreg                    # dreg = vector priority
270
        mov     \dreg1,(0,a2)                   # store real vector in saved state
271
        asl     2,\dreg                         # dreg = byte index of isr
272
        add     12,\dreg                        # skip NMI vectors
273
        .endm
274
 
275
#else
276
 
277
#define CYG_ISR_TABLE_SIZE       57
278
 
279
        # decode the interrupt
280
        .macro  hal_intc_decode dreg,areg,dreg1
281
        mov     _mn10300_interrupt_control,\areg
282
        movhu   (0x100,\areg),\dreg             # dreg = IAGR
283
        mov     \dreg,(0,a2)                    # store real vector in saved state
284
        add     12,\dreg                        # skip NMI vectors
285
        .endm
286
 
287
#endif
288
 
289
#define CYGPKG_HAL_MN10300_INTC_DECODE_DEFINED
290
 
291
#endif
292
 
293
 
294
#------------------------------------------------------------------------------
295
# Diagnostics macros.
296
 
297
#ifndef CYGPKG_HAL_MN10300_DIAG_DEFINED
298
 
299
        .macro  hal_diag_init
300
        .endm
301
 
302
        .macro  hal_diag_excpt_start
303
        .endm
304
 
305
        .macro  hal_diag_intr_start
306
        .endm
307
 
308
        .macro  hal_diag_restore
309
        .endm
310
 
311
        .macro  hal_diag_led val
312
        movm    [d2,a2],(sp)
313
        mov     \val,d2
314
        movm    (sp),[d2,a2]
315
        .endm
316
 
317
 
318
#define CYGPKG_HAL_MN10300_DIAG_DEFINED
319
 
320
#endif
321
 
322
#------------------------------------------------------------------------------
323
# Monitor initialization.
324
 
325
#ifndef CYGPKG_HAL_MN10300_MON_DEFINED
326
 
327
        .macro  hal_mon_init
328
        hal_mon_init_vectors
329
        hal_mon_init_vsr
330
        .endm
331
 
332
#if defined(CYG_HAL_STARTUP_ROM) || !defined(CYGSEM_HAL_USE_ROM_MONITOR)
333
        .macro  hal_mon_init_vectors
334
        # direct external interrupts
335
        mov     _mn10300_interrupt_vectors,a0
336
        mov     __hardware_vector_0,d0
337
        movhu   d0,(0,a0)
338
        mov     __hardware_vector_1,d0
339
        movhu   d0,(4,a0)
340
        mov     __hardware_vector_2,d0
341
        movhu   d0,(8,a0)
342
        mov     __hardware_vector_3,d0
343
        movhu   d0,(12,a0)
344
        mov     __hardware_vector_4,d0
345
        movhu   d0,(16,a0)
346
        mov     __hardware_vector_5,d0
347
        movhu   d0,(20,a0)
348
        mov     __hardware_vector_6,d0
349
        movhu   d0,(24,a0)
350
        .endm
351
#else
352
        .macro  hal_mon_init_vectors
353
        .endm
354
#endif
355
 
356
        .extern nmi_vsr_trampoline
357
        .extern nmi_sysef_trampoline
358
 
359
        # init vsr table in SRAM where the ROM
360
        # vectors the interrupts.
361
 
362
#if defined(CYG_HAL_STARTUP_ROM)
363
        .macro  hal_mon_init_vsr
364
        mov     _hal_vsr_table,a0
365
        mov     __default_interrupt_vsr,d0
366
        mov     d0,(0,a0)
367
        mov     d0,(4,a0)
368
        mov     d0,(8,a0)
369
        mov     d0,(12,a0)
370
        mov     d0,(16,a0)
371
        mov     d0,(20,a0)
372
        mov     d0,(24,a0)
373
        mov     nmi_vsr_trampoline,d0
374
        mov     d0,(28,a0)
375
        mov     __default_trap_vsr,d0
376
        mov     d0,(32,a0)
377
        mov     nmi_sysef_trampoline,d0
378
        mov     d0,(44,a0)
379
        mov     __default_nmi_vsr,d0
380
        mov     d0,(36,a0)
381
        mov     d0,(40,a0)
382
        mov     d0,(48,a0)
383
        mov     d0,(52,a0)
384
        mov     d0,(56,a0)
385
        mov     d0,(60,a0)
386
        mov     d0,(64,a0)
387
        mov     d0,(68,a0)
388
        mov     d0,(72,a0)
389
        mov     d0,(76,a0)
390
        mov     d0,(80,a0)
391
        mov     d0,(84,a0)
392
        mov     d0,(88,a0)
393
        mov     d0,(92,a0)
394
        mov     d0,(96,a0)
395
        mov     d0,(100,a0)
396
        mov     d0,(104,a0)
397
        mov     d0,(108,a0)
398
        .endm
399
#elif defined(CYG_HAL_STARTUP_RAM)
400
        .macro  hal_mon_init_vsr
401
        mov     _hal_vsr_table,a0
402
        mov     __default_interrupt_vsr,d0
403
        mov     d0,(0,a0)
404
        mov     d0,(4,a0)
405
        mov     d0,(8,a0)
406
        mov     d0,(12,a0)
407
        mov     d0,(16,a0)
408
        mov     d0,(20,a0)
409
        mov     d0,(24,a0)
410
#if !(defined(CYGSEM_HAL_USE_ROM_MONITOR_GDB_stubs))
411
        mov     nmi_vsr_trampoline,d0
412
        mov     d0,(28,a0)
413
        mov     nmi_sysef_trampoline,d0
414
        mov     d0,(44,a0)
415
#endif
416
        mov     __default_trap_vsr,d0
417
        mov     d0,(32,a0)
418
        mov     __default_nmi_vsr,d0
419
        mov     d0,(36,a0)
420
        mov     d0,(40,a0)
421
        mov     d0,(48,a0)
422
        mov     d0,(52,a0)
423
        mov     d0,(56,a0)
424
        mov     d0,(60,a0)
425
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
426
        mov     d0,(64,a0)      # breakpoint VSR only if stubs included
427
#endif
428
        mov     d0,(68,a0)
429
        mov     d0,(72,a0)
430
        mov     d0,(76,a0)
431
        mov     d0,(80,a0)
432
        mov     d0,(84,a0)
433
        mov     d0,(88,a0)
434
        mov     d0,(92,a0)
435
        mov     d0,(96,a0)
436
        mov     d0,(100,a0)
437
        mov     d0,(104,a0)
438
        mov     d0,(108,a0)
439
        .endm
440
#else
441
        .macro  hal_mon_init_vsr
442
        .endif
443
#endif
444
 
445
#define CYGPKG_HAL_MN10300_MON_DEFINED
446
 
447
#define CYG_HAL_MN10300_VSR_TABLE_DEFINED
448
 
449
#endif
450
 
451
 
452
 
453
#------------------------------------------------------------------------------
454
#endif // ifndef CYGONCE_HAL_VARIANT_INC
455
# end of variant.inc

powered by: WebSVN 2.1.0

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