1 |
786 |
skrzyp |
#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 Free Software Foundation, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
18 |
|
|
// version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
21 |
|
|
// ANY 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
|
26 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use
|
30 |
|
|
// macros or inline functions from this file, or you compile this file
|
31 |
|
|
// and link it with other works to produce a work based on this file,
|
32 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
33 |
|
|
// the GNU General Public License. However the source code for this file
|
34 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
35 |
|
|
// General Public License v2.
|
36 |
|
|
//
|
37 |
|
|
// This exception does not invalidate any other reasons why a work based
|
38 |
|
|
// on this file might be covered by the GNU General Public License.
|
39 |
|
|
// -------------------------------------------
|
40 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
41 |
|
|
//=============================================================================
|
42 |
|
|
//#####DESCRIPTIONBEGIN####
|
43 |
|
|
//
|
44 |
|
|
// Author(s): gthomas
|
45 |
|
|
// Contributors: amichelotti
|
46 |
|
|
// Date: 2004-06-4
|
47 |
|
|
// Purpose: JTST platform specific support routines
|
48 |
|
|
// Description:
|
49 |
|
|
// Usage: #include <cyg/hal/hal_platform_setup.h>
|
50 |
|
|
//
|
51 |
|
|
//####DESCRIPTIONEND####
|
52 |
|
|
//
|
53 |
|
|
//===========================================================================*/
|
54 |
|
|
|
55 |
|
|
#include <cyg/hal/var_io.h>
|
56 |
|
|
#include <cyg/hal/hal_misc.h>
|
57 |
|
|
|
58 |
|
|
.macro __pio_clkgen_init
|
59 |
|
|
ldr r0,=AT91_PIO
|
60 |
|
|
ldr r1,=BIT21|BIT22|BIT23|BIT24|BIT25|BIT26|BIT27
|
61 |
|
|
str r1,[r0,#AT91_PIO_SODR] // set this bit must be always 1,
|
62 |
|
|
// otherwise resets
|
63 |
|
|
ldr r1,=BIT21|BIT22|BIT23|BIT24|BIT25|BIT26|BIT27
|
64 |
|
|
str r1,[r0,#AT91_PIO_OER] // set to output
|
65 |
|
|
str r1,[r0,#AT91_PIO_PER] // software control
|
66 |
|
|
ldr r1,=BIT21|BIT22|BIT23|BIT24|BIT25|BIT26|BIT27
|
67 |
|
|
str r1,[r0,#AT91_PIO_CODR] // leds all on
|
68 |
|
|
ldr r1,=BIT30|BIT3
|
69 |
|
|
ldr r1,[r0,#AT91_PIO_PDR] // (BIT30) usb interrupt line in
|
70 |
|
|
// (BIT3) active watchdog reset line
|
71 |
|
|
ldr r0,=AT91_CLKGEN
|
72 |
|
|
ldr r1,=32
|
73 |
|
|
str r1,[r0,#AT91_CLKGEN_CPTMAX0]
|
74 |
|
|
str r1,[r0,#AT91_CLKGEN_CPTMAX1]
|
75 |
|
|
ldr r1,=128
|
76 |
|
|
str r1,[r0,#AT91_CLKGEN_CPTMAX2] //watch dog divider1
|
77 |
|
|
ldr r1,=1024
|
78 |
|
|
str r1,[r0,#AT91_CLKGEN_CPTMAX3] //watch dog divider2
|
79 |
|
|
ldr r1,=2046
|
80 |
|
|
str r1,[r0,#AT91_CLKGEN_CPTMAX4] //watch dog divider3 (max accepted value)
|
81 |
|
|
|
82 |
|
|
ldr r1,=1
|
83 |
|
|
str r1,[r0,#AT91_CLKGEN_CLKENABLE]
|
84 |
|
|
|
85 |
|
|
#if defined(CYG_HAL_STARTUP_RAM)
|
86 |
|
|
// set internal ram as interrupt stack and other
|
87 |
|
|
ldr r0, =0x7ffc
|
88 |
|
|
ldr r1,=__startup_stack
|
89 |
|
|
ldr r2,=__startup_stack_base
|
90 |
|
|
sub r3,r1,r2
|
91 |
|
|
ldr r1,=.__startup_stack
|
92 |
|
|
str r0,[r1]
|
93 |
|
|
sub r0,r0,r3
|
94 |
|
|
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
|
95 |
|
|
ldr r1,=__interrupt_stack
|
96 |
|
|
ldr r2,=__interrupt_stack_base
|
97 |
|
|
sub r3,r1,r2
|
98 |
|
|
ldr r1,=.__interrupt_stack
|
99 |
|
|
str r0,[r1]
|
100 |
|
|
#endif
|
101 |
|
|
#endif
|
102 |
|
|
.endm
|
103 |
|
|
|
104 |
|
|
#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
|
105 |
|
|
|
106 |
|
|
.macro _setup
|
107 |
|
|
ldr r10,=_InitMemory // Initialize memory controller
|
108 |
|
|
movs r0,pc,lsr #20 // If ROM startup, PC < 0x100000
|
109 |
|
|
moveq r10,r10,lsl #12 // mask address to low 20 bits
|
110 |
|
|
moveq r10,r10,lsr #12
|
111 |
|
|
ldmia r10!,{r0-r9,r11-r12} // Table of initialization constants
|
112 |
|
|
#if defined(CYG_HAL_STARTUP_ROMRAM)
|
113 |
|
|
ldr r10,=0x0000FFFF
|
114 |
|
|
and r12,r12,r10
|
115 |
|
|
ldr r10,=0x00510000
|
116 |
|
|
orr r12,r12,r10
|
117 |
|
|
#endif
|
118 |
|
|
stmia r11!,{r0-r9} // Write to controller
|
119 |
|
|
mov pc,r12 // Change address space, break pipeline
|
120 |
|
|
_InitMemory:
|
121 |
|
|
.long 0x00502031 // FLASH
|
122 |
|
|
.long 0x00602021 // RAM
|
123 |
|
|
.long 0x00702021 // unused
|
124 |
|
|
.long 0x00802021 // unused
|
125 |
|
|
.long 0x00902021 // unused
|
126 |
|
|
.long 0x00A02021 // unused
|
127 |
|
|
.long 0x00b02021 // unused
|
128 |
|
|
.long 0x00c02021 // unused
|
129 |
|
|
.long 0x00000001 // REMAP commande
|
130 |
|
|
.long 0x00000006 // 7 memory regions, standard read
|
131 |
|
|
.long AT91_EBI // External Bus Interface address
|
132 |
|
|
.long 10f // address where to jump
|
133 |
|
|
10:
|
134 |
|
|
|
135 |
|
|
#if defined(CYG_HAL_STARTUP_ROMRAM)
|
136 |
|
|
ldr r0,=0x00510000 // Relocate FLASH/ROM to on-chip RAM
|
137 |
|
|
ldr r1,=0x00600000 // RAM base & length
|
138 |
|
|
ldr r2,=0x00610000
|
139 |
|
|
20: ldr r3,[r0],#4
|
140 |
|
|
str r3,[r1],#4
|
141 |
|
|
cmp r1,r2
|
142 |
|
|
bne 20b
|
143 |
|
|
ldr r0,=30f
|
144 |
|
|
mov pc,r0
|
145 |
|
|
30:
|
146 |
|
|
|
147 |
|
|
#endif
|
148 |
|
|
|
149 |
|
|
__pio_clkgen_init
|
150 |
|
|
.endm
|
151 |
|
|
|
152 |
|
|
#define CYGSEM_HAL_ROM_RESET_USES_JUMP
|
153 |
|
|
#define PLATFORM_SETUP1 _setup
|
154 |
|
|
#else
|
155 |
|
|
|
156 |
|
|
#define PLATFORM_SETUP1 __pio_clkgen_init
|
157 |
|
|
|
158 |
|
|
#endif
|
159 |
|
|
|
160 |
|
|
//-----------------------------------------------------------------------------
|
161 |
|
|
// end of hal_platform_setup.h
|
162 |
|
|
#endif // CYGONCE_HAL_PLATFORM_SETUP_H
|