1 |
27 |
unneback |
#ifndef CYGONCE_HAL_PLATFORM_SETUP_H
|
2 |
|
|
#define CYGONCE_HAL_PLATFORM_SETUP_H
|
3 |
|
|
|
4 |
|
|
/*=============================================================================
|
5 |
|
|
//
|
6 |
|
|
// hal_platform_setup.h
|
7 |
|
|
//
|
8 |
|
|
// Platform specific support for HAL (assembly code)
|
9 |
|
|
//
|
10 |
|
|
//=============================================================================
|
11 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
12 |
|
|
// -------------------------------------------
|
13 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
14 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
15 |
|
|
// Copyright (C) 2003 Gary Thomas <gary@mind.be>
|
16 |
|
|
//
|
17 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
18 |
|
|
// the terms of the GNU General Public License as published by the Free
|
19 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
20 |
|
|
//
|
21 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
22 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
23 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
24 |
|
|
// for more details.
|
25 |
|
|
//
|
26 |
|
|
// You should have received a copy of the GNU General Public License along
|
27 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
28 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
29 |
|
|
//
|
30 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
31 |
|
|
// or inline functions from this file, or you compile this file and link it
|
32 |
|
|
// with other works to produce a work based on this file, this file does not
|
33 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
34 |
|
|
// License. However the source code for this file must still be made available
|
35 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
36 |
|
|
//
|
37 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
38 |
|
|
// this file might be covered by the GNU General Public License.
|
39 |
|
|
//
|
40 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
41 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
42 |
|
|
// -------------------------------------------
|
43 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
44 |
|
|
//=============================================================================
|
45 |
|
|
//#####DESCRIPTIONBEGIN####
|
46 |
|
|
//
|
47 |
|
|
// Author(s): gthomas
|
48 |
|
|
// Contributors: gthomas
|
49 |
|
|
// Date: 1999-04-21
|
50 |
|
|
// Purpose: Cirrus EDB7XXX platform specific support routines
|
51 |
|
|
// Description:
|
52 |
|
|
// Usage: #include <cyg/hal/hal_platform_setup.h>
|
53 |
|
|
//
|
54 |
|
|
//####DESCRIPTIONEND####
|
55 |
|
|
//
|
56 |
|
|
//===========================================================================*/
|
57 |
|
|
|
58 |
|
|
#include <pkgconf/system.h> // System-wide configuration info
|
59 |
|
|
#include <pkgconf/hal.h> // Architecture independent configuration
|
60 |
|
|
#include CYGBLD_HAL_PLATFORM_H // Platform specific configuration
|
61 |
|
|
#include <cyg/hal/hal_edb7xxx.h> // Platform specific hardware definitions
|
62 |
|
|
#include <cyg/hal/hal_mmu.h> // MMU definitions
|
63 |
|
|
|
64 |
|
|
#define CYGHWR_HAL_ARM_HAS_MMU // This processor has an MMU
|
65 |
|
|
#define CYGSEM_HAL_ROM_RESET_USES_JUMP
|
66 |
|
|
//
|
67 |
|
|
// Memory map - set up by ROM (GDB stubs)
|
68 |
|
|
//
|
69 |
|
|
// Region Logical Address Physical Address
|
70 |
|
|
// DRAM 0x00000000..0x00xFFFFF 0xC00x0000 (see below)
|
71 |
|
|
// Expansion 2 0x20000000 0x20000000
|
72 |
|
|
// Expansion 3 0x30000000 0x30000000
|
73 |
|
|
// PCMCIA 0 0x40000000 0x40000000
|
74 |
|
|
// PCMCIA 1 0x50000000 0x50000000
|
75 |
|
|
// SRAM 0x60000000..0x600007FF 0x60000000
|
76 |
|
|
// I/O 0x80000000 0x80000000
|
77 |
|
|
// MMU Tables 0xC00y0000
|
78 |
|
|
// LCD buffer 0xC0000000..0xC001FFFF 0xC0000000
|
79 |
|
|
// ROM 0xE0000000..0xEFFFFFFF 0x00000000
|
80 |
|
|
// ROM 0xF0000000..0xFFFFFFFF 0x10000000
|
81 |
|
|
|
82 |
|
|
#ifdef CYGHWR_HAL_ARM_EDB7XXX_LCD_INSTALLED
|
83 |
|
|
#define LCD_BUFFER_SIZE 0x00020000
|
84 |
|
|
#else
|
85 |
|
|
#define LCD_BUFFER_SIZE 0x00000000
|
86 |
|
|
#endif
|
87 |
|
|
#define DRAM_PA_START 0xC0000000
|
88 |
|
|
#define MMU_BASE DRAM_PA_START+LCD_BUFFER_SIZE
|
89 |
|
|
#define PTE_BASE MMU_BASE+0x4000
|
90 |
|
|
#if (CYGHWR_HAL_ARM_EDB7XXX_DRAM_SIZE == 2)
|
91 |
|
|
#define MMU_TABLES_SIZE (0x4000+0x1000+0x1000) // RAM used for PTE entries
|
92 |
|
|
#define DRAM_LA_END (0x00200000-MMU_TABLES_SIZE-LCD_BUFFER_SIZE)
|
93 |
|
|
#elif (CYGHWR_HAL_ARM_EDB7XXX_DRAM_SIZE == 16)
|
94 |
|
|
#define MMU_TABLES_SIZE (0x4000+0x4000+0x1000) // RAM used for PTE entries
|
95 |
|
|
#define DRAM_LA_END (0x01000000-MMU_TABLES_SIZE-LCD_BUFFER_SIZE)
|
96 |
|
|
#endif
|
97 |
|
|
#define DRAM_LA_START 0x00000000
|
98 |
|
|
#define DRAM_PA MMU_BASE+MMU_TABLES_SIZE
|
99 |
|
|
#define LCD_LA_START 0xC0000000
|
100 |
|
|
#define LCD_LA_END 0xC0020000
|
101 |
|
|
#define LCD_PA 0xC0000000
|
102 |
|
|
#define ROM0_LA_START 0xE0000000
|
103 |
|
|
#define ROM0_PA 0x00000000
|
104 |
|
|
#define ROM0_LA_END 0xF0000000
|
105 |
|
|
#define ROM1_LA_START 0xF0000000
|
106 |
|
|
#define ROM1_LA_END 0x00000000
|
107 |
|
|
#define ROM1_PA 0x10000000
|
108 |
|
|
#define EXPANSION2_LA_START 0x20000000
|
109 |
|
|
#define EXPANSION2_PA 0x20000000
|
110 |
|
|
#define EXPANSION3_LA_START 0x30000000
|
111 |
|
|
#define EXPANSION3_PA 0x30000000
|
112 |
|
|
#define PCMCIA0_LA_START 0x40000000
|
113 |
|
|
#define PCMCIA0_PA 0x40000000
|
114 |
|
|
#define PCMCIA1_LA_START 0x50000000
|
115 |
|
|
#define PCMCIA1_PA 0x50000000
|
116 |
|
|
#define SRAM_LA_START 0x60000000
|
117 |
|
|
#ifdef CYGHWR_HAL_ARM_EDB7XXX_VARIANT_CL_PS7111 // 4K SRAM
|
118 |
|
|
#define SRAM_LA_END 0x60001000
|
119 |
|
|
#else // 72xx - 37.5K SRAM
|
120 |
|
|
#define SRAM_LA_END 0x6000A000
|
121 |
|
|
#endif
|
122 |
|
|
#define SRAM_PA 0x60000000
|
123 |
|
|
#define IO_LA_START 0x80000000
|
124 |
|
|
#define IO_LA_END 0x8000f000
|
125 |
|
|
#define IO_PA 0x80000000
|
126 |
|
|
|
127 |
|
|
#ifndef _CYGHWR_LAYOUT_ONLY
|
128 |
|
|
// Define startup code [macros]
|
129 |
|
|
#if defined(CYGSEM_HAL_INSTALL_MMU_TABLES)
|
130 |
|
|
|
131 |
|
|
#ifdef CYGHWR_HAL_ARM_EDB7XXX_VARIANT_CL_PS7111 // CL7111, 710 processor
|
132 |
|
|
.macro MMU_INITIALIZE
|
133 |
|
|
ldr r2,=MMU_Control_Init
|
134 |
|
|
mcr MMU_CP,0,r2,MMU_Control,c0 /* MMU off */
|
135 |
|
|
mcr MMU_CP,0,r1,MMU_Base,c0
|
136 |
|
|
mcr MMU_CP,0,r1,MMU_FlushTLB,c0,0 /* Invalidate TLB */
|
137 |
|
|
mcr MMU_CP,0,r1,MMU_FlushIDC,c0,0 /* Invalidate Caches */
|
138 |
|
|
ldr r1,=0xFFFFFFFF
|
139 |
|
|
mcr MMU_CP,0,r1,MMU_DomainAccess,c0
|
140 |
|
|
ldr r2,=10f
|
141 |
|
|
ldr r1,=MMU_Control_Init|MMU_Control_M
|
142 |
|
|
mcr MMU_CP,0,r1,MMU_Control,c0
|
143 |
|
|
mov pc,r2 /* Change address spaces */
|
144 |
|
|
nop
|
145 |
|
|
nop
|
146 |
|
|
nop
|
147 |
|
|
10:
|
148 |
|
|
.endm
|
149 |
|
|
#else // EP7xxx, 720T processor
|
150 |
|
|
.macro MMU_INITIALIZE
|
151 |
|
|
ldr r2,=MMU_Control_Init
|
152 |
|
|
mcr MMU_CP,0,r2,MMU_Control,c0 /* MMU off */
|
153 |
|
|
mcr MMU_CP,0,r1,MMU_Base,c0
|
154 |
|
|
mcr MMU_CP,0,r1,MMU_TLB,c7,0 /* Invalidate TLB */
|
155 |
|
|
mcr MMU_CP,0,r1,MMU_FlushIDC,c0,0 /* Invalidate Caches */
|
156 |
|
|
ldr r1,=0xFFFFFFFF
|
157 |
|
|
mcr MMU_CP,0,r1,MMU_DomainAccess,c0
|
158 |
|
|
ldr r2,=10f
|
159 |
|
|
#ifdef CYG_HAL_STARTUP_ROMRAM
|
160 |
|
|
ldr r3,=__exception_handlers
|
161 |
|
|
sub r2,r2,r3
|
162 |
|
|
ldr r3,=ROM0_LA_START
|
163 |
|
|
add r2,r2,r3
|
164 |
|
|
#endif
|
165 |
|
|
ldr r1,=MMU_Control_Init|MMU_Control_M
|
166 |
|
|
mcr MMU_CP,0,r1,MMU_Control,c0
|
167 |
|
|
mov pc,r2 /* Change address spaces */
|
168 |
|
|
nop
|
169 |
|
|
nop
|
170 |
|
|
nop
|
171 |
|
|
10:
|
172 |
|
|
.endm
|
173 |
|
|
#endif // EP7xxx,720T processor
|
174 |
|
|
|
175 |
|
|
#ifdef CYG_HAL_STARTUP_ROMRAM
|
176 |
|
|
.macro RELOCATE_TEXT_SEGMENT
|
177 |
|
|
ldr r2,=__exception_handlers
|
178 |
|
|
ldr r3,=ROM0_LA_START
|
179 |
|
|
cmp r2,r3
|
180 |
|
|
beq 20f
|
181 |
|
|
ldr r4,=__rom_data_end
|
182 |
|
|
15:
|
183 |
|
|
ldr r0,[r3],#4
|
184 |
|
|
str r0,[r2],#4
|
185 |
|
|
cmp r2,r4
|
186 |
|
|
bne 15b
|
187 |
|
|
ldr r2,=20f
|
188 |
|
|
mov pc,r2 /* Change address spaces */
|
189 |
|
|
nop
|
190 |
|
|
nop
|
191 |
|
|
nop
|
192 |
|
|
20:
|
193 |
|
|
.endm
|
194 |
|
|
#endif
|
195 |
|
|
|
196 |
|
|
#ifdef CYG_HAL_STARTUP_RAM
|
197 |
|
|
.macro RELOCATE_RAM_IMAGE
|
198 |
|
|
// Special code to handle case where program has been loaded into DRAM
|
199 |
|
|
// _somewhere_. This code first relocates itself into DRAM where eCos
|
200 |
|
|
// mapping will expect it to be. Note since we don't know the current
|
201 |
|
|
// MMU mapping, this is tricky. This is handled by putting a small
|
202 |
|
|
// routine into SRAM (which is always mapped 1-1) that turns off the
|
203 |
|
|
// MMU whilst it stores one word into physical memory. Once the whole
|
204 |
|
|
// program has been relocated thusly, the MMU is shut off again while
|
205 |
|
|
// the eCos memory mapping takes place
|
206 |
|
|
bl 5f
|
207 |
|
|
// Routine to store one item in physical memory, with the MMU off
|
208 |
|
|
_phys_store:
|
209 |
|
|
ldr r5,=MMU_Control_Init
|
210 |
|
|
mcr MMU_CP,0,r5,MMU_Control,c0 /* MMU off */
|
211 |
|
|
nop
|
212 |
|
|
nop
|
213 |
|
|
nop
|
214 |
|
|
mcr MMU_CP,0,r1,MMU_TLB,c7,0 /* Invalidate TLB */
|
215 |
|
|
mcr MMU_CP,0,r1,MMU_FlushIDC,c0,0 /* Invalidate Caches */
|
216 |
|
|
str r4,[r2],#4
|
217 |
|
|
ldr r5,=MMU_Control_Init|MMU_Control_M
|
218 |
|
|
mcr MMU_CP,0,r5,MMU_Control,c0
|
219 |
|
|
mov pc,lr
|
220 |
|
|
_phys_store_end:
|
221 |
|
|
// Copy above routine to SRAM, whose address does not change with MMU
|
222 |
|
|
5: mov r1,lr
|
223 |
|
|
add r2,r1,#_phys_store_end-_phys_store
|
224 |
|
|
ldr r3,=SRAM_LA_START
|
225 |
|
|
6: ldr r4,[r1],#4
|
226 |
|
|
str r4,[r3],#4
|
227 |
|
|
cmp r1,r2
|
228 |
|
|
bne 6b
|
229 |
|
|
ldr r6,=SRAM_LA_START
|
230 |
|
|
// Relocate code in DRAM to where eCos mapping wants it
|
231 |
|
|
bl 7f
|
232 |
|
|
7: mov r2,lr
|
233 |
|
|
ldr r1,=7b
|
234 |
|
|
sub r1,r2,r1
|
235 |
|
|
ldr r2,=__exception_handlers
|
236 |
|
|
add r1,r1,r2
|
237 |
|
|
// ldr r1,=0xF0020000
|
238 |
|
|
ldr r3,=DRAM_PA
|
239 |
|
|
add r2,r2,r3
|
240 |
|
|
// ldr r2,=DRAM_PA+0x20000
|
241 |
|
|
ldr r3,=_edata
|
242 |
|
|
ldr r4,=__exception_handlers
|
243 |
|
|
sub r3,r3,r4
|
244 |
|
|
add r3,r1,r3
|
245 |
|
|
// ldr r3,=0xF0040000
|
246 |
|
|
10: ldr r4,[r1],#4
|
247 |
|
|
mov lr,pc // Call phys_store() function above
|
248 |
|
|
mov pc,r6
|
249 |
|
|
cmp r1,r3
|
250 |
|
|
bne 10b
|
251 |
|
|
// Now, turn off the MMU an execute the rest of this code in PHYSICAL memory
|
252 |
|
|
ldr r1,=15f
|
253 |
|
|
ldr r2,=DRAM_PA
|
254 |
|
|
add r1,r1,r2
|
255 |
|
|
ldr r5,=MMU_Control_Init
|
256 |
|
|
mcr MMU_CP,0,r5,MMU_Control,c0 /* MMU off */
|
257 |
|
|
mov pc,r1
|
258 |
|
|
nop
|
259 |
|
|
nop
|
260 |
|
|
nop
|
261 |
|
|
15: mcr MMU_CP,0,r1,MMU_TLB,c7,0 /* Invalidate TLB */
|
262 |
|
|
mcr MMU_CP,0,r1,MMU_FlushIDC,c0,0 /* Invalidate Caches */
|
263 |
|
|
.endm
|
264 |
|
|
#endif // CYG_HAL_STARTUP_RAM
|
265 |
|
|
|
266 |
|
|
#ifdef CYGHWR_HAL_ARM_EDB7XXX_VARIANT_EP7312
|
267 |
|
|
.macro INIT_MEMORY_CONFIG
|
268 |
|
|
mov r0,#(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_SUPERVISOR_MODE)
|
269 |
|
|
msr cpsr,r0
|
270 |
|
|
ldr r10,=UARTDR1
|
271 |
|
|
ldr r11,=SYSFLG1
|
272 |
|
|
ldr r12,=SYSFLG1_UTXFF1
|
273 |
|
|
ldr r1,=SDCONF
|
274 |
|
|
ldr r2,=0x00000522
|
275 |
|
|
str r2,[r1]
|
276 |
|
|
ldr r1,=SDRFOR
|
277 |
|
|
ldr r2,=0x00000240
|
278 |
|
|
str r2,[r1]
|
279 |
|
|
ldr r1,=MEMCFG1
|
280 |
|
|
ldr r2,=0x1F101710
|
281 |
|
|
str r2,[r1]
|
282 |
|
|
ldr r1,=MEMCFG2
|
283 |
|
|
ldr r2,=0x00001F13
|
284 |
|
|
str r2,[r1]
|
285 |
|
|
.endm
|
286 |
|
|
#else
|
287 |
|
|
#if CYGHWR_HAL_ARM_EDB7XXX_VARIANT_EP7209
|
288 |
|
|
// No DRAM controller
|
289 |
|
|
.macro INIT_MEMORY_CONFIG
|
290 |
|
|
/* Initialize memory configuration */
|
291 |
|
|
ldr r1,=MEMCFG1
|
292 |
|
|
ldr r2,=0x8200A080
|
293 |
|
|
str r2,[r1]
|
294 |
|
|
ldr r1,=MEMCFG2
|
295 |
|
|
ldr r2,=0xFEFC0000
|
296 |
|
|
str r2,[r1]
|
297 |
|
|
.endm
|
298 |
|
|
#else // CYGHWR_HAL_ARM_EDB7XXX_VARIANT = EP7211, EP7212
|
299 |
|
|
.macro INIT_MEMORY_CONFIG
|
300 |
|
|
/* Initialize memory configuration */
|
301 |
|
|
ldr r1,=MEMCFG1
|
302 |
|
|
ldr r2,=0x8200A080
|
303 |
|
|
str r2,[r1]
|
304 |
|
|
ldr r1,=MEMCFG2
|
305 |
|
|
ldr r2,=0xFEFC0000
|
306 |
|
|
str r2,[r1]
|
307 |
|
|
ldr r1,=DRFPR
|
308 |
|
|
ldr r2,=0x81 /* DRAM refresh = 64KHz */
|
309 |
|
|
strb r2,[r1]
|
310 |
|
|
.endm
|
311 |
|
|
#endif
|
312 |
|
|
#endif
|
313 |
|
|
|
314 |
|
|
#if defined(CYGSEM_HAL_STATIC_MMU_TABLES)
|
315 |
|
|
#define PLATFORM_SETUP1 \
|
316 |
|
|
INIT_MEMORY_CONFIG ;\
|
317 |
|
|
ldr r1,=_MMU_table-0xE0000000 ;\
|
318 |
|
|
MMU_INITIALIZE ;\
|
319 |
|
|
RELOCATE_TEXT_SEGMENT
|
320 |
|
|
|
321 |
|
|
#define PLATFORM_EXTRAS <cyg/hal/hal_platform_extras.h>
|
322 |
|
|
|
323 |
|
|
#else
|
324 |
|
|
// MMU tables placed in DRAM
|
325 |
|
|
|
326 |
|
|
#if (CYGHWR_HAL_ARM_EDB7XXX_DRAM_SIZE == 2)
|
327 |
|
|
// Note: The DRAM on this board is very irregular in that every
|
328 |
|
|
// other 256K piece is missing. E.g. only these [physical]
|
329 |
|
|
// addresses are valid:
|
330 |
|
|
// 0xC0000000..0xC003FFFF
|
331 |
|
|
// 0xC0080000..0xC00BFFFF
|
332 |
|
|
// 0xC0200000..0xC023FFFF Note the additional GAP!
|
333 |
|
|
// etc.
|
334 |
|
|
// 0xC0800000..0xC083FFFF Note the additional GAP!
|
335 |
|
|
// 0xC0880000..0xC08CFFFF
|
336 |
|
|
// 0xC0A00000..0xC0A3FFFF
|
337 |
|
|
// etc.
|
338 |
|
|
// The MMU mapping code takes this into consideration and creates
|
339 |
|
|
// a continuous logical map for the DRAM.
|
340 |
|
|
.macro MAP_DRAM
|
341 |
|
|
/* Map DRAM */
|
342 |
|
|
ldr r3,=DRAM_LA_START
|
343 |
|
|
ldr r4,=DRAM_LA_END
|
344 |
|
|
ldr r5,=DRAM_PA
|
345 |
|
|
/* 0x00000000..0x000FFFFF */
|
346 |
|
|
mov r6,r2 /* Set up page table descriptor */
|
347 |
|
|
ldr r7,=MMU_L1_TYPE_Page
|
348 |
|
|
orr r6,r6,r7
|
349 |
|
|
str r6,[r1],#4 /* Store PTE, update pointer */
|
350 |
|
|
10: mov r6,r5 /* Build page table entry */
|
351 |
|
|
ldr r7,=MMU_L2_TYPE_Small|MMU_AP_Any|MMU_Bufferable|MMU_Cacheable
|
352 |
|
|
orr r6,r6,r7
|
353 |
|
|
ldr r7,=MMU_PAGE_SIZE
|
354 |
|
|
str r6,[r2],#4 /* Next page */
|
355 |
|
|
add r3,r3,r7
|
356 |
|
|
add r5,r5,r7
|
357 |
|
|
ldr r8,=DRAM_LA_START+MMU_SECTION_SIZE
|
358 |
|
|
cmp r3,r8 /* Done with first 1M? */
|
359 |
|
|
beq 20f
|
360 |
|
|
ldr r7,=0x40000 /* Special check for 256K boundary */
|
361 |
|
|
and r7,r7,r5
|
362 |
|
|
cmp r7,#0
|
363 |
|
|
beq 10b
|
364 |
|
|
add r5,r5,r7 /* Skip 256K hole */
|
365 |
|
|
ldr r7,=0x100000
|
366 |
|
|
and r7,r5,r7
|
367 |
|
|
beq 10b
|
368 |
|
|
add r5,r5,r7 /* Nothing at 0xC0100000 */
|
369 |
|
|
ldr r7,=0x400000 /* Also nothing at 0xC0400000 */
|
370 |
|
|
and r7,r5,r7
|
371 |
|
|
beq 10b
|
372 |
|
|
add r5,r5,r7
|
373 |
|
|
b 10b
|
374 |
|
|
20:
|
375 |
|
|
/* 0x00100000..0x001FFFFF */
|
376 |
|
|
mov r6,r2 /* Set up page table descriptor */
|
377 |
|
|
ldr r7,=MMU_L1_TYPE_Page
|
378 |
|
|
orr r6,r6,r7
|
379 |
|
|
str r6,[r1],#4 /* Store PTE, update pointer */
|
380 |
|
|
10: mov r6,r5 /* Build page table entry */
|
381 |
|
|
ldr r7,=MMU_L2_TYPE_Small|MMU_AP_Any|MMU_Bufferable|MMU_Cacheable
|
382 |
|
|
orr r6,r6,r7
|
383 |
|
|
ldr r7,=MMU_PAGE_SIZE
|
384 |
|
|
str r6,[r2],#4 /* Next page */
|
385 |
|
|
add r3,r3,r7
|
386 |
|
|
cmp r3,r4 /* Done with first DRAM? */
|
387 |
|
|
beq 20f
|
388 |
|
|
add r5,r5,r7
|
389 |
|
|
ldr r7,=0x40000 /* Special check for 256K boundary */
|
390 |
|
|
and r7,r7,r5
|
391 |
|
|
cmp r7,#0
|
392 |
|
|
beq 10b
|
393 |
|
|
add r5,r5,r7 /* Skip 256K hole */
|
394 |
|
|
ldr r7,=0x100000
|
395 |
|
|
and r7,r5,r7
|
396 |
|
|
beq 10b
|
397 |
|
|
add r5,r5,r7 /* Nothing at 0xC0300000 */
|
398 |
|
|
ldr r7,=0x400000 /* Also nothing at 0xC0400000 */
|
399 |
|
|
and r7,r5,r7
|
400 |
|
|
beq 10b
|
401 |
|
|
add r5,r5,r7
|
402 |
|
|
b 10b
|
403 |
|
|
20:
|
404 |
|
|
|
405 |
|
|
#elif (CYGHWR_HAL_ARM_EDB7XXX_DRAM_SIZE == 16)
|
406 |
|
|
// The 16M EDB72xx boards are arranged as:
|
407 |
|
|
// 0xC0000000..0xC07FFFFF
|
408 |
|
|
// 0xC1000000..0xC17FFFFF
|
409 |
|
|
// The 16M EDB7312 board is arranged as:
|
410 |
|
|
// 0xC0000000..0xC0FFFFFF
|
411 |
|
|
.macro MAP_DRAM
|
412 |
|
|
/* Map DRAM */
|
413 |
|
|
ldr r3,=DRAM_LA_START
|
414 |
|
|
ldr r4,=DRAM_LA_END
|
415 |
|
|
ldr r5,=DRAM_PA
|
416 |
|
|
/* 0xXXX00000..0xXXXFFFFF */
|
417 |
|
|
10: mov r6,r2 /* Set up page table descriptor */
|
418 |
|
|
ldr r7,=MMU_L1_TYPE_Page
|
419 |
|
|
orr r6,r6,r7
|
420 |
|
|
str r6,[r1],#4 /* Store PTE, update pointer */
|
421 |
|
|
ldr r8,=MMU_SECTION_SIZE/MMU_PAGE_SIZE
|
422 |
|
|
#if !defined(__EDB7312)
|
423 |
|
|
// EDB7312 has contiguous SDRAM
|
424 |
|
|
ldr r9,=DRAM_PA_START+0x00800000 /* Skip at 8M boundary */
|
425 |
|
|
12: cmp r5,r9
|
426 |
|
|
bne 15f
|
427 |
|
|
ldr r5,=DRAM_PA_START+0x01000000 /* Next chunk of DRAM */
|
428 |
|
|
#else
|
429 |
|
|
12:
|
430 |
|
|
#endif
|
431 |
|
|
15: mov r6,r5 /* Build page table entry */
|
432 |
|
|
ldr r7,=MMU_L2_TYPE_Small|MMU_AP_Any|MMU_Bufferable|MMU_Cacheable
|
433 |
|
|
orr r6,r6,r7
|
434 |
|
|
ldr r7,=MMU_PAGE_SIZE
|
435 |
|
|
str r6,[r2],#4 /* Next page */
|
436 |
|
|
add r3,r3,r7
|
437 |
|
|
add r5,r5,r7
|
438 |
|
|
cmp r3,r4 /* End of DRAM? */
|
439 |
|
|
beq 20f
|
440 |
|
|
sub r8,r8,#1 /* End of 1M section? */
|
441 |
|
|
cmp r8,#0
|
442 |
|
|
bne 12b /* Next page */
|
443 |
|
|
b 10b /* Next section */
|
444 |
|
|
20:
|
445 |
|
|
.endm
|
446 |
|
|
#else
|
447 |
|
|
#error Invalid DRAM size select
|
448 |
|
|
#endif
|
449 |
|
|
|
450 |
|
|
.macro MAP_L1_SEGMENT start end phys prot
|
451 |
|
|
ldr r3,=0x3FF /* Page tables need 2K boundary */
|
452 |
|
|
add r2,r2,r3
|
453 |
|
|
ldr r3,=~0x3FF
|
454 |
|
|
and r2,r2,r3
|
455 |
|
|
ldr r3,=\start
|
456 |
|
|
ldr r4,=\end
|
457 |
|
|
ldr r5,=\phys
|
458 |
|
|
ldr r6,=\prot
|
459 |
|
|
ldr r7,=MMU_SECTION_SIZE
|
460 |
|
|
10: orr r0,r5,r6
|
461 |
|
|
str r0,[r1],#4
|
462 |
|
|
add r5,r5,r7
|
463 |
|
|
add r3,r3,r7
|
464 |
|
|
cmp r3,r4
|
465 |
|
|
bne 10b
|
466 |
|
|
.endm
|
467 |
|
|
|
468 |
|
|
.macro PLATFORM_SETUP1
|
469 |
|
|
INIT_MEMORY_CONFIG
|
470 |
|
|
#ifdef CYG_HAL_STARTUP_RAM
|
471 |
|
|
RELOCATE_RAM_IMAGE
|
472 |
|
|
#endif
|
473 |
|
|
/* Initialize MMU to create new memory map */
|
474 |
|
|
ldr r1,=MMU_BASE
|
475 |
|
|
ldr r2,=PTE_BASE
|
476 |
|
|
MAP_DRAM
|
477 |
|
|
/* Nothing until PCMCIA0 */
|
478 |
|
|
MAP_L1_SEGMENT (DRAM_LA_END+0x000FFFFF)&0xFFF00000 EXPANSION2_LA_START 0 MMU_L1_TYPE_Fault
|
479 |
|
|
/* EXPANSION2, EXPANSION3, PCMCIA0, PCMCIA1 */
|
480 |
|
|
MAP_L1_SEGMENT EXPANSION2_LA_START SRAM_LA_START EXPANSION2_PA MMU_L1_TYPE_Section|MMU_AP_Any
|
481 |
|
|
/* SRAM */
|
482 |
|
|
ldr r3,=SRAM_LA_START
|
483 |
|
|
ldr r4,=MMU_L1_TYPE_Page|MMU_DOMAIN(0)
|
484 |
|
|
orr r4,r4,r2
|
485 |
|
|
str r4,[r1],#4
|
486 |
|
|
ldr r7,=MMU_PAGE_SIZE
|
487 |
|
|
ldr r5,=SRAM_LA_END
|
488 |
|
|
05: ldr r4,=MMU_L2_TYPE_Small|MMU_AP_Any|MMU_Bufferable|MMU_Cacheable
|
489 |
|
|
orr r4,r3,r4
|
490 |
|
|
str r4,[r2],#4
|
491 |
|
|
add r3,r3,r7
|
492 |
|
|
cmp r3,r5
|
493 |
|
|
bne 05b
|
494 |
|
|
ldr r4,=SRAM_LA_START+MMU_SECTION_SIZE
|
495 |
|
|
ldr r5,=MMU_L2_TYPE_Fault
|
496 |
|
|
10: str r5,[r2],#4
|
497 |
|
|
add r3,r3,r7
|
498 |
|
|
cmp r3,r4
|
499 |
|
|
bne 10b
|
500 |
|
|
ldr r4,=IO_LA_START
|
501 |
|
|
ldr r5,=MMU_L1_TYPE_Fault
|
502 |
|
|
ldr r7,=MMU_SECTION_SIZE
|
503 |
|
|
20: str r5,[r1],#4
|
504 |
|
|
add r3,r3,r7
|
505 |
|
|
cmp r3,r4
|
506 |
|
|
bne 20b
|
507 |
|
|
/* I/O */
|
508 |
|
|
ldr r3,=0x3FF /* Page tables need 2K boundary */
|
509 |
|
|
add r2,r2,r3
|
510 |
|
|
ldr r3,=~0x3FF
|
511 |
|
|
and r2,r2,r3
|
512 |
|
|
ldr r4,=MMU_L1_TYPE_Page|MMU_DOMAIN(0)
|
513 |
|
|
orr r4,r4,r2
|
514 |
|
|
str r4,[r1],#4
|
515 |
|
|
ldr r3,=IO_LA_START
|
516 |
|
|
ldr r4,=IO_LA_END
|
517 |
|
|
ldr r7,=MMU_PAGE_SIZE
|
518 |
|
|
ldr r5,=IO_PA|MMU_L2_TYPE_Small|MMU_AP_All
|
519 |
|
|
10: str r5,[r2],#4
|
520 |
|
|
add r5,r5,r7
|
521 |
|
|
add r3,r3,r7
|
522 |
|
|
cmp r3,r4
|
523 |
|
|
bne 10b
|
524 |
|
|
ldr r4,=IO_LA_START+MMU_SECTION_SIZE
|
525 |
|
|
ldr r5,=MMU_L2_TYPE_Fault
|
526 |
|
|
ldr r7,=MMU_PAGE_SIZE
|
527 |
|
|
10: str r5,[r2],#4
|
528 |
|
|
add r3,r3,r7
|
529 |
|
|
cmp r3,r4
|
530 |
|
|
bne 10b
|
531 |
|
|
ldr r4,=LCD_LA_START
|
532 |
|
|
ldr r5,=MMU_L1_TYPE_Fault
|
533 |
|
|
ldr r7,=MMU_SECTION_SIZE
|
534 |
|
|
20: str r5,[r1],#4
|
535 |
|
|
add r3,r3,r7
|
536 |
|
|
cmp r3,r4
|
537 |
|
|
bne 20b
|
538 |
|
|
/* LCD Buffer & Unmapped DRAM (holes and all) */
|
539 |
|
|
MAP_L1_SEGMENT LCD_LA_START ROM0_LA_START LCD_PA MMU_L1_TYPE_Section|MMU_AP_Any|MMU_Bufferable|MMU_Cacheable
|
540 |
|
|
/* ROM0 */
|
541 |
|
|
MAP_L1_SEGMENT ROM0_LA_START ROM0_LA_END ROM0_PA MMU_L1_TYPE_Section|MMU_AP_Any
|
542 |
|
|
/* ROM1 */
|
543 |
|
|
MAP_L1_SEGMENT ROM1_LA_START ROM1_LA_END ROM1_PA MMU_L1_TYPE_Section|MMU_AP_Any
|
544 |
|
|
/* Now initialize the MMU to use this new page table */
|
545 |
|
|
ldr r1,=MMU_BASE
|
546 |
|
|
MMU_INITIALIZE
|
547 |
|
|
#ifdef CYG_HAL_STARTUP_ROMRAM
|
548 |
|
|
RELOCATE_TEXT_SEGMENT
|
549 |
|
|
#endif // CYG_HAL_STARTUP_ROM
|
550 |
|
|
.endm
|
551 |
|
|
#endif // CYGSEM_HAL_STATIC_MMU_TABLES
|
552 |
|
|
|
553 |
|
|
#else // CYGSEM_HAL_INSTALL_MMU_TABLES
|
554 |
|
|
|
555 |
|
|
#define PLATFORM_SETUP1
|
556 |
|
|
#endif
|
557 |
|
|
#endif //_CYGHWR_LAYOUT_ONLY
|
558 |
|
|
|
559 |
|
|
/*---------------------------------------------------------------------------*/
|
560 |
|
|
/* end of hal_platform_setup.h */
|
561 |
|
|
#endif /* CYGONCE_HAL_PLATFORM_SETUP_H */
|