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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [xscale/] [mpc50/] [current/] [src/] [mpc50_misc.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      mpc50_misc.c
4
//
5
//      HAL misc board support code for MPC 5.0
6
//
7
//=============================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 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):    <knud.woehler@microplex.de>
43
// Date:         2003-01-06
44
//
45
//####DESCRIPTIONEND####
46
//
47
//========================================================================*/
48
#include <pkgconf/hal.h>
49
#include <pkgconf/system.h>
50
#include CYGBLD_HAL_PLATFORM_H
51
#include <cyg/infra/cyg_type.h>
52
#include <cyg/infra/cyg_trac.h>
53
#include <cyg/infra/cyg_ass.h>
54
#include <cyg/hal/hal_io.h>
55
#include <cyg/hal/hal_arch.h>
56
#include <cyg/hal/hal_diag.h>
57
#include <cyg/hal/hal_intr.h>
58
#include <cyg/hal/hal_cache.h>
59
#include <cyg/hal/hal_pxa2x0.h>
60
#include <cyg/hal/hal_misc.h>
61
#include <cyg/hal/mpc50.h>
62
#include <cyg/infra/diag.h>
63
#include <cyg/hal/hal_mm.h>
64
 
65
 
66
void hal_mmu_init(void)
67
{
68
#ifdef CYG_HAL_STARTUP_ROM
69
 
70
    typedef cyg_uint32 aptr;        // for arithmetic
71
 
72
        unsigned long ttb_base = PXA2X0_RAM_BANK0_BASE + 0x4000;
73
        unsigned long *SDRAMConfig;
74
    int *p_hdsize = (int *)((aptr)(&hal_dram_size) | (0xA00u *SZ_1M));
75
    int *p_hdtype = (int *)((aptr)(&hal_dram_type) | (0xA00u *SZ_1M));
76
 
77
        *p_hdtype = 0;
78
        for(SDRAMConfig=0; *SDRAMConfig != MPC50_VAL_MAGIC ;SDRAMConfig++);
79
        SDRAMConfig += (MPC50_VAL_OFFS_MDCNFG>>2);
80
 
81
        // set TTB Register
82
        asm volatile ("mcr  p15,0,%0,c2,c0,0" : : "r"(ttb_base));
83
 
84
        // erase Page Table
85
        memset((void *)ttb_base, 0, ARM_FIRST_LEVEL_PAGE_TABLE_SIZE);
86
 
87
        // create Page Table
88
 
89
        /*               Actual                 Virtual         Size    Attribute                                                  Function    */
90
        /*                   Base                       Base                    MB      cached?          buffered?         access permissions                  */
91
        /*               xxx00000       xxx00000                                                                                       */
92
        X_ARM_MMU_SECTION(0x000,                0x500,                  16,             ARM_CACHEABLE,   ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Boot flash ROMspace */
93
        X_ARM_MMU_SECTION(0x040,                0x600,                  64,             ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* FPGA Register */
94
        X_ARM_MMU_SECTION(0x080,                0x680,                  64,             ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* LAN Register */
95
        X_ARM_MMU_SECTION(0x400,                0x400,                  192,    ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* PXA2x0 Register */
96
 
97
        if((*SDRAMConfig & 0x00000018) == 0x08) // 32MB per bank
98
        {
99
        X_ARM_MMU_SECTION(0xA00,                0x0,                    32,             ARM_CACHEABLE,   ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 0 */
100
        X_ARM_MMU_SECTION(0xA40,                0x020,                  32,             ARM_CACHEABLE,   ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 1 */
101
    *p_hdsize = 64 * SZ_1M; // 64MB
102
        if((*SDRAMConfig & 0x00030000) != 0)     // 4 banks 
103
        {
104
        X_ARM_MMU_SECTION(0xA80,                0x040,                  32,             ARM_CACHEABLE,   ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 2 */
105
        X_ARM_MMU_SECTION(0xAc0,                0x060,                  32,             ARM_CACHEABLE,   ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 3 */
106
        *p_hdsize = 128 * SZ_1M; // 128MB       
107
        }
108
        }else{                          // 64MB per bank
109
        X_ARM_MMU_SECTION(0xA00,                0x0,                    64,             ARM_CACHEABLE,   ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 0 */
110
        X_ARM_MMU_SECTION(0xA40,                0x040,                  64,             ARM_CACHEABLE,   ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 1 */
111
        *p_hdsize = 128 * SZ_1M; // 128MB       
112
        if((*SDRAMConfig & 0x00030000) != 0)     // 4 banks 
113
        {
114
        X_ARM_MMU_SECTION(0xA80,                0x080,                  64,             ARM_CACHEABLE,   ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 2 */
115
        X_ARM_MMU_SECTION(0xAc0,                0x0c0,                  64,             ARM_CACHEABLE,   ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 3 */
116
        *p_hdsize = 256 * SZ_1M; // 256MB       
117
        }
118
        }
119
        X_ARM_MMU_SECTION(0xA00,                0xA00,                  256,    ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Unmapped Memory */
120
 
121
        X_ARM_MMU_SECTION(0xC00,                0xC00,                  128,    ARM_CACHEABLE,   ARM_BUFFERABLE,   ARM_ACCESS_PERM_RW_RW);
122
#endif
123
}
124
 
125
void plf_hardware_init(void)
126
{
127
        int t;
128
        unsigned long int gpioValue ;
129
 
130
        // enable FFUART clock
131
        gpioValue = *PXA2X0_CKEN ;
132
        gpioValue = gpioValue | (unsigned long)0x40 ;
133
        *PXA2X0_CKEN = gpioValue ;
134
 
135
        hal_if_init();                          // Set up eCos/ROM interfaces
136
 
137
        mpc50_user_hardware_init();
138
 
139
        return ;
140
}
141
 
142
#include CYGHWR_MEMORY_LAYOUT_H
143
typedef void code_fun(void);
144
void mpc50_program_new_stack(void *func)
145
{
146
    register CYG_ADDRESS stack_ptr asm("sp");
147
    register CYG_ADDRESS old_stack asm("r4");
148
    register code_fun *new_func asm("r0");
149
    old_stack = stack_ptr;
150
    stack_ptr = CYGMEM_REGION_ram + CYGMEM_REGION_ram_SIZE - sizeof(CYG_ADDRESS);
151
    new_func = (code_fun*)func;
152
    new_func();
153
    stack_ptr = old_stack;
154
    return;
155
}
156
 
157
//
158
// Memory layout
159
//
160
externC cyg_uint8 *
161
hal_arm_mem_real_region_top( cyg_uint8 *regionend )
162
{
163
    CYG_ASSERT( hal_dram_size > 0, "Didn't detect DRAM size!" );
164
    CYG_ASSERT( hal_dram_size <=  256<<20, "More than 256MB reported - that can't be right" );
165
    CYG_ASSERT( 0 == (hal_dram_size & 0xfffff), "hal_dram_size not whole Mb" );
166
    // is it the "normal" end of the DRAM region? If so, it should be
167
    // replaced by the real size
168
    if ( regionend == ((cyg_uint8 *)CYGMEM_REGION_ram + CYGMEM_REGION_ram_SIZE) )
169
        {
170
        regionend = (cyg_uint8 *)CYGMEM_REGION_ram + hal_dram_size;
171
    }
172
    return regionend;
173
}
174
 
175
void mpc50_user_hardware_init(void) CYGBLD_ATTRIB_WEAK;
176
 
177
void mpc50_user_hardware_init()
178
{
179
}
180
 
181
 
182
 
183
/*------------------------------------------------------------------------*/
184
// EOF mpc50_misc.c

powered by: WebSVN 2.1.0

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