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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [xscale/] [ixdp425/] [current/] [include/] [hal_platform_setup.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#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, 2004 Free Software Foundation, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under
17
// the terms of the GNU General Public License as published by the Free
18
// Software Foundation; either version 2 or (at your option) any later
19
// version.
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT
22
// ANY 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
27
// along with eCos; if not, write to the Free Software Foundation, Inc.,
28
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
29
//
30
// As a special exception, if other files instantiate templates or use
31
// macros or inline functions from this file, or you compile this file
32
// and link it with other works to produce a work based on this file,
33
// this file does not by itself cause the resulting work to be covered by
34
// the GNU General Public License. However the source code for this file
35
// must still be made available in accordance with section (3) of the GNU
36
// General Public License v2.
37
//
38
// This exception does not invalidate any other reasons why a work based
39
// on this file might be covered by the GNU General Public License.
40
// -------------------------------------------
41
// ####ECOSGPLCOPYRIGHTEND####
42
//=============================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):    msalter
46
// Contributors: msalter
47
// Date:         2002-12-10
48
// Purpose:      Intel XScale IXPD specific support routines
49
// Description:
50
// Usage:        #include <cyg/hal/hal_platform_setup.h>
51
//     Only used by "vectors.S"
52
//
53
//####DESCRIPTIONEND####
54
//
55
//===========================================================================*/
56
 
57
#include <pkgconf/system.h>             // System-wide configuration info
58
#include CYGBLD_HAL_VARIANT_H           // Variant specific configuration
59
#include CYGBLD_HAL_PLATFORM_H          // Platform specific configuration
60
#include <cyg/hal/hal_ixp425.h>         // Variant specific hardware definitions
61
#include <cyg/hal/hal_mmu.h>            // MMU definitions
62
#include <cyg/hal/hal_mm.h>             // more MMU definitions
63
#include <cyg/hal/ixdp425.h>            // Platform specific hardware definitions
64
 
65
// ------------------------------------------------------------------------
66
// Convenience macros for setting up page table
67
// 
68
.macro IXP_MAP_SDRAM va, c, b, x, p
69
    XSCALE_MMU_SECTION SDRAM_PHYS_BASE>>20, \va>>20, SDRAM_SIZE>>20, \c, \b, 3, \x, \p
70
.endm
71
 
72
.macro IXP_MAP_EXP_V n, va, sz, c, b, x, p
73
    XSCALE_MMU_SECTION (0x500 + ((IXP425_EXP_CS_SIZE * \n) >> 20)), \va>>20, \sz>>20, \c, \b, 3, \x, \p
74
.endm
75
 
76
.macro IXP_MAP_EXP n, sz, c, b, x, p
77
    IXP_MAP_EXP_V \n, (0x50000000 + (IXP425_EXP_CS_SIZE * \n)), \sz, \c, \b, \x, \p
78
.endm
79
 
80
.macro IXP_MAP_IO addr, sz
81
    XSCALE_MMU_SECTION \addr>>20, \addr>>20, \sz>>20, 0, 0, 3, 0, 0
82
.endm
83
 
84
 
85
#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
86
#define PLATFORM_SETUP1  _platform_setup1
87
#define CYGHWR_HAL_ARM_HAS_MMU
88
 
89
// ------------------------------------------------------------------------
90
// Define macro used to diddle the LEDs during early initialization.
91
// Can use r0+r1.  Argument in \x.
92
#define CYGHWR_LED_MACRO  DISPLAY \x, r0, r1
93
 
94
// Delay a bit
95
.macro DELAY cycles, reg0
96
    ldr     \reg0, =\cycles
97
    subs    \reg0, \reg0, #1
98
    subne   pc,  pc, #0xc
99
.endm
100
 
101
// ------------------------------------------------------------------------
102
// This macro represents the initial startup code for the platform        
103
        .macro _platform_setup1
104
 
105
#ifdef CYGHWR_HAL_ARM_BIGENDIAN
106
        // set big-endian
107
        mrc     p15, 0, r0, c1, c0, 0
108
        orr     r0, r0, #0x80
109
        mcr     p15, 0, r0, c1, c0, 0
110
        CPWAIT  r0
111
#endif
112
 
113
        ldr     r0,=(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_SUPERVISOR_MODE)
114
        msr     cpsr, r0
115
 
116
        // invalidate I & D caches & BTB
117
        mcr     p15, 0, r0, c7, c7, 0
118
        CPWAIT  r0
119
 
120
        // invalidate I & Data TLB
121
        mcr     p15, 0, r0, c8, c7, 0
122
        CPWAIT r0
123
 
124
        // drain write and fill buffers
125
        mcr     p15, 0, r0, c7, c10, 4
126
        CPWAIT  r0
127
 
128
        // disable write buffer coalescing
129
        mrc     p15, 0, r0, c1, c0, 1
130
        orr     r0, r0, #1
131
        mcr     p15, 0, r0, c1, c0, 1
132
        CPWAIT  r0
133
 
134
        // Setup chip selects
135
        ldr     r1, =IXP425_EXP_CFG_BASE
136
#ifdef IXP425_EXP_CS0_INIT
137
        ldr     r0, =IXP425_EXP_CS0_INIT
138
        str     r0, [r1, #IXP425_EXP_CS0]
139
#endif
140
#ifdef IXP425_EXP_CS1_INIT
141
        ldr     r0, =IXP425_EXP_CS1_INIT
142
        str     r0, [r1, #IXP425_EXP_CS1]
143
#endif
144
#ifdef IXP425_EXP_CS2_INIT
145
        ldr     r0, =IXP425_EXP_CS2_INIT
146
        str     r0, [r1, #IXP425_EXP_CS2]
147
#endif
148
#ifdef IXP425_EXP_CS3_INIT
149
        ldr     r0, =IXP425_EXP_CS3_INIT
150
        str     r0, [r1, #IXP425_EXP_CS3]
151
#endif
152
#ifdef IXP425_EXP_CS4_INIT
153
        ldr     r0, =IXP425_EXP_CS4_INIT
154
        str     r0, [r1, #IXP425_EXP_CS4]
155
#endif
156
#ifdef IXP425_EXP_CS5_INIT
157
        ldr     r0, =IXP425_EXP_CS5_INIT
158
        str     r0, [r1, #IXP425_EXP_CS5]
159
#endif
160
#ifdef IXP425_EXP_CS6_INIT
161
        ldr     r0, =IXP425_EXP_CS6_INIT
162
        str     r0, [r1, #IXP425_EXP_CS6]
163
#endif
164
#ifdef IXP425_EXP_CS7_INIT
165
        ldr     r0, =IXP425_EXP_CS7_INIT
166
        str     r0, [r1, #IXP425_EXP_CS7]
167
#endif
168
 
169
        DISPLAY 0x1001, r7, r8
170
 
171
        // Enable the Icache
172
        mrc     p15, 0, r0, c1, c0, 0
173
        orr     r0, r0, #MMU_Control_I
174
        mcr     p15, 0, r0, c1, c0, 0
175
        CPWAIT  r0
176
 
177
        DISPLAY 0x1002, r7, r8
178
 
179
        // Setup SDRAM controller
180
 
181
        ldr     r0, =IXP425_SDRAM_CFG_BASE
182
 
183
        ldr     r1, =IXP425_SDRAM_CONFIG_INIT
184
        str     r1, [r0, #IXP425_SDRAM_CONFIG]
185
 
186
        // disable refresh cycles
187
        mov     r1, #0
188
        str     r1, [r0, #IXP425_SDRAM_REFRESH]
189
 
190
        // send nop command
191
        mov     r1, #SDRAM_IR_NOP
192
        str     r1, [r0, #IXP425_SDRAM_IR]
193
        DELAY   0x10000, r1
194
 
195
        // set SDRAM internal refresh val
196
        ldr     r1, =IXP425_SDRAM_REFRESH_CNT
197
        str     r1, [r0, #IXP425_SDRAM_REFRESH]
198
        DELAY   0x10000, r1
199
 
200
        // send precharge-all command to close all open banks
201
        mov     r1, #SDRAM_IR_PRECHARGE
202
        str     r1, [r0, #IXP425_SDRAM_IR]
203
        DELAY   0x10000, r1
204
 
205
        // provide 8 auto-refresh cycles
206
        mov     r1, #SDRAM_IR_AUTO_REFRESH
207
        mov     r2, #8
208
  1:
209
        str     r1, [r0, #IXP425_SDRAM_IR]
210
        DELAY   0x800, r3
211
        subs    r2, r2, #1
212
        bne     1b
213
 
214
        // set mode register in sdram
215
        mov     r1, #IXP425_SDRAM_SET_MODE_CMD
216
        str     r1, [r0, #IXP425_SDRAM_IR]
217
        DELAY   0x10000, r1
218
 
219
        // start normal operation
220
        mov     r1, #SDRAM_IR_NORMAL
221
        str     r1, [r0, #IXP425_SDRAM_IR]
222
        DELAY   0x10000, r1
223
 
224
        DISPLAY 0x1003, r7, r8
225
 
226
        // Enable byte swapping control via page table P bit.    
227
        ldr     r2, =IXP425_EXP_CFG_BASE
228
        ldr     r1, [r2, #IXP425_EXP_CNFG1]
229
        orr     r1, r1, #EXP_CNFG1_BYTE_SWAP_EN
230
        str     r1, [r2, #IXP425_EXP_CNFG1]
231
 
232
        // value to load into pc to jump to real runtime address
233
        ldr     r0, =1f
234
#if defined(CYG_HAL_STARTUP_ROMRAM)
235
        // R0 holds a RAM address for ROMRAM startup,
236
        // so convert to a flash address.
237
        orr     r0, r0, #IXDP_FLASH_BASE
238
#endif
239
 
240
        // Setup EXP_CNFG0 value to switch EXP bus out of low memory
241
        ldr     r2, =IXP425_EXP_CFG_BASE
242
        ldr     r1, [r2, #IXP425_EXP_CNFG0]
243
        bic     r1, r1, #EXP_CNFG0_MEM_MAP
244
        ldr     r3, =0xFFFF
245
        ldr     r4, =IXDP425_LED_DATA
246
 
247
 
248
        b       icache_boundary
249
        .p2align 5
250
icache_boundary:
251
        // Here is where we switch from boot address (0x000000000) to the
252
        // actual flash runtime address. We align to cache boundary so we
253
        // execute from cache during the switchover. Cachelines are 8 words.
254
        str     r1, [r2, #IXP425_EXP_CNFG0]    // make the EXP bus switch
255
        nop
256
        nop
257
        nop
258
        nop
259
        mov     pc, r0
260
        strh    r3, [r4]    // We should never reach this point. If we do,
261
                            // display FFFF and loop forever.
262
    0:  b       0b
263
    1:
264
 
265
        DISPLAY 0x1004, r7, r8
266
 
267
#if defined(CYG_HAL_STARTUP_ROMRAM)
268
        mov     r0, #IXDP_FLASH_BASE
269
        mov     r1, #SDRAM_PHYS_BASE
270
        ldr     r2, =__ram_data_end
271
20:     ldr     r3, [r0],#4
272
        str     r3, [r1],#4
273
        cmp     r1, r2
274
        bne     20b
275
 
276
        // start executing from RAM
277
        ldr     r0, =30f
278
        mov     pc, r0
279
30:
280
#endif
281
 
282
        // Build mmu tables into RAM so page table walks by the cpu
283
        // don't interfere with FLASH programming.
284
        mov     r1, #SDRAM_PHYS_BASE
285
        orr     r1, r1, #0x4000         // RAM tables
286
        add     r2, r1, #0x4000         // End of tables
287
 
288
        // First clear table
289
        mov     r0, #0
290
    1:
291
        str     r0, [r1], #4
292
        cmp     r1, r2
293
        bne     1b
294
 
295
        // Build section mappings
296
        IXP_MAP_SDRAM   SDRAM_BASE,           1, 0, 0, 0   // Cached SDRAM
297
        IXP_MAP_SDRAM   SDRAM_ALIAS_BASE,     1, 0, 0, 0   // Cached SDRAM alias
298
        IXP_MAP_SDRAM   SDRAM_UNCACHED_BASE,  0, 0, 0, 0   // Uncached SDRAM
299
        IXP_MAP_SDRAM   SDRAM_DC_BASE,        1, 0, 0, 1   // Cached data coherent SDRAM
300
 
301
        IXP_MAP_EXP 0, IXDP_FLASH_SIZE,       1, 0, 0, 0   // Flash
302
        IXP_MAP_EXP 2, IXDP425_LED_SIZE,      0, 0, 0, 0   // LED
303
        IXP_MAP_EXP 4, (1 << 20),             0, 0, 0, 0   // NPE use
304
        IXP_MAP_EXP 5, (1 << 20),             0, 0, 0, 0   // NPE use
305
 
306
        IXP_MAP_EXP_V 0, IXDP_FLASH_DC_BASE, IXDP_FLASH_SIZE, 1, 0, 0, 1  // data coherent flash
307
        IXP_MAP_EXP_V 0, IXDP_FLASH_UNCACHED_BASE, IXDP_FLASH_SIZE, 0, 0, 0, 0  // uncached flash
308
 
309
        IXP_MAP_IO      IXP425_PCI_WINDOW_BASE,  IXP425_PCI_WINDOW_SIZE
310
        IXP_MAP_IO      IXP425_QMGR_BASE,        IXP425_QMGR_SIZE
311
        IXP_MAP_IO      IXP425_PCI_CFG_BASE,     IXP425_PCI_CFG_SIZE
312
        IXP_MAP_IO      IXP425_EXP_CFG_BASE,     IXP425_EXP_CFG_SIZE
313
        IXP_MAP_IO      IXP425_MISC_CFG_BASE,    IXP425_MISC_CFG_SIZE
314
        IXP_MAP_IO      IXP425_SDRAM_CFG_BASE,   IXP425_SDRAM_CFG_SIZE
315
 
316
        DISPLAY 0x1005, r7, r8
317
 
318
        mcr     p15, 0, r0, c7, c10, 4  // drain the write & fill buffers
319
        CPWAIT  r0
320
 
321
        // Set the TTB register to DRAM mmu_table
322
        ldr     r0, =(SDRAM_PHYS_BASE | 0x4000) // RAM tables
323
        mcr     p15, 0, r0, c2, c0, 0             // load page table pointer
324
        CPWAIT  r0
325
 
326
        // enable permission checks in all domains
327
        ldr     r0, =0x55555555
328
        mcr     p15, 0, r0, c3, c0, 0
329
        CPWAIT  r0
330
 
331
        DISPLAY 0x1006, r7, r8
332
 
333
        // enable mmu
334
        mrc     p15, 0, r0, c1, c0, 0
335
        orr     r0, r0, #MMU_Control_M
336
        orr     r0, r0, #MMU_Control_R
337
        mcr     p15, 0, r0, c1, c0, 0
338
        CPWAIT  r0
339
 
340
        DISPLAY 0x1007, r7, r8
341
 
342
        // enable D cache
343
        mrc     p15, 0, r0, c1, c0, 0
344
        orr     r0, r0, #MMU_Control_C
345
        mcr     p15, 0, r0, c1, c0, 0
346
        CPWAIT  r0
347
 
348
        DISPLAY 0x1008, r7, r8
349
 
350
        // Enable branch target buffer
351
        mrc     p15, 0, r0, c1, c0, 0
352
        orr     r0, r0, #MMU_Control_BTB
353
        mcr     p15, 0, r0, c1, c0, 0
354
        CPWAIT  r0
355
 
356
        DISPLAY 0x1009, r7, r8
357
 
358
        mcr     p15, 0, r0, c7, c10, 4  // drain the write & fill buffers
359
        CPWAIT  r0
360
 
361
        mcr     p15, 0, r0, c7, c7, 0   // flush Icache, Dcache and BTB
362
        CPWAIT  r0
363
 
364
        mcr     p15, 0, r0, c8, c7, 0   // flush instuction and data TLBs
365
        CPWAIT  r0
366
 
367
        mcr     p15, 0, r0, c7, c10, 4   // drain the write & fill buffers
368
        CPWAIT r0
369
 
370
        DISPLAY 0x100A, r7, r8
371
 
372
        // save SDRAM size
373
        ldr     r1, =hal_dram_size  /* [see hal_intr.h] */
374
        mov     r8, #SDRAM_SIZE
375
        str     r8, [r1]
376
 
377
        DISPLAY 0x100B, r7, r8
378
 
379
        .endm    // _platform_setup1
380
 
381
#else // defined(CYG_HAL_STARTUP_ROM)
382
#define PLATFORM_SETUP1
383
#endif
384
 
385
#define PLATFORM_VECTORS         _platform_vectors
386
        .macro  _platform_vectors
387
        .endm
388
 
389
/*---------------------------------------------------------------------------*/
390
/* end of hal_platform_setup.h                                               */
391
#endif /* CYGONCE_HAL_PLATFORM_SETUP_H */

powered by: WebSVN 2.1.0

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