]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/hal/arm/lpc24xx/ea2468/v2_0/include/hal_platform_setup.h
Initial revision
[karo-tx-redboot.git] / packages / hal / arm / lpc24xx / ea2468 / v2_0 / include / hal_platform_setup.h
1 #ifndef CYGONCE_HAL_PLATFORM_SETUP_H
2 #define CYGONCE_HAL_PLATFORM_SETUP_H
3 /*=============================================================================
4 //
5 //      hal_platform_setup.h
6 //
7 //      Platform specific support for HAL (assembly code)
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 Red Hat, Inc.
14 // Copyright (C) 2008 eCosCentric Limited
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 version.
19 //
20 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21 // 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 along
26 // with eCos; if not, write to the Free Software Foundation, Inc.,
27 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28 //
29 // As a special exception, if other files instantiate templates or use macros
30 // or inline functions from this file, or you compile this file and link it
31 // with other works to produce a work based on this file, this file does not
32 // by itself cause the resulting work to be covered by the GNU General Public
33 // License. However the source code for this file must still be made available
34 // in accordance with section (3) of the GNU General Public License.
35 //
36 // This exception does not invalidate any other reasons why a work based on
37 // this file might be covered by the GNU General Public License.
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //=============================================================================
41 //#####DESCRIPTIONBEGIN####
42 //
43 // Author(s):    Uwe Kindler
44 // Contributors: Uwe Kindler
45 // Date:         2008-06-05
46 // Purpose:      EA LPC2468 OEM platform specific support routines
47 // Description:
48 // Usage:        #include <cyg/hal/hal_platform_setup.h>
49 //
50 //####DESCRIPTIONEND####
51 //
52 //===========================================================================*/
53 #include <pkgconf/system.h>
54 #include <cyg/hal/var_io.h>
55
56
57 //
58 // The minimum initialisation code - we simply setup a valid C stack in 
59 // internal SRAM and do any further initialisation in C code
60 //
61 #if defined(CYG_HAL_STARTUP_ROM)
62 .macro _setup
63     //
64     // While setting the stack pointer please note that the 
65     // Flash programming routines use a
66     // section of the on-chip SRAM. In-System Programming (ISP) uses 
67     // the top 256 bytes and In-Application Programming (IAP) uses the 
68     // top 128 bytes of the on-chip SRAM. The application stack should 
69     // not overlap this area.
70     //
71     ldr r2,=0x4000ffff // ram end
72     sub sp,r2,#0xff
73         
74     //
75     // now map the vector table to internal flash - normally this should be
76     // the default value after boot - but we go the save way here and force
77     // the mapping to internal flash (the value for 
78     // CYGARC_HAL_LPC24XX_REG_MEMMAP is 1)
79     //
80     ldr r0,=CYGARC_HAL_LPC24XX_REG_SCB_BASE
81     mov r1,#1
82     str r1, [r0,#CYGARC_HAL_LPC24XX_REG_MEMMAP] 
83     
84     //    
85     // Now its is save to copy the first 64 bytes of flash to RAM
86     //
87     mov r0,#0                                   
88     mov r1,#0x40000000
89     mov r2,#0x40
90 1:
91     ldr r3,[r0,#4]!
92     str r3,[r1,#4]!
93     cmps r0,r2
94     bne 1b
95         
96     // 
97     // Now we can map the vector table to internal SRAM because the SRAM no
98     // contains a copy of the vector table from flash (the value for 
99     // CYGARC_HAL_LPC24XX_REG_MEMMAP is 2 = SRAM)
100     //
101     ldr r0,=CYGARC_HAL_LPC24XX_REG_SCB_BASE
102     mov r1,#2                                   // User RAM Mode. Interrupt 
103                                      // vectors are re-mapped to Static RAM.
104     str r1, [r0,#CYGARC_HAL_LPC24XX_REG_MEMMAP]
105     
106     //
107     // now we have a valid stack and we can jump into the beautiful
108     // world of C and do any further initialisation in C code
109     //
110     bl hal_plf_startup
111 .endm
112 #define CYGSEM_HAL_ROM_RESET_USES_JUMP
113 #else
114 .macro  _setup
115 .endm    
116 #endif
117
118 #define PLATFORM_SETUP1 _setup
119
120 //-----------------------------------------------------------------------------
121 // end of hal_platform_setup.h
122 #endif // CYGONCE_HAL_PLATFORM_SETUP_H