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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [m68k/] [mcf52xx/] [mcf5272/] [proc/] [current/] [include/] [proc.inc] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
##=============================================================================
2
##
3
##      proc.inc
4
##
5
##      mcf5272 processor
6
##
7
##=============================================================================
8
## ####ECOSGPLCOPYRIGHTBEGIN####
9
## -------------------------------------------
10
## This file is part of eCos, the Embedded Configurable Operating System.
11
## Copyright (C) 2003, 2004, 2006, 2008 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):   bartv
43
## Date:        2003-06-04
44
######DESCRIPTIONEND####
45
##=============================================================================
46
 
47
#include 
48
 
49
// Vectors support.
50
// The 5272's interrupt vectors go up to slot 96: the standard 64 plus another
51
// 32 for the on-chip peripherals.
52
#define HAL_M68K_VSR_COUNT              96
53
 
54
// The chip has 4K on-chip RAM so enable the relevant init code in vectors.S
55
#define _HAL_M68K_INITIALIZE_IRAM_      1
56
 
57
// Fixed vectors data. The cacr cache control register is write-only so
58
// a shadow copy is needed. This has to be shared between RedBoot and the
59
// application, otherwise confusing things can happen when both manipulate
60
// the cache e.g. during debugging. Shadow copies are also needed to
61
// implement interrupt priorities. Some space is allocated for future
62
// expansion.
63
        .macro  _hal_mcf5272_ram_vectors_
64
        .global hal_mcf5272_cacr
65
hal_mcf5272_cacr:
66
        .long   0
67
        .global hal_mcf5272_icr_pri_mirror
68
hal_mcf5272_icr_pri_mirror:
69
        .long   0, 0, 0, 0
70
        .rept 11
71
        .long 0
72
        .endr
73
        .endm
74
 
75
#define _HAL_M68K_PROCESSOR_RAM_VECTORS_        _hal_mcf5272_ram_vectors_
76
 
77
// ----------------------------------------------------------------------------
78
// Utility macros for initialization. It is assumed that the platform HAL
79
// has provided the magic numbers.
80
 
81
// Remap. Typically on an MCF5272 board flash memory starts of at location
82
// 0, everything else is still disabled. The flash needs to be moved to
83
// its final location, usually in high memory, while we are still running
84
// out of flash. The way to do this is to set the mask in the cs option
85
// register to 0, causing the flash to be mirrored throughout the address
86
// space, then branch to the actual flash location, and then the rest of
87
// the memory map can be sorted out. To access CSOR0, first we need to map
88
// the MBAR into memory. MBAR has priority over chip selects so it will
89
// remain visible even if the flash is mirrored.
90
 
91
        .macro  _hal_mcf5272_remap_flash_
92
        move.l  # _HAL_MCF5272_MBAR_VALUE_, %d0
93
        movec.l %d0, %mbar
94
        move.l  # HAL_MCFxxxx_MBAR, %a5
95
        move.l  # (_HAL_MCF5272_CSOR0_VALUE_ & ~HAL_MCF5272_CSOR_BA_MASK), %d0
96
        move.l  %d0, HAL_MCF5272_CSOR0 (%a5)
97
 
98
        // dBUG inserts a nop here and another in the branch location.
99
        // Presumably this avoids pipeline problems if the memory map
100
        // changes under the pipeline's feet.
101
        nop
102
 
103
        // Now we can branch to the real location in the flash. The linker
104
        // script is set up so that this code is mapped to the right place.
105
        jmp     _hal_mcf5272_flash_
106
 
107
        // Put the next code in a separate section to stop the assembler turning
108
        // the above jump into a PC-relative one
109
        .section ".m68k_start.0", "ax"
110
 
111
_hal_mcf5272_flash_:
112
        // Another nop as per dBUG
113
        nop
114
        // We are now running out of flash. CSOR0 and MBAR have been changed,
115
        // everything else is still at reset values.
116
        .endm
117
 
118
// Initialize all the system registers. Typically this is done unconditionally
119
// on the off-chance that RedBoot and the application need different values.
120
        .macro  _hal_mcf5272_init_sysregs_
121
        move.l  # (HAL_MCFxxxx_CACR_CINV), %d0
122
        movec.l %d0, %cacr
123
        move.l  # (CYGNUM_HAL_M68K_MCF5272_ACR0), %d0
124
        movec.l %d0, %acr0
125
        move.l  # (CYGNUM_HAL_M68K_MCF5272_ACR1), %d0
126
        movec.l %d0, %acr1
127
        move.l  # (CYGNUM_HAL_M68K_MCF5272_ROMBAR), %d0
128
        movec.l %d0, %rombar
129
        move.l  # (CYGNUM_HAL_M68K_MCF5272_RAMBAR), %d0
130
        movec.l %d0, %rambar0
131
        move.l  # (CYGNUM_HAL_M68K_MCF5272_CACR), %d0
132
        movec.l %d0, %cacr
133
        .endm
134
 
135
// Initialize memory, including starting the SDRAM controller
136
        .macro  _hal_mcf5272_init_memory_
137
        move.w  # CYGNUM_HAL_M68K_MCF5272_SCR, %d0
138
        move.w  %d0,                            HAL_MCF5272_SCR (%a5)
139
        move.w  # 0xFFFF,                       %d0
140
        move.w  %d0,                            HAL_MCF5272_SPR (%a5)
141
 
142
        // chip selects and SDRAM. CS0 should always be connected to
143
        // a boot flash. The BW bits are set from external pins
144
        // QSPI_CS0/CSPI_CLK and are preserved here. Arguably that
145
        // should not be necessary but it allows for platforms where
146
        // the hardware has gone through several revisions and it
147
        // is undesirable to build different images for different
148
        // revisions. The overhead is small, just two instructions.
149
        move.l  HAL_MCF5272_CSBR0 (%a5),        %d0
150
        andi.l  # HAL_MCF5272_CSBR_BW_MASK,     %d0
151
        ori.l   # (_HAL_MCF5272_CSBR0_VALUE_),  %d0
152
        move.l  %d0,                            HAL_MCF5272_CSBR0 (%a5)
153
        move.l  # (_HAL_MCF5272_CSOR0_VALUE_),  %d0
154
        move.l  %d0,                            HAL_MCF5272_CSOR0 (%a5)
155
 
156
        // Chip selects 1-6 may or may not be connected. If not just leave
157
        // them to their default disabled state.
158
        .ifdef _HAL_MCF5272_CSBR1_VALUE_
159
        move.l  # (_HAL_MCF5272_CSBR1_VALUE_),  %d0
160
        move.l  %d0,                            HAL_MCF5272_CSBR1 (%a5)
161
        move.l  # (_HAL_MCF5272_CSOR1_VALUE_),  %d0
162
        move.l  %d0,                            HAL_MCF5272_CSOR1 (%a5)
163
        .endif
164
        .ifdef _HAL_MCF5272_CSBR2_VALUE_
165
        move.l  # (_HAL_MCF5272_CSBR2_VALUE_),  %d0
166
        move.l  %d0,                            HAL_MCF5272_CSBR2 (%a5)
167
        move.l  # (_HAL_MCF5272_CSOR2_VALUE_),  %d0
168
        move.l  %d0,                            HAL_MCF5272_CSOR2 (%a5)
169
        .endif
170
        .ifdef _HAL_MCF5272_CSBR3_VALUE_
171
        move.l  # (_HAL_MCF5272_CSBR3_VALUE_),  %d0
172
        move.l  %d0,                            HAL_MCF5272_CSBR3 (%a5)
173
        move.l  # (_HAL_MCF5272_CSOR3_VALUE_),  %d0
174
        move.l  %d0,                            HAL_MCF5272_CSOR3 (%a5)
175
        .endif
176
        .ifdef _HAL_MCF5272_CSBR4_VALUE_
177
        move.l  # (_HAL_MCF5272_CSBR4_VALUE_),  %d0
178
        move.l  %d0,                            HAL_MCF5272_CSBR4 (%a5)
179
        move.l  # (_HAL_MCF5272_CSOR4_VALUE_),  %d0
180
        move.l  %d0,                            HAL_MCF5272_CSOR4 (%a5)
181
        .endif
182
        .ifdef _HAL_MCF5272_CSBR5_VALUE_
183
        move.l  # (_HAL_MCF5272_CSBR5_VALUE_),  %d0
184
        move.l  %d0,                            HAL_MCF5272_CSBR5 (%a5)
185
        move.l  # (_HAL_MCF5272_CSOR5_VALUE_),  %d0
186
        move.l  %d0,                            HAL_MCF5272_CSOR5 (%a5)
187
        .endif
188
        .ifdef _HAL_MCF5272_CSBR6_VALUE_
189
        move.l  # (_HAL_MCF5272_CSBR6_VALUE_),  %d0
190
        move.l  %d0,                            HAL_MCF5272_CSBR6 (%a5)
191
        move.l  # (_HAL_MCF5272_CSOR6_VALUE_),  %d0
192
        move.l  %d0,                            HAL_MCF5272_CSOR6 (%a5)
193
        .endif
194
 
195
        // CS7 will go the SDRAM.
196
        move.l  # (_HAL_MCF5272_CSBR7_VALUE_),  %d0
197
        move.l  %d0,                            HAL_MCF5272_CSBR7 (%a5)
198
        move.l  # (_HAL_MCF5272_CSOR7_VALUE_),  %d0
199
        move.l  %d0,                            HAL_MCF5272_CSOR7 (%a5)
200
 
201
        // The SDRAM should now be ready for its first commands.
202
        // The timer register needs to be done first, then the
203
        // control register, and finally a dummy write to memory.
204
        // That dummy write causes the SDRAM controller to take
205
        // the necessary actions, and the memory should be usable
206
        // a few cycles later.
207
        move.l  # (_HAL_MCF5272_SDTR_VALUE_),   %d0
208
        move.l  %d0,                            HAL_MCF5272_SDTR (%a5)
209
        move.l  # (_HAL_MCF5272_SDCR_VALUE_),   %d0
210
        move.l  %d0,                            HAL_MCF5272_SDCR (%a5)
211
        clr.l   0
212
        .endm
213
 
214
// ----------------------------------------------------------------------------
215
// Now that the utility macros are defined include the platform HAL.
216
#include 
217
 
218
// And if the platform HAL requests it, provide the standard initialization
219
// code.
220
#if defined(_HAL_MCF5272_STANDARD_INIT_ROM_)
221
        .macro  _hal_m68k_mcf5272_start_
222
        // Initial stack and program counter
223
        .long   0
224
        .long   8
225
        _hal_mcf5272_remap_flash_
226
        .endm
227
 
228
        .macro  _hal_m68k_mcf5272_setup1_
229
        _hal_mcf5272_init_sysregs_
230
        _hal_mcf5272_init_memory_
231
        .endm
232
 
233
# define _HAL_M68K_START_               _hal_m68k_mcf5272_start_
234
# define _HAL_M68K_PLATFORM_SETUP1_     _hal_m68k_mcf5272_setup1_
235
# define _HAL_M68K_COPY_ROM_DATA_TO_RAM_ 1
236
 
237
#elif defined(_HAL_MCF5272_STANDARD_INIT_RAM_)
238
        .macro  _hal_m68k_mcf5272_start_
239
        .endm
240
 
241
        .macro  _hal_m68k_mcf5272_setup1_
242
        // Always initialize the remaining system registers, in case the
243
        // application needs different values from RedBoot for some reason.
244
        _hal_mcf5272_init_sysregs_
245
        .endm
246
 
247
# define _HAL_M68K_START_               _hal_m68k_mcf5272_start_
248
# define _HAL_M68K_PLATFORM_SETUP1_     _hal_m68k_mcf5272_setup1_
249
#endif
250
 
251
// ----------------------------------------------------------------------------
252
// end of proc.inc

powered by: WebSVN 2.1.0

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