Commit 7def6b34f910f08d7ef0a14646da067719237ca2
1 parent
dd60d1223b
Exists in
master
and in
56 other branches
lib_{m68k,microblaze,mips,ppc}/: Remove obsolete references to CONFIG_COMMANDS
Signed-off-by: Jon Loeliger <jdl@freescale.com>
Showing 5 changed files with 34 additions and 34 deletions Inline Diff
lib_m68k/board.c
1 | /* | 1 | /* |
2 | * (C) Copyright 2003 | 2 | * (C) Copyright 2003 |
3 | * Josef Baumgartner <josef.baumgartner@telex.de> | 3 | * Josef Baumgartner <josef.baumgartner@telex.de> |
4 | * | 4 | * |
5 | * (C) Copyright 2000-2002 | 5 | * (C) Copyright 2000-2002 |
6 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 6 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
7 | * | 7 | * |
8 | * See file CREDITS for list of people who contributed to this | 8 | * See file CREDITS for list of people who contributed to this |
9 | * project. | 9 | * project. |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or | 11 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU General Public License as | 12 | * modify it under the terms of the GNU General Public License as |
13 | * published by the Free Software Foundation; either version 2 of | 13 | * published by the Free Software Foundation; either version 2 of |
14 | * the License, or (at your option) any later version. | 14 | * the License, or (at your option) any later version. |
15 | * | 15 | * |
16 | * This program is distributed in the hope that it will be useful, | 16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU General Public License for more details. | 19 | * GNU General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU General Public License | 21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software | 22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
24 | * MA 02111-1307 USA | 24 | * MA 02111-1307 USA |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <common.h> | 27 | #include <common.h> |
28 | #include <watchdog.h> | 28 | #include <watchdog.h> |
29 | #include <command.h> | 29 | #include <command.h> |
30 | #include <malloc.h> | 30 | #include <malloc.h> |
31 | #include <devices.h> | 31 | #include <devices.h> |
32 | 32 | ||
33 | #ifdef CONFIG_M5272 | 33 | #ifdef CONFIG_M5272 |
34 | #include <asm/immap_5272.h> | 34 | #include <asm/immap_5272.h> |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #if (CONFIG_COMMANDS & CFG_CMD_IDE) || defined(CONFIG_CMD_IDE) | 37 | #if defined(CONFIG_CMD_IDE) |
38 | #include <ide.h> | 38 | #include <ide.h> |
39 | #endif | 39 | #endif |
40 | #if (CONFIG_COMMANDS & CFG_CMD_SCSI) || defined(CONFIG_CMD_SCSI) | 40 | #if defined(CONFIG_CMD_SCSI) |
41 | #include <scsi.h> | 41 | #include <scsi.h> |
42 | #endif | 42 | #endif |
43 | #if (CONFIG_COMMANDS & CFG_CMD_KGDB) || defined(CONFIG_CMD_KGDB) | 43 | #if defined(CONFIG_CMD_KGDB) |
44 | #include <kgdb.h> | 44 | #include <kgdb.h> |
45 | #endif | 45 | #endif |
46 | #ifdef CONFIG_STATUS_LED | 46 | #ifdef CONFIG_STATUS_LED |
47 | #include <status_led.h> | 47 | #include <status_led.h> |
48 | #endif | 48 | #endif |
49 | #include <net.h> | 49 | #include <net.h> |
50 | #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG) || defined(CONFIG_CMD_BEDBUG) | 50 | #if defined(CONFIG_CMD_BEDBUG) |
51 | #include <cmd_bedbug.h> | 51 | #include <cmd_bedbug.h> |
52 | #endif | 52 | #endif |
53 | #ifdef CFG_ALLOC_DPRAM | 53 | #ifdef CFG_ALLOC_DPRAM |
54 | #include <commproc.h> | 54 | #include <commproc.h> |
55 | #endif | 55 | #endif |
56 | #include <version.h> | 56 | #include <version.h> |
57 | 57 | ||
58 | #if defined(CONFIG_HARD_I2C) || \ | 58 | #if defined(CONFIG_HARD_I2C) || \ |
59 | defined(CONFIG_SOFT_I2C) | 59 | defined(CONFIG_SOFT_I2C) |
60 | #include <i2c.h> | 60 | #include <i2c.h> |
61 | #endif | 61 | #endif |
62 | 62 | ||
63 | DECLARE_GLOBAL_DATA_PTR; | 63 | DECLARE_GLOBAL_DATA_PTR; |
64 | 64 | ||
65 | static char *failed = "*** failed ***\n"; | 65 | static char *failed = "*** failed ***\n"; |
66 | 66 | ||
67 | #ifdef CONFIG_PCU_E | 67 | #ifdef CONFIG_PCU_E |
68 | extern flash_info_t flash_info[]; | 68 | extern flash_info_t flash_info[]; |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | #include <environment.h> | 71 | #include <environment.h> |
72 | 72 | ||
73 | #if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \ | 73 | #if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \ |
74 | (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \ | 74 | (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \ |
75 | defined(CFG_ENV_IS_IN_NVRAM) | 75 | defined(CFG_ENV_IS_IN_NVRAM) |
76 | #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE) | 76 | #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE) |
77 | #else | 77 | #else |
78 | #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN | 78 | #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN |
79 | #endif | 79 | #endif |
80 | 80 | ||
81 | extern ulong __init_end; | 81 | extern ulong __init_end; |
82 | extern ulong _end; | 82 | extern ulong _end; |
83 | 83 | ||
84 | extern void timer_init(void); | 84 | extern void timer_init(void); |
85 | 85 | ||
86 | #if defined(CONFIG_WATCHDOG) | 86 | #if defined(CONFIG_WATCHDOG) |
87 | # define INIT_FUNC_WATCHDOG_INIT watchdog_init, | 87 | # define INIT_FUNC_WATCHDOG_INIT watchdog_init, |
88 | # define WATCHDOG_DISABLE watchdog_disable | 88 | # define WATCHDOG_DISABLE watchdog_disable |
89 | 89 | ||
90 | extern int watchdog_init(void); | 90 | extern int watchdog_init(void); |
91 | extern int watchdog_disable(void); | 91 | extern int watchdog_disable(void); |
92 | #else | 92 | #else |
93 | # define INIT_FUNC_WATCHDOG_INIT /* undef */ | 93 | # define INIT_FUNC_WATCHDOG_INIT /* undef */ |
94 | # define WATCHDOG_DISABLE /* undef */ | 94 | # define WATCHDOG_DISABLE /* undef */ |
95 | #endif /* CONFIG_WATCHDOG */ | 95 | #endif /* CONFIG_WATCHDOG */ |
96 | 96 | ||
97 | ulong monitor_flash_len; | 97 | ulong monitor_flash_len; |
98 | 98 | ||
99 | /* | 99 | /* |
100 | * Begin and End of memory area for malloc(), and current "brk" | 100 | * Begin and End of memory area for malloc(), and current "brk" |
101 | */ | 101 | */ |
102 | static ulong mem_malloc_start = 0; | 102 | static ulong mem_malloc_start = 0; |
103 | static ulong mem_malloc_end = 0; | 103 | static ulong mem_malloc_end = 0; |
104 | static ulong mem_malloc_brk = 0; | 104 | static ulong mem_malloc_brk = 0; |
105 | 105 | ||
106 | /************************************************************************ | 106 | /************************************************************************ |
107 | * Utilities * | 107 | * Utilities * |
108 | ************************************************************************ | 108 | ************************************************************************ |
109 | */ | 109 | */ |
110 | 110 | ||
111 | /* | 111 | /* |
112 | * The Malloc area is immediately below the monitor copy in DRAM | 112 | * The Malloc area is immediately below the monitor copy in DRAM |
113 | */ | 113 | */ |
114 | static void mem_malloc_init (void) | 114 | static void mem_malloc_init (void) |
115 | { | 115 | { |
116 | ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off; | 116 | ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off; |
117 | 117 | ||
118 | mem_malloc_end = dest_addr; | 118 | mem_malloc_end = dest_addr; |
119 | mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN; | 119 | mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN; |
120 | mem_malloc_brk = mem_malloc_start; | 120 | mem_malloc_brk = mem_malloc_start; |
121 | 121 | ||
122 | memset ((void *) mem_malloc_start, | 122 | memset ((void *) mem_malloc_start, |
123 | 0, | 123 | 0, |
124 | mem_malloc_end - mem_malloc_start); | 124 | mem_malloc_end - mem_malloc_start); |
125 | } | 125 | } |
126 | 126 | ||
127 | void *sbrk (ptrdiff_t increment) | 127 | void *sbrk (ptrdiff_t increment) |
128 | { | 128 | { |
129 | ulong old = mem_malloc_brk; | 129 | ulong old = mem_malloc_brk; |
130 | ulong new = old + increment; | 130 | ulong new = old + increment; |
131 | 131 | ||
132 | if ((new < mem_malloc_start) || | 132 | if ((new < mem_malloc_start) || |
133 | (new > mem_malloc_end) ) { | 133 | (new > mem_malloc_end) ) { |
134 | return (NULL); | 134 | return (NULL); |
135 | } | 135 | } |
136 | mem_malloc_brk = new; | 136 | mem_malloc_brk = new; |
137 | return ((void *)old); | 137 | return ((void *)old); |
138 | } | 138 | } |
139 | 139 | ||
140 | char *strmhz(char *buf, long hz) | 140 | char *strmhz(char *buf, long hz) |
141 | { | 141 | { |
142 | long l, n; | 142 | long l, n; |
143 | long m; | 143 | long m; |
144 | 144 | ||
145 | n = hz / 1000000L; | 145 | n = hz / 1000000L; |
146 | 146 | ||
147 | l = sprintf (buf, "%ld", n); | 147 | l = sprintf (buf, "%ld", n); |
148 | 148 | ||
149 | m = (hz % 1000000L) / 1000L; | 149 | m = (hz % 1000000L) / 1000L; |
150 | 150 | ||
151 | if (m != 0) | 151 | if (m != 0) |
152 | sprintf (buf+l, ".%03ld", m); | 152 | sprintf (buf+l, ".%03ld", m); |
153 | 153 | ||
154 | return (buf); | 154 | return (buf); |
155 | } | 155 | } |
156 | 156 | ||
157 | /* | 157 | /* |
158 | * All attempts to come up with a "common" initialization sequence | 158 | * All attempts to come up with a "common" initialization sequence |
159 | * that works for all boards and architectures failed: some of the | 159 | * that works for all boards and architectures failed: some of the |
160 | * requirements are just _too_ different. To get rid of the resulting | 160 | * requirements are just _too_ different. To get rid of the resulting |
161 | * mess of board dependend #ifdef'ed code we now make the whole | 161 | * mess of board dependend #ifdef'ed code we now make the whole |
162 | * initialization sequence configurable to the user. | 162 | * initialization sequence configurable to the user. |
163 | * | 163 | * |
164 | * The requirements for any new initalization function is simple: it | 164 | * The requirements for any new initalization function is simple: it |
165 | * receives a pointer to the "global data" structure as it's only | 165 | * receives a pointer to the "global data" structure as it's only |
166 | * argument, and returns an integer return code, where 0 means | 166 | * argument, and returns an integer return code, where 0 means |
167 | * "continue" and != 0 means "fatal error, hang the system". | 167 | * "continue" and != 0 means "fatal error, hang the system". |
168 | */ | 168 | */ |
169 | typedef int (init_fnc_t) (void); | 169 | typedef int (init_fnc_t) (void); |
170 | 170 | ||
171 | /************************************************************************ | 171 | /************************************************************************ |
172 | * Init Utilities * | 172 | * Init Utilities * |
173 | ************************************************************************ | 173 | ************************************************************************ |
174 | * Some of this code should be moved into the core functions, | 174 | * Some of this code should be moved into the core functions, |
175 | * but let's get it working (again) first... | 175 | * but let's get it working (again) first... |
176 | */ | 176 | */ |
177 | 177 | ||
178 | static int init_baudrate (void) | 178 | static int init_baudrate (void) |
179 | { | 179 | { |
180 | uchar tmp[64]; /* long enough for environment variables */ | 180 | uchar tmp[64]; /* long enough for environment variables */ |
181 | int i = getenv_r ("baudrate", tmp, sizeof (tmp)); | 181 | int i = getenv_r ("baudrate", tmp, sizeof (tmp)); |
182 | 182 | ||
183 | gd->baudrate = (i > 0) | 183 | gd->baudrate = (i > 0) |
184 | ? (int) simple_strtoul (tmp, NULL, 10) | 184 | ? (int) simple_strtoul (tmp, NULL, 10) |
185 | : CONFIG_BAUDRATE; | 185 | : CONFIG_BAUDRATE; |
186 | return (0); | 186 | return (0); |
187 | } | 187 | } |
188 | 188 | ||
189 | /***********************************************************************/ | 189 | /***********************************************************************/ |
190 | 190 | ||
191 | static int init_func_ram (void) | 191 | static int init_func_ram (void) |
192 | { | 192 | { |
193 | int board_type = 0; /* use dummy arg */ | 193 | int board_type = 0; /* use dummy arg */ |
194 | puts ("DRAM: "); | 194 | puts ("DRAM: "); |
195 | 195 | ||
196 | if ((gd->ram_size = initdram (board_type)) > 0) { | 196 | if ((gd->ram_size = initdram (board_type)) > 0) { |
197 | print_size (gd->ram_size, "\n"); | 197 | print_size (gd->ram_size, "\n"); |
198 | return (0); | 198 | return (0); |
199 | } | 199 | } |
200 | puts (failed); | 200 | puts (failed); |
201 | return (1); | 201 | return (1); |
202 | } | 202 | } |
203 | 203 | ||
204 | /***********************************************************************/ | 204 | /***********************************************************************/ |
205 | 205 | ||
206 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) | 206 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) |
207 | static int init_func_i2c (void) | 207 | static int init_func_i2c (void) |
208 | { | 208 | { |
209 | puts ("I2C: "); | 209 | puts ("I2C: "); |
210 | i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); | 210 | i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); |
211 | puts ("ready\n"); | 211 | puts ("ready\n"); |
212 | return (0); | 212 | return (0); |
213 | } | 213 | } |
214 | #endif | 214 | #endif |
215 | 215 | ||
216 | /***********************************************************************/ | 216 | /***********************************************************************/ |
217 | 217 | ||
218 | /************************************************************************ | 218 | /************************************************************************ |
219 | * Initialization sequence * | 219 | * Initialization sequence * |
220 | ************************************************************************ | 220 | ************************************************************************ |
221 | */ | 221 | */ |
222 | 222 | ||
223 | init_fnc_t *init_sequence[] = { | 223 | init_fnc_t *init_sequence[] = { |
224 | env_init, | 224 | env_init, |
225 | init_baudrate, | 225 | init_baudrate, |
226 | serial_init, | 226 | serial_init, |
227 | console_init_f, | 227 | console_init_f, |
228 | display_options, | 228 | display_options, |
229 | checkcpu, | 229 | checkcpu, |
230 | checkboard, | 230 | checkboard, |
231 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) | 231 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) |
232 | init_func_i2c, | 232 | init_func_i2c, |
233 | #endif | 233 | #endif |
234 | init_func_ram, | 234 | init_func_ram, |
235 | #if defined(CFG_DRAM_TEST) | 235 | #if defined(CFG_DRAM_TEST) |
236 | testdram, | 236 | testdram, |
237 | #endif /* CFG_DRAM_TEST */ | 237 | #endif /* CFG_DRAM_TEST */ |
238 | INIT_FUNC_WATCHDOG_INIT | 238 | INIT_FUNC_WATCHDOG_INIT |
239 | NULL, /* Terminate this list */ | 239 | NULL, /* Terminate this list */ |
240 | }; | 240 | }; |
241 | 241 | ||
242 | 242 | ||
243 | /************************************************************************ | 243 | /************************************************************************ |
244 | * | 244 | * |
245 | * This is the first part of the initialization sequence that is | 245 | * This is the first part of the initialization sequence that is |
246 | * implemented in C, but still running from ROM. | 246 | * implemented in C, but still running from ROM. |
247 | * | 247 | * |
248 | * The main purpose is to provide a (serial) console interface as | 248 | * The main purpose is to provide a (serial) console interface as |
249 | * soon as possible (so we can see any error messages), and to | 249 | * soon as possible (so we can see any error messages), and to |
250 | * initialize the RAM so that we can relocate the monitor code to | 250 | * initialize the RAM so that we can relocate the monitor code to |
251 | * RAM. | 251 | * RAM. |
252 | * | 252 | * |
253 | * Be aware of the restrictions: global data is read-only, BSS is not | 253 | * Be aware of the restrictions: global data is read-only, BSS is not |
254 | * initialized, and stack space is limited to a few kB. | 254 | * initialized, and stack space is limited to a few kB. |
255 | * | 255 | * |
256 | ************************************************************************ | 256 | ************************************************************************ |
257 | */ | 257 | */ |
258 | 258 | ||
259 | void | 259 | void |
260 | board_init_f (ulong bootflag) | 260 | board_init_f (ulong bootflag) |
261 | { | 261 | { |
262 | bd_t *bd; | 262 | bd_t *bd; |
263 | ulong len, addr, addr_sp; | 263 | ulong len, addr, addr_sp; |
264 | ulong *paddr; | 264 | ulong *paddr; |
265 | gd_t *id; | 265 | gd_t *id; |
266 | init_fnc_t **init_fnc_ptr; | 266 | init_fnc_t **init_fnc_ptr; |
267 | #ifdef CONFIG_PRAM | 267 | #ifdef CONFIG_PRAM |
268 | int i; | 268 | int i; |
269 | ulong reg; | 269 | ulong reg; |
270 | uchar tmp[64]; /* long enough for environment variables */ | 270 | uchar tmp[64]; /* long enough for environment variables */ |
271 | #endif | 271 | #endif |
272 | 272 | ||
273 | /* Pointer is writable since we allocated a register for it */ | 273 | /* Pointer is writable since we allocated a register for it */ |
274 | gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); | 274 | gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); |
275 | /* compiler optimization barrier needed for GCC >= 3.4 */ | 275 | /* compiler optimization barrier needed for GCC >= 3.4 */ |
276 | __asm__ __volatile__("": : :"memory"); | 276 | __asm__ __volatile__("": : :"memory"); |
277 | 277 | ||
278 | /* Clear initial global data */ | 278 | /* Clear initial global data */ |
279 | memset ((void *) gd, 0, sizeof (gd_t)); | 279 | memset ((void *) gd, 0, sizeof (gd_t)); |
280 | 280 | ||
281 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { | 281 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { |
282 | if ((*init_fnc_ptr)() != 0) { | 282 | if ((*init_fnc_ptr)() != 0) { |
283 | hang (); | 283 | hang (); |
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | /* | 287 | /* |
288 | * Now that we have DRAM mapped and working, we can | 288 | * Now that we have DRAM mapped and working, we can |
289 | * relocate the code and continue running from DRAM. | 289 | * relocate the code and continue running from DRAM. |
290 | * | 290 | * |
291 | * Reserve memory at end of RAM for (top down in that order): | 291 | * Reserve memory at end of RAM for (top down in that order): |
292 | * - protected RAM | 292 | * - protected RAM |
293 | * - LCD framebuffer | 293 | * - LCD framebuffer |
294 | * - monitor code | 294 | * - monitor code |
295 | * - board info struct | 295 | * - board info struct |
296 | */ | 296 | */ |
297 | len = (ulong)&_end - CFG_MONITOR_BASE; | 297 | len = (ulong)&_end - CFG_MONITOR_BASE; |
298 | 298 | ||
299 | addr = CFG_SDRAM_BASE + gd->ram_size; | 299 | addr = CFG_SDRAM_BASE + gd->ram_size; |
300 | 300 | ||
301 | #ifdef CONFIG_LOGBUFFER | 301 | #ifdef CONFIG_LOGBUFFER |
302 | /* reserve kernel log buffer */ | 302 | /* reserve kernel log buffer */ |
303 | addr -= (LOGBUFF_RESERVE); | 303 | addr -= (LOGBUFF_RESERVE); |
304 | debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr); | 304 | debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr); |
305 | #endif | 305 | #endif |
306 | 306 | ||
307 | #ifdef CONFIG_PRAM | 307 | #ifdef CONFIG_PRAM |
308 | /* | 308 | /* |
309 | * reserve protected RAM | 309 | * reserve protected RAM |
310 | */ | 310 | */ |
311 | i = getenv_r ("pram", tmp, sizeof (tmp)); | 311 | i = getenv_r ("pram", tmp, sizeof (tmp)); |
312 | reg = (i > 0) ? simple_strtoul (tmp, NULL, 10) : CONFIG_PRAM; | 312 | reg = (i > 0) ? simple_strtoul (tmp, NULL, 10) : CONFIG_PRAM; |
313 | addr -= (reg << 10); /* size is in kB */ | 313 | addr -= (reg << 10); /* size is in kB */ |
314 | debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr); | 314 | debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr); |
315 | #endif /* CONFIG_PRAM */ | 315 | #endif /* CONFIG_PRAM */ |
316 | 316 | ||
317 | /* | 317 | /* |
318 | * reserve memory for U-Boot code, data & bss | 318 | * reserve memory for U-Boot code, data & bss |
319 | * round down to next 4 kB limit | 319 | * round down to next 4 kB limit |
320 | */ | 320 | */ |
321 | addr -= len; | 321 | addr -= len; |
322 | addr &= ~(4096 - 1); | 322 | addr &= ~(4096 - 1); |
323 | 323 | ||
324 | debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr); | 324 | debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr); |
325 | 325 | ||
326 | /* | 326 | /* |
327 | * reserve memory for malloc() arena | 327 | * reserve memory for malloc() arena |
328 | */ | 328 | */ |
329 | addr_sp = addr - TOTAL_MALLOC_LEN; | 329 | addr_sp = addr - TOTAL_MALLOC_LEN; |
330 | debug ("Reserving %dk for malloc() at: %08lx\n", | 330 | debug ("Reserving %dk for malloc() at: %08lx\n", |
331 | TOTAL_MALLOC_LEN >> 10, addr_sp); | 331 | TOTAL_MALLOC_LEN >> 10, addr_sp); |
332 | 332 | ||
333 | /* | 333 | /* |
334 | * (permanently) allocate a Board Info struct | 334 | * (permanently) allocate a Board Info struct |
335 | * and a permanent copy of the "global" data | 335 | * and a permanent copy of the "global" data |
336 | */ | 336 | */ |
337 | addr_sp -= sizeof (bd_t); | 337 | addr_sp -= sizeof (bd_t); |
338 | bd = (bd_t *) addr_sp; | 338 | bd = (bd_t *) addr_sp; |
339 | gd->bd = bd; | 339 | gd->bd = bd; |
340 | debug ("Reserving %d Bytes for Board Info at: %08lx\n", | 340 | debug ("Reserving %d Bytes for Board Info at: %08lx\n", |
341 | sizeof (bd_t), addr_sp); | 341 | sizeof (bd_t), addr_sp); |
342 | addr_sp -= sizeof (gd_t); | 342 | addr_sp -= sizeof (gd_t); |
343 | id = (gd_t *) addr_sp; | 343 | id = (gd_t *) addr_sp; |
344 | debug ("Reserving %d Bytes for Global Data at: %08lx\n", | 344 | debug ("Reserving %d Bytes for Global Data at: %08lx\n", |
345 | sizeof (gd_t), addr_sp); | 345 | sizeof (gd_t), addr_sp); |
346 | 346 | ||
347 | /* Reserve memory for boot params. */ | 347 | /* Reserve memory for boot params. */ |
348 | addr_sp -= CFG_BOOTPARAMS_LEN; | 348 | addr_sp -= CFG_BOOTPARAMS_LEN; |
349 | bd->bi_boot_params = addr_sp; | 349 | bd->bi_boot_params = addr_sp; |
350 | debug ("Reserving %dk for boot parameters at: %08lx\n", | 350 | debug ("Reserving %dk for boot parameters at: %08lx\n", |
351 | CFG_BOOTPARAMS_LEN >> 10, addr_sp); | 351 | CFG_BOOTPARAMS_LEN >> 10, addr_sp); |
352 | 352 | ||
353 | /* | 353 | /* |
354 | * Finally, we set up a new (bigger) stack. | 354 | * Finally, we set up a new (bigger) stack. |
355 | * | 355 | * |
356 | * Leave some safety gap for SP, force alignment on 16 byte boundary | 356 | * Leave some safety gap for SP, force alignment on 16 byte boundary |
357 | * Clear initial stack frame | 357 | * Clear initial stack frame |
358 | */ | 358 | */ |
359 | addr_sp -= 16; | 359 | addr_sp -= 16; |
360 | addr_sp &= ~0xF; | 360 | addr_sp &= ~0xF; |
361 | 361 | ||
362 | paddr = (ulong *)addr_sp; | 362 | paddr = (ulong *)addr_sp; |
363 | *paddr-- = 0; | 363 | *paddr-- = 0; |
364 | *paddr-- = 0; | 364 | *paddr-- = 0; |
365 | addr_sp = (ulong)paddr; | 365 | addr_sp = (ulong)paddr; |
366 | 366 | ||
367 | debug ("Stack Pointer at: %08lx\n", addr_sp); | 367 | debug ("Stack Pointer at: %08lx\n", addr_sp); |
368 | 368 | ||
369 | /* | 369 | /* |
370 | * Save local variables to board info struct | 370 | * Save local variables to board info struct |
371 | */ | 371 | */ |
372 | bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */ | 372 | bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */ |
373 | bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */ | 373 | bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */ |
374 | bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */ | 374 | bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */ |
375 | 375 | ||
376 | bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ | 376 | bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ |
377 | 377 | ||
378 | WATCHDOG_RESET (); | 378 | WATCHDOG_RESET (); |
379 | bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */ | 379 | bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */ |
380 | bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */ | 380 | bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */ |
381 | bd->bi_baudrate = gd->baudrate; /* Console Baudrate */ | 381 | bd->bi_baudrate = gd->baudrate; /* Console Baudrate */ |
382 | 382 | ||
383 | #ifdef CFG_EXTBDINFO | 383 | #ifdef CFG_EXTBDINFO |
384 | strncpy (bd->bi_s_version, "1.2", sizeof (bd->bi_s_version)); | 384 | strncpy (bd->bi_s_version, "1.2", sizeof (bd->bi_s_version)); |
385 | strncpy (bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version)); | 385 | strncpy (bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version)); |
386 | #endif | 386 | #endif |
387 | 387 | ||
388 | WATCHDOG_RESET (); | 388 | WATCHDOG_RESET (); |
389 | 389 | ||
390 | #ifdef CONFIG_POST | 390 | #ifdef CONFIG_POST |
391 | post_bootmode_init(); | 391 | post_bootmode_init(); |
392 | post_run (NULL, POST_ROM | post_bootmode_get(0)); | 392 | post_run (NULL, POST_ROM | post_bootmode_get(0)); |
393 | #endif | 393 | #endif |
394 | 394 | ||
395 | WATCHDOG_RESET(); | 395 | WATCHDOG_RESET(); |
396 | 396 | ||
397 | memcpy (id, (void *)gd, sizeof (gd_t)); | 397 | memcpy (id, (void *)gd, sizeof (gd_t)); |
398 | 398 | ||
399 | debug ("Start relocate of code from %08x to %08lx\n", CFG_MONITOR_BASE, addr); | 399 | debug ("Start relocate of code from %08x to %08lx\n", CFG_MONITOR_BASE, addr); |
400 | relocate_code (addr_sp, id, addr); | 400 | relocate_code (addr_sp, id, addr); |
401 | 401 | ||
402 | /* NOTREACHED - jump_to_ram() does not return */ | 402 | /* NOTREACHED - jump_to_ram() does not return */ |
403 | } | 403 | } |
404 | 404 | ||
405 | /************************************************************************ | 405 | /************************************************************************ |
406 | * | 406 | * |
407 | * This is the next part if the initialization sequence: we are now | 407 | * This is the next part if the initialization sequence: we are now |
408 | * running from RAM and have a "normal" C environment, i. e. global | 408 | * running from RAM and have a "normal" C environment, i. e. global |
409 | * data can be written, BSS has been cleared, the stack size in not | 409 | * data can be written, BSS has been cleared, the stack size in not |
410 | * that critical any more, etc. | 410 | * that critical any more, etc. |
411 | * | 411 | * |
412 | ************************************************************************ | 412 | ************************************************************************ |
413 | */ | 413 | */ |
414 | void board_init_r (gd_t *id, ulong dest_addr) | 414 | void board_init_r (gd_t *id, ulong dest_addr) |
415 | { | 415 | { |
416 | cmd_tbl_t *cmdtp; | 416 | cmd_tbl_t *cmdtp; |
417 | char *s, *e; | 417 | char *s, *e; |
418 | bd_t *bd; | 418 | bd_t *bd; |
419 | int i; | 419 | int i; |
420 | extern void malloc_bin_reloc (void); | 420 | extern void malloc_bin_reloc (void); |
421 | 421 | ||
422 | #ifndef CFG_ENV_IS_NOWHERE | 422 | #ifndef CFG_ENV_IS_NOWHERE |
423 | extern char * env_name_spec; | 423 | extern char * env_name_spec; |
424 | #endif | 424 | #endif |
425 | #ifndef CFG_NO_FLASH | 425 | #ifndef CFG_NO_FLASH |
426 | ulong flash_size; | 426 | ulong flash_size; |
427 | #endif | 427 | #endif |
428 | gd = id; /* initialize RAM version of global data */ | 428 | gd = id; /* initialize RAM version of global data */ |
429 | bd = gd->bd; | 429 | bd = gd->bd; |
430 | 430 | ||
431 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ | 431 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ |
432 | 432 | ||
433 | debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr); | 433 | debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr); |
434 | 434 | ||
435 | WATCHDOG_RESET (); | 435 | WATCHDOG_RESET (); |
436 | 436 | ||
437 | gd->reloc_off = dest_addr - CFG_MONITOR_BASE; | 437 | gd->reloc_off = dest_addr - CFG_MONITOR_BASE; |
438 | 438 | ||
439 | monitor_flash_len = (ulong)&__init_end - dest_addr; | 439 | monitor_flash_len = (ulong)&__init_end - dest_addr; |
440 | 440 | ||
441 | /* | 441 | /* |
442 | * We have to relocate the command table manually | 442 | * We have to relocate the command table manually |
443 | */ | 443 | */ |
444 | for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { | 444 | for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { |
445 | ulong addr; | 445 | ulong addr; |
446 | addr = (ulong) (cmdtp->cmd) + gd->reloc_off; | 446 | addr = (ulong) (cmdtp->cmd) + gd->reloc_off; |
447 | #if 0 | 447 | #if 0 |
448 | printf ("Command \"%s\": 0x%08lx => 0x%08lx\n", | 448 | printf ("Command \"%s\": 0x%08lx => 0x%08lx\n", |
449 | cmdtp->name, (ulong) (cmdtp->cmd), addr); | 449 | cmdtp->name, (ulong) (cmdtp->cmd), addr); |
450 | #endif | 450 | #endif |
451 | cmdtp->cmd = | 451 | cmdtp->cmd = |
452 | (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; | 452 | (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; |
453 | 453 | ||
454 | addr = (ulong)(cmdtp->name) + gd->reloc_off; | 454 | addr = (ulong)(cmdtp->name) + gd->reloc_off; |
455 | cmdtp->name = (char *)addr; | 455 | cmdtp->name = (char *)addr; |
456 | 456 | ||
457 | if (cmdtp->usage) { | 457 | if (cmdtp->usage) { |
458 | addr = (ulong)(cmdtp->usage) + gd->reloc_off; | 458 | addr = (ulong)(cmdtp->usage) + gd->reloc_off; |
459 | cmdtp->usage = (char *)addr; | 459 | cmdtp->usage = (char *)addr; |
460 | } | 460 | } |
461 | #ifdef CFG_LONGHELP | 461 | #ifdef CFG_LONGHELP |
462 | if (cmdtp->help) { | 462 | if (cmdtp->help) { |
463 | addr = (ulong)(cmdtp->help) + gd->reloc_off; | 463 | addr = (ulong)(cmdtp->help) + gd->reloc_off; |
464 | cmdtp->help = (char *)addr; | 464 | cmdtp->help = (char *)addr; |
465 | } | 465 | } |
466 | #endif | 466 | #endif |
467 | } | 467 | } |
468 | /* there are some other pointer constants we must deal with */ | 468 | /* there are some other pointer constants we must deal with */ |
469 | #ifndef CFG_ENV_IS_NOWHERE | 469 | #ifndef CFG_ENV_IS_NOWHERE |
470 | env_name_spec += gd->reloc_off; | 470 | env_name_spec += gd->reloc_off; |
471 | #endif | 471 | #endif |
472 | 472 | ||
473 | WATCHDOG_RESET (); | 473 | WATCHDOG_RESET (); |
474 | 474 | ||
475 | #ifdef CONFIG_LOGBUFFER | 475 | #ifdef CONFIG_LOGBUFFER |
476 | logbuff_init_ptrs (); | 476 | logbuff_init_ptrs (); |
477 | #endif | 477 | #endif |
478 | #ifdef CONFIG_POST | 478 | #ifdef CONFIG_POST |
479 | post_output_backlog (); | 479 | post_output_backlog (); |
480 | post_reloc (); | 480 | post_reloc (); |
481 | #endif | 481 | #endif |
482 | WATCHDOG_RESET(); | 482 | WATCHDOG_RESET(); |
483 | 483 | ||
484 | #if 0 | 484 | #if 0 |
485 | /* instruction cache enabled in cpu_init_f() for faster relocation */ | 485 | /* instruction cache enabled in cpu_init_f() for faster relocation */ |
486 | icache_enable (); /* it's time to enable the instruction cache */ | 486 | icache_enable (); /* it's time to enable the instruction cache */ |
487 | #endif | 487 | #endif |
488 | 488 | ||
489 | /* | 489 | /* |
490 | * Setup trap handlers | 490 | * Setup trap handlers |
491 | */ | 491 | */ |
492 | trap_init (0); | 492 | trap_init (0); |
493 | 493 | ||
494 | #if !defined(CFG_NO_FLASH) | 494 | #if !defined(CFG_NO_FLASH) |
495 | puts ("FLASH: "); | 495 | puts ("FLASH: "); |
496 | 496 | ||
497 | if ((flash_size = flash_init ()) > 0) { | 497 | if ((flash_size = flash_init ()) > 0) { |
498 | # ifdef CFG_FLASH_CHECKSUM | 498 | # ifdef CFG_FLASH_CHECKSUM |
499 | print_size (flash_size, ""); | 499 | print_size (flash_size, ""); |
500 | /* | 500 | /* |
501 | * Compute and print flash CRC if flashchecksum is set to 'y' | 501 | * Compute and print flash CRC if flashchecksum is set to 'y' |
502 | * | 502 | * |
503 | * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX | 503 | * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX |
504 | */ | 504 | */ |
505 | s = getenv ("flashchecksum"); | 505 | s = getenv ("flashchecksum"); |
506 | if (s && (*s == 'y')) { | 506 | if (s && (*s == 'y')) { |
507 | printf (" CRC: %08lX", | 507 | printf (" CRC: %08lX", |
508 | crc32 (0, | 508 | crc32 (0, |
509 | (const unsigned char *) CFG_FLASH_BASE, | 509 | (const unsigned char *) CFG_FLASH_BASE, |
510 | flash_size) | 510 | flash_size) |
511 | ); | 511 | ); |
512 | } | 512 | } |
513 | putc ('\n'); | 513 | putc ('\n'); |
514 | # else /* !CFG_FLASH_CHECKSUM */ | 514 | # else /* !CFG_FLASH_CHECKSUM */ |
515 | print_size (flash_size, "\n"); | 515 | print_size (flash_size, "\n"); |
516 | # endif /* CFG_FLASH_CHECKSUM */ | 516 | # endif /* CFG_FLASH_CHECKSUM */ |
517 | } else { | 517 | } else { |
518 | puts (failed); | 518 | puts (failed); |
519 | hang (); | 519 | hang (); |
520 | } | 520 | } |
521 | 521 | ||
522 | bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */ | 522 | bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */ |
523 | bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ | 523 | bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ |
524 | bd->bi_flashoffset = 0; | 524 | bd->bi_flashoffset = 0; |
525 | #else /* CFG_NO_FLASH */ | 525 | #else /* CFG_NO_FLASH */ |
526 | bd->bi_flashsize = 0; | 526 | bd->bi_flashsize = 0; |
527 | bd->bi_flashstart = 0; | 527 | bd->bi_flashstart = 0; |
528 | bd->bi_flashoffset = 0; | 528 | bd->bi_flashoffset = 0; |
529 | #endif /* !CFG_NO_FLASH */ | 529 | #endif /* !CFG_NO_FLASH */ |
530 | 530 | ||
531 | WATCHDOG_RESET (); | 531 | WATCHDOG_RESET (); |
532 | 532 | ||
533 | /* initialize higher level parts of CPU like time base and timers */ | 533 | /* initialize higher level parts of CPU like time base and timers */ |
534 | cpu_init_r (); | 534 | cpu_init_r (); |
535 | 535 | ||
536 | WATCHDOG_RESET (); | 536 | WATCHDOG_RESET (); |
537 | 537 | ||
538 | /* initialize malloc() area */ | 538 | /* initialize malloc() area */ |
539 | mem_malloc_init (); | 539 | mem_malloc_init (); |
540 | malloc_bin_reloc (); | 540 | malloc_bin_reloc (); |
541 | 541 | ||
542 | #ifdef CONFIG_SPI | 542 | #ifdef CONFIG_SPI |
543 | # if !defined(CFG_ENV_IS_IN_EEPROM) | 543 | # if !defined(CFG_ENV_IS_IN_EEPROM) |
544 | spi_init_f (); | 544 | spi_init_f (); |
545 | # endif | 545 | # endif |
546 | spi_init_r (); | 546 | spi_init_r (); |
547 | #endif | 547 | #endif |
548 | 548 | ||
549 | /* relocate environment function pointers etc. */ | 549 | /* relocate environment function pointers etc. */ |
550 | env_relocate (); | 550 | env_relocate (); |
551 | 551 | ||
552 | /* | 552 | /* |
553 | * Fill in missing fields of bd_info. | 553 | * Fill in missing fields of bd_info. |
554 | * We do this here, where we have "normal" access to the | 554 | * We do this here, where we have "normal" access to the |
555 | * environment; we used to do this still running from ROM, | 555 | * environment; we used to do this still running from ROM, |
556 | * where had to use getenv_r(), which can be pretty slow when | 556 | * where had to use getenv_r(), which can be pretty slow when |
557 | * the environment is in EEPROM. | 557 | * the environment is in EEPROM. |
558 | */ | 558 | */ |
559 | s = getenv ("ethaddr"); | 559 | s = getenv ("ethaddr"); |
560 | for (i = 0; i < 6; ++i) { | 560 | for (i = 0; i < 6; ++i) { |
561 | bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0; | 561 | bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0; |
562 | if (s) | 562 | if (s) |
563 | s = (*e) ? e + 1 : e; | 563 | s = (*e) ? e + 1 : e; |
564 | } | 564 | } |
565 | 565 | ||
566 | /* IP Address */ | 566 | /* IP Address */ |
567 | bd->bi_ip_addr = getenv_IPaddr ("ipaddr"); | 567 | bd->bi_ip_addr = getenv_IPaddr ("ipaddr"); |
568 | 568 | ||
569 | WATCHDOG_RESET (); | 569 | WATCHDOG_RESET (); |
570 | 570 | ||
571 | 571 | ||
572 | /** leave this here (after malloc(), environment and PCI are working) **/ | 572 | /** leave this here (after malloc(), environment and PCI are working) **/ |
573 | /* Initialize devices */ | 573 | /* Initialize devices */ |
574 | devices_init (); | 574 | devices_init (); |
575 | 575 | ||
576 | /* Initialize the jump table for applications */ | 576 | /* Initialize the jump table for applications */ |
577 | jumptable_init (); | 577 | jumptable_init (); |
578 | 578 | ||
579 | /* Initialize the console (after the relocation and devices init) */ | 579 | /* Initialize the console (after the relocation and devices init) */ |
580 | console_init_r (); | 580 | console_init_r (); |
581 | 581 | ||
582 | #if defined(CONFIG_MISC_INIT_R) | 582 | #if defined(CONFIG_MISC_INIT_R) |
583 | /* miscellaneous platform dependent initialisations */ | 583 | /* miscellaneous platform dependent initialisations */ |
584 | misc_init_r (); | 584 | misc_init_r (); |
585 | #endif | 585 | #endif |
586 | 586 | ||
587 | #if (CONFIG_COMMANDS & CFG_CMD_KGDB) || defined(CONFIG_CMD_KGDB) | 587 | #if defined(CONFIG_CMD_KGDB) |
588 | WATCHDOG_RESET (); | 588 | WATCHDOG_RESET (); |
589 | puts ("KGDB: "); | 589 | puts ("KGDB: "); |
590 | kgdb_init (); | 590 | kgdb_init (); |
591 | #endif | 591 | #endif |
592 | 592 | ||
593 | debug ("U-Boot relocated to %08lx\n", dest_addr); | 593 | debug ("U-Boot relocated to %08lx\n", dest_addr); |
594 | 594 | ||
595 | /* | 595 | /* |
596 | * Enable Interrupts | 596 | * Enable Interrupts |
597 | */ | 597 | */ |
598 | interrupt_init (); | 598 | interrupt_init (); |
599 | 599 | ||
600 | /* Must happen after interrupts are initialized since | 600 | /* Must happen after interrupts are initialized since |
601 | * an irq handler gets installed | 601 | * an irq handler gets installed |
602 | */ | 602 | */ |
603 | timer_init(); | 603 | timer_init(); |
604 | 604 | ||
605 | #ifdef CONFIG_SERIAL_SOFTWARE_FIFO | 605 | #ifdef CONFIG_SERIAL_SOFTWARE_FIFO |
606 | serial_buffered_init(); | 606 | serial_buffered_init(); |
607 | #endif | 607 | #endif |
608 | 608 | ||
609 | #ifdef CONFIG_STATUS_LED | 609 | #ifdef CONFIG_STATUS_LED |
610 | status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING); | 610 | status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING); |
611 | #endif | 611 | #endif |
612 | 612 | ||
613 | udelay (20); | 613 | udelay (20); |
614 | 614 | ||
615 | set_timer (0); | 615 | set_timer (0); |
616 | 616 | ||
617 | /* Insert function pointers now that we have relocated the code */ | 617 | /* Insert function pointers now that we have relocated the code */ |
618 | 618 | ||
619 | /* Initialize from environment */ | 619 | /* Initialize from environment */ |
620 | if ((s = getenv ("loadaddr")) != NULL) { | 620 | if ((s = getenv ("loadaddr")) != NULL) { |
621 | load_addr = simple_strtoul (s, NULL, 16); | 621 | load_addr = simple_strtoul (s, NULL, 16); |
622 | } | 622 | } |
623 | #if (CONFIG_COMMANDS & CFG_CMD_NET) || defined(CONFIG_CMD_NET) | 623 | #if defined(CONFIG_CMD_NET) |
624 | if ((s = getenv ("bootfile")) != NULL) { | 624 | if ((s = getenv ("bootfile")) != NULL) { |
625 | copy_filename (BootFile, s, sizeof (BootFile)); | 625 | copy_filename (BootFile, s, sizeof (BootFile)); |
626 | } | 626 | } |
627 | #endif /* CFG_CMD_NET */ | 627 | #endif /* CFG_CMD_NET */ |
628 | 628 | ||
629 | WATCHDOG_RESET (); | 629 | WATCHDOG_RESET (); |
630 | 630 | ||
631 | #if (CONFIG_COMMANDS & CFG_CMD_DOC) || defined(CONFIG_CMD_DOC) | 631 | #if defined(CONFIG_CMD_DOC) |
632 | WATCHDOG_RESET (); | 632 | WATCHDOG_RESET (); |
633 | puts ("DOC: "); | 633 | puts ("DOC: "); |
634 | doc_init (); | 634 | doc_init (); |
635 | #endif | 635 | #endif |
636 | 636 | ||
637 | #if (CONFIG_COMMANDS & CFG_CMD_NAND) || defined(CONFIG_CMD_NAND) | 637 | #if defined(CONFIG_CMD_NAND) |
638 | WATCHDOG_RESET (); | 638 | WATCHDOG_RESET (); |
639 | puts ("NAND: "); | 639 | puts ("NAND: "); |
640 | nand_init(); /* go init the NAND */ | 640 | nand_init(); /* go init the NAND */ |
641 | #endif | 641 | #endif |
642 | 642 | ||
643 | #if ((CONFIG_COMMANDS & CFG_CMD_NET) || defined(CONFIG_CMD_NET)) && defined(FEC_ENET) | 643 | #if defined(CONFIG_CMD_NET) && defined(FEC_ENET) |
644 | WATCHDOG_RESET(); | 644 | WATCHDOG_RESET(); |
645 | eth_init(bd); | 645 | eth_init(bd); |
646 | #endif | 646 | #endif |
647 | 647 | ||
648 | #ifdef CONFIG_POST | 648 | #ifdef CONFIG_POST |
649 | post_run (NULL, POST_RAM | post_bootmode_get(0)); | 649 | post_run (NULL, POST_RAM | post_bootmode_get(0)); |
650 | #endif | 650 | #endif |
651 | 651 | ||
652 | #ifdef CONFIG_LAST_STAGE_INIT | 652 | #ifdef CONFIG_LAST_STAGE_INIT |
653 | WATCHDOG_RESET (); | 653 | WATCHDOG_RESET (); |
654 | /* | 654 | /* |
655 | * Some parts can be only initialized if all others (like | 655 | * Some parts can be only initialized if all others (like |
656 | * Interrupts) are up and running (i.e. the PC-style ISA | 656 | * Interrupts) are up and running (i.e. the PC-style ISA |
657 | * keyboard). | 657 | * keyboard). |
658 | */ | 658 | */ |
659 | last_stage_init (); | 659 | last_stage_init (); |
660 | #endif | 660 | #endif |
661 | 661 | ||
662 | #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG) || defined(CONFIG_CMD_BEDBUG) | 662 | #if defined(CONFIG_CMD_BEDBUG) |
663 | WATCHDOG_RESET (); | 663 | WATCHDOG_RESET (); |
664 | bedbug_init (); | 664 | bedbug_init (); |
665 | #endif | 665 | #endif |
666 | 666 | ||
667 | #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) | 667 | #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) |
668 | /* | 668 | /* |
669 | * Export available size of memory for Linux, | 669 | * Export available size of memory for Linux, |
670 | * taking into account the protected RAM at top of memory | 670 | * taking into account the protected RAM at top of memory |
671 | */ | 671 | */ |
672 | { | 672 | { |
673 | ulong pram; | 673 | ulong pram; |
674 | uchar memsz[32]; | 674 | uchar memsz[32]; |
675 | #ifdef CONFIG_PRAM | 675 | #ifdef CONFIG_PRAM |
676 | char *s; | 676 | char *s; |
677 | 677 | ||
678 | if ((s = getenv ("pram")) != NULL) { | 678 | if ((s = getenv ("pram")) != NULL) { |
679 | pram = simple_strtoul (s, NULL, 10); | 679 | pram = simple_strtoul (s, NULL, 10); |
680 | } else { | 680 | } else { |
681 | pram = CONFIG_PRAM; | 681 | pram = CONFIG_PRAM; |
682 | } | 682 | } |
683 | #else | 683 | #else |
684 | pram=0; | 684 | pram=0; |
685 | #endif | 685 | #endif |
686 | #ifdef CONFIG_LOGBUFFER | 686 | #ifdef CONFIG_LOGBUFFER |
687 | /* Also take the logbuffer into account (pram is in kB) */ | 687 | /* Also take the logbuffer into account (pram is in kB) */ |
688 | pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024; | 688 | pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024; |
689 | #endif | 689 | #endif |
690 | sprintf (memsz, "%ldk", (bd->bi_memsize / 1024) - pram); | 690 | sprintf (memsz, "%ldk", (bd->bi_memsize / 1024) - pram); |
691 | setenv ("mem", memsz); | 691 | setenv ("mem", memsz); |
692 | } | 692 | } |
693 | #endif | 693 | #endif |
694 | 694 | ||
695 | #ifdef CONFIG_MODEM_SUPPORT | 695 | #ifdef CONFIG_MODEM_SUPPORT |
696 | { | 696 | { |
697 | extern int do_mdm_init; | 697 | extern int do_mdm_init; |
698 | do_mdm_init = gd->do_mdm_init; | 698 | do_mdm_init = gd->do_mdm_init; |
699 | } | 699 | } |
700 | #endif | 700 | #endif |
701 | 701 | ||
702 | #ifdef CONFIG_WATCHDOG | 702 | #ifdef CONFIG_WATCHDOG |
703 | /* disable watchdog if environment is set */ | 703 | /* disable watchdog if environment is set */ |
704 | if ((s = getenv ("watchdog")) != NULL) { | 704 | if ((s = getenv ("watchdog")) != NULL) { |
705 | if (strncmp (s, "off", 3) == 0) { | 705 | if (strncmp (s, "off", 3) == 0) { |
706 | WATCHDOG_DISABLE (); | 706 | WATCHDOG_DISABLE (); |
707 | } | 707 | } |
708 | } | 708 | } |
709 | #endif /* CONFIG_WATCHDOG*/ | 709 | #endif /* CONFIG_WATCHDOG*/ |
710 | 710 | ||
711 | 711 | ||
712 | /* Initialization complete - start the monitor */ | 712 | /* Initialization complete - start the monitor */ |
713 | 713 | ||
714 | /* main_loop() can return to retry autoboot, if so just run it again. */ | 714 | /* main_loop() can return to retry autoboot, if so just run it again. */ |
715 | for (;;) { | 715 | for (;;) { |
716 | WATCHDOG_RESET (); | 716 | WATCHDOG_RESET (); |
717 | main_loop (); | 717 | main_loop (); |
718 | } | 718 | } |
719 | 719 | ||
720 | /* NOTREACHED - no way out of command loop except booting */ | 720 | /* NOTREACHED - no way out of command loop except booting */ |
721 | } | 721 | } |
722 | 722 | ||
723 | 723 | ||
724 | void hang(void) | 724 | void hang(void) |
725 | { | 725 | { |
726 | puts ("### ERROR ### Please RESET the board ###\n"); | 726 | puts ("### ERROR ### Please RESET the board ###\n"); |
727 | for (;;); | 727 | for (;;); |
728 | } | 728 | } |
729 | 729 |
lib_microblaze/board.c
1 | /* | 1 | /* |
2 | * (C) Copyright 2007 Michal Simek | 2 | * (C) Copyright 2007 Michal Simek |
3 | * (C) Copyright 2004 Atmark Techno, Inc. | 3 | * (C) Copyright 2004 Atmark Techno, Inc. |
4 | * | 4 | * |
5 | * Michal SIMEK <monstr@monstr.eu> | 5 | * Michal SIMEK <monstr@monstr.eu> |
6 | * Yasushi SHOJI <yashi@atmark-techno.com> | 6 | * Yasushi SHOJI <yashi@atmark-techno.com> |
7 | * | 7 | * |
8 | * See file CREDITS for list of people who contributed to this | 8 | * See file CREDITS for list of people who contributed to this |
9 | * project. | 9 | * project. |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or | 11 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU General Public License as | 12 | * modify it under the terms of the GNU General Public License as |
13 | * published by the Free Software Foundation; either version 2 of | 13 | * published by the Free Software Foundation; either version 2 of |
14 | * the License, or (at your option) any later version. | 14 | * the License, or (at your option) any later version. |
15 | * | 15 | * |
16 | * This program is distributed in the hope that it will be useful, | 16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU General Public License for more details. | 19 | * GNU General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU General Public License | 21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software | 22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
24 | * MA 02111-1307 USA | 24 | * MA 02111-1307 USA |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <common.h> | 27 | #include <common.h> |
28 | #include <command.h> | 28 | #include <command.h> |
29 | #include <malloc.h> | 29 | #include <malloc.h> |
30 | #include <version.h> | 30 | #include <version.h> |
31 | #include <watchdog.h> | 31 | #include <watchdog.h> |
32 | 32 | ||
33 | DECLARE_GLOBAL_DATA_PTR; | 33 | DECLARE_GLOBAL_DATA_PTR; |
34 | 34 | ||
35 | const char version_string[] = U_BOOT_VERSION " (" __DATE__ " - " __TIME__ ")"; | 35 | const char version_string[] = U_BOOT_VERSION " (" __DATE__ " - " __TIME__ ")"; |
36 | 36 | ||
37 | #ifdef CFG_GPIO_0 | 37 | #ifdef CFG_GPIO_0 |
38 | extern int gpio_init (void); | 38 | extern int gpio_init (void); |
39 | #endif | 39 | #endif |
40 | #ifdef CFG_INTC_0 | 40 | #ifdef CFG_INTC_0 |
41 | extern int interrupts_init (void); | 41 | extern int interrupts_init (void); |
42 | #endif | 42 | #endif |
43 | #if (CONFIG_COMMANDS & CFG_CMD_NET) || defined(CONFIG_CMD_NET) | 43 | #if defined(CONFIG_CMD_NET) |
44 | extern int eth_init (bd_t * bis); | 44 | extern int eth_init (bd_t * bis); |
45 | extern int getenv_IPaddr (char *); | 45 | extern int getenv_IPaddr (char *); |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | /* | 48 | /* |
49 | * Begin and End of memory area for malloc(), and current "brk" | 49 | * Begin and End of memory area for malloc(), and current "brk" |
50 | */ | 50 | */ |
51 | static ulong mem_malloc_start; | 51 | static ulong mem_malloc_start; |
52 | static ulong mem_malloc_end; | 52 | static ulong mem_malloc_end; |
53 | static ulong mem_malloc_brk; | 53 | static ulong mem_malloc_brk; |
54 | 54 | ||
55 | /* | 55 | /* |
56 | * The Malloc area is immediately below the monitor copy in DRAM | 56 | * The Malloc area is immediately below the monitor copy in DRAM |
57 | * aka CFG_MONITOR_BASE - Note there is no need for reloc_off | 57 | * aka CFG_MONITOR_BASE - Note there is no need for reloc_off |
58 | * as our monitory code is run from SDRAM | 58 | * as our monitory code is run from SDRAM |
59 | */ | 59 | */ |
60 | static void mem_malloc_init (void) | 60 | static void mem_malloc_init (void) |
61 | { | 61 | { |
62 | mem_malloc_end = (CFG_MALLOC_BASE + CFG_MALLOC_LEN); | 62 | mem_malloc_end = (CFG_MALLOC_BASE + CFG_MALLOC_LEN); |
63 | mem_malloc_start = CFG_MALLOC_BASE; | 63 | mem_malloc_start = CFG_MALLOC_BASE; |
64 | mem_malloc_brk = mem_malloc_start; | 64 | mem_malloc_brk = mem_malloc_start; |
65 | memset ((void *)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start); | 65 | memset ((void *)mem_malloc_start, 0, mem_malloc_end - mem_malloc_start); |
66 | } | 66 | } |
67 | 67 | ||
68 | void *sbrk (ptrdiff_t increment) | 68 | void *sbrk (ptrdiff_t increment) |
69 | { | 69 | { |
70 | ulong old = mem_malloc_brk; | 70 | ulong old = mem_malloc_brk; |
71 | ulong new = old + increment; | 71 | ulong new = old + increment; |
72 | 72 | ||
73 | if ((new < mem_malloc_start) || (new > mem_malloc_end)) { | 73 | if ((new < mem_malloc_start) || (new > mem_malloc_end)) { |
74 | return (NULL); | 74 | return (NULL); |
75 | } | 75 | } |
76 | mem_malloc_brk = new; | 76 | mem_malloc_brk = new; |
77 | return ((void *)old); | 77 | return ((void *)old); |
78 | } | 78 | } |
79 | 79 | ||
80 | /* | 80 | /* |
81 | * All attempts to come up with a "common" initialization sequence | 81 | * All attempts to come up with a "common" initialization sequence |
82 | * that works for all boards and architectures failed: some of the | 82 | * that works for all boards and architectures failed: some of the |
83 | * requirements are just _too_ different. To get rid of the resulting | 83 | * requirements are just _too_ different. To get rid of the resulting |
84 | * mess of board dependend #ifdef'ed code we now make the whole | 84 | * mess of board dependend #ifdef'ed code we now make the whole |
85 | * initialization sequence configurable to the user. | 85 | * initialization sequence configurable to the user. |
86 | * | 86 | * |
87 | * The requirements for any new initalization function is simple: it | 87 | * The requirements for any new initalization function is simple: it |
88 | * receives a pointer to the "global data" structure as it's only | 88 | * receives a pointer to the "global data" structure as it's only |
89 | * argument, and returns an integer return code, where 0 means | 89 | * argument, and returns an integer return code, where 0 means |
90 | * "continue" and != 0 means "fatal error, hang the system". | 90 | * "continue" and != 0 means "fatal error, hang the system". |
91 | */ | 91 | */ |
92 | typedef int (init_fnc_t) (void); | 92 | typedef int (init_fnc_t) (void); |
93 | 93 | ||
94 | init_fnc_t *init_sequence[] = { | 94 | init_fnc_t *init_sequence[] = { |
95 | env_init, | 95 | env_init, |
96 | serial_init, | 96 | serial_init, |
97 | #ifdef CFG_GPIO_0 | 97 | #ifdef CFG_GPIO_0 |
98 | gpio_init, | 98 | gpio_init, |
99 | #endif | 99 | #endif |
100 | #ifdef CFG_INTC_0 | 100 | #ifdef CFG_INTC_0 |
101 | interrupts_init, | 101 | interrupts_init, |
102 | #endif | 102 | #endif |
103 | NULL, | 103 | NULL, |
104 | }; | 104 | }; |
105 | 105 | ||
106 | void board_init (void) | 106 | void board_init (void) |
107 | { | 107 | { |
108 | bd_t *bd; | 108 | bd_t *bd; |
109 | init_fnc_t **init_fnc_ptr; | 109 | init_fnc_t **init_fnc_ptr; |
110 | gd = (gd_t *) CFG_GBL_DATA_OFFSET; | 110 | gd = (gd_t *) CFG_GBL_DATA_OFFSET; |
111 | #if (CONFIG_COMMANDS & CFG_CMD_FLASH) || defined(CONFIG_CMD_FLASH) | 111 | #if defined(CONFIG_CMD_FLASH) |
112 | ulong flash_size = 0; | 112 | ulong flash_size = 0; |
113 | #endif | 113 | #endif |
114 | asm ("nop"); /* FIXME gd is not initialize - wait */ | 114 | asm ("nop"); /* FIXME gd is not initialize - wait */ |
115 | memset ((void *)gd, 0, CFG_GBL_DATA_SIZE); | 115 | memset ((void *)gd, 0, CFG_GBL_DATA_SIZE); |
116 | gd->bd = (bd_t *) (gd + 1); /* At end of global data */ | 116 | gd->bd = (bd_t *) (gd + 1); /* At end of global data */ |
117 | gd->baudrate = CONFIG_BAUDRATE; | 117 | gd->baudrate = CONFIG_BAUDRATE; |
118 | bd = gd->bd; | 118 | bd = gd->bd; |
119 | bd->bi_baudrate = CONFIG_BAUDRATE; | 119 | bd->bi_baudrate = CONFIG_BAUDRATE; |
120 | bd->bi_memstart = CFG_SDRAM_BASE; | 120 | bd->bi_memstart = CFG_SDRAM_BASE; |
121 | bd->bi_memsize = CFG_SDRAM_SIZE; | 121 | bd->bi_memsize = CFG_SDRAM_SIZE; |
122 | 122 | ||
123 | /* Initialise malloc() area */ | 123 | /* Initialise malloc() area */ |
124 | mem_malloc_init (); | 124 | mem_malloc_init (); |
125 | 125 | ||
126 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { | 126 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { |
127 | WATCHDOG_RESET (); | 127 | WATCHDOG_RESET (); |
128 | if ((*init_fnc_ptr) () != 0) { | 128 | if ((*init_fnc_ptr) () != 0) { |
129 | hang (); | 129 | hang (); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | #if (CONFIG_COMMANDS & CFG_CMD_FLASH) || defined(CONFIG_CMD_FLASH) | 133 | #if defined(CONFIG_CMD_FLASH) |
134 | bd->bi_flashstart = CFG_FLASH_BASE; | 134 | bd->bi_flashstart = CFG_FLASH_BASE; |
135 | if (0 < (flash_size = flash_init ())) { | 135 | if (0 < (flash_size = flash_init ())) { |
136 | bd->bi_flashsize = flash_size; | 136 | bd->bi_flashsize = flash_size; |
137 | bd->bi_flashoffset = CFG_FLASH_BASE + flash_size; | 137 | bd->bi_flashoffset = CFG_FLASH_BASE + flash_size; |
138 | } else { | 138 | } else { |
139 | puts ("Flash init FAILED"); | 139 | puts ("Flash init FAILED"); |
140 | bd->bi_flashstart = 0; | 140 | bd->bi_flashstart = 0; |
141 | bd->bi_flashsize = 0; | 141 | bd->bi_flashsize = 0; |
142 | bd->bi_flashoffset = 0; | 142 | bd->bi_flashoffset = 0; |
143 | } | 143 | } |
144 | #endif | 144 | #endif |
145 | 145 | ||
146 | #if (CONFIG_COMMANDS & CFG_CMD_NET) || defined(CONFIG_CMD_NET) | 146 | #if defined(CONFIG_CMD_NET) |
147 | char *s, *e; | 147 | char *s, *e; |
148 | int i; | 148 | int i; |
149 | /* board MAC address */ | 149 | /* board MAC address */ |
150 | s = getenv ("ethaddr"); | 150 | s = getenv ("ethaddr"); |
151 | for (i = 0; i < 6; ++i) { | 151 | for (i = 0; i < 6; ++i) { |
152 | bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0; | 152 | bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0; |
153 | if (s) | 153 | if (s) |
154 | s = (*e) ? e + 1 : e; | 154 | s = (*e) ? e + 1 : e; |
155 | } | 155 | } |
156 | /* IP Address */ | 156 | /* IP Address */ |
157 | bd->bi_ip_addr = getenv_IPaddr ("ipaddr"); | 157 | bd->bi_ip_addr = getenv_IPaddr ("ipaddr"); |
158 | eth_init (bd); | 158 | eth_init (bd); |
159 | #endif | 159 | #endif |
160 | 160 | ||
161 | /* relocate environment function pointers etc. */ | 161 | /* relocate environment function pointers etc. */ |
162 | env_relocate (); | 162 | env_relocate (); |
163 | 163 | ||
164 | /* main_loop */ | 164 | /* main_loop */ |
165 | for (;;) { | 165 | for (;;) { |
166 | WATCHDOG_RESET (); | 166 | WATCHDOG_RESET (); |
167 | main_loop (); | 167 | main_loop (); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | void hang (void) | 171 | void hang (void) |
172 | { | 172 | { |
173 | puts ("### ERROR ### Please RESET the board ###\n"); | 173 | puts ("### ERROR ### Please RESET the board ###\n"); |
174 | for (;;) ; | 174 | for (;;) ; |
175 | } | 175 | } |
176 | 176 |
lib_mips/board.c
1 | /* | 1 | /* |
2 | * (C) Copyright 2003 | 2 | * (C) Copyright 2003 |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
4 | * | 4 | * |
5 | * See file CREDITS for list of people who contributed to this | 5 | * See file CREDITS for list of people who contributed to this |
6 | * project. | 6 | * project. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or | 8 | * This program is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU General Public License as | 9 | * modify it under the terms of the GNU General Public License as |
10 | * published by the Free Software Foundation; either version 2 of | 10 | * published by the Free Software Foundation; either version 2 of |
11 | * the License, or (at your option) any later version. | 11 | * the License, or (at your option) any later version. |
12 | * | 12 | * |
13 | * This program is distributed in the hope that it will be useful, | 13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. | 16 | * GNU General Public License for more details. |
17 | * | 17 | * |
18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software | 19 | * along with this program; if not, write to the Free Software |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
21 | * MA 02111-1307 USA | 21 | * MA 02111-1307 USA |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <common.h> | 24 | #include <common.h> |
25 | #include <command.h> | 25 | #include <command.h> |
26 | #include <malloc.h> | 26 | #include <malloc.h> |
27 | #include <devices.h> | 27 | #include <devices.h> |
28 | #include <version.h> | 28 | #include <version.h> |
29 | #include <net.h> | 29 | #include <net.h> |
30 | #include <environment.h> | 30 | #include <environment.h> |
31 | 31 | ||
32 | DECLARE_GLOBAL_DATA_PTR; | 32 | DECLARE_GLOBAL_DATA_PTR; |
33 | 33 | ||
34 | #if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \ | 34 | #if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \ |
35 | (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \ | 35 | (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \ |
36 | defined(CFG_ENV_IS_IN_NVRAM) | 36 | defined(CFG_ENV_IS_IN_NVRAM) |
37 | #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE) | 37 | #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE) |
38 | #else | 38 | #else |
39 | #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN | 39 | #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #undef DEBUG | 42 | #undef DEBUG |
43 | 43 | ||
44 | extern int timer_init(void); | 44 | extern int timer_init(void); |
45 | 45 | ||
46 | extern int incaip_set_cpuclk(void); | 46 | extern int incaip_set_cpuclk(void); |
47 | 47 | ||
48 | extern ulong uboot_end_data; | 48 | extern ulong uboot_end_data; |
49 | extern ulong uboot_end; | 49 | extern ulong uboot_end; |
50 | 50 | ||
51 | ulong monitor_flash_len; | 51 | ulong monitor_flash_len; |
52 | 52 | ||
53 | const char version_string[] = | 53 | const char version_string[] = |
54 | U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")"; | 54 | U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")"; |
55 | 55 | ||
56 | static char *failed = "*** failed ***\n"; | 56 | static char *failed = "*** failed ***\n"; |
57 | 57 | ||
58 | /* | 58 | /* |
59 | * Begin and End of memory area for malloc(), and current "brk" | 59 | * Begin and End of memory area for malloc(), and current "brk" |
60 | */ | 60 | */ |
61 | static ulong mem_malloc_start; | 61 | static ulong mem_malloc_start; |
62 | static ulong mem_malloc_end; | 62 | static ulong mem_malloc_end; |
63 | static ulong mem_malloc_brk; | 63 | static ulong mem_malloc_brk; |
64 | 64 | ||
65 | 65 | ||
66 | /* | 66 | /* |
67 | * The Malloc area is immediately below the monitor copy in DRAM | 67 | * The Malloc area is immediately below the monitor copy in DRAM |
68 | */ | 68 | */ |
69 | static void mem_malloc_init (void) | 69 | static void mem_malloc_init (void) |
70 | { | 70 | { |
71 | ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off; | 71 | ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off; |
72 | 72 | ||
73 | mem_malloc_end = dest_addr; | 73 | mem_malloc_end = dest_addr; |
74 | mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN; | 74 | mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN; |
75 | mem_malloc_brk = mem_malloc_start; | 75 | mem_malloc_brk = mem_malloc_start; |
76 | 76 | ||
77 | memset ((void *) mem_malloc_start, | 77 | memset ((void *) mem_malloc_start, |
78 | 0, | 78 | 0, |
79 | mem_malloc_end - mem_malloc_start); | 79 | mem_malloc_end - mem_malloc_start); |
80 | } | 80 | } |
81 | 81 | ||
82 | void *sbrk (ptrdiff_t increment) | 82 | void *sbrk (ptrdiff_t increment) |
83 | { | 83 | { |
84 | ulong old = mem_malloc_brk; | 84 | ulong old = mem_malloc_brk; |
85 | ulong new = old + increment; | 85 | ulong new = old + increment; |
86 | 86 | ||
87 | if ((new < mem_malloc_start) || (new > mem_malloc_end)) { | 87 | if ((new < mem_malloc_start) || (new > mem_malloc_end)) { |
88 | return (NULL); | 88 | return (NULL); |
89 | } | 89 | } |
90 | mem_malloc_brk = new; | 90 | mem_malloc_brk = new; |
91 | return ((void *) old); | 91 | return ((void *) old); |
92 | } | 92 | } |
93 | 93 | ||
94 | 94 | ||
95 | static int init_func_ram (void) | 95 | static int init_func_ram (void) |
96 | { | 96 | { |
97 | #ifdef CONFIG_BOARD_TYPES | 97 | #ifdef CONFIG_BOARD_TYPES |
98 | int board_type = gd->board_type; | 98 | int board_type = gd->board_type; |
99 | #else | 99 | #else |
100 | int board_type = 0; /* use dummy arg */ | 100 | int board_type = 0; /* use dummy arg */ |
101 | #endif | 101 | #endif |
102 | puts ("DRAM: "); | 102 | puts ("DRAM: "); |
103 | 103 | ||
104 | if ((gd->ram_size = initdram (board_type)) > 0) { | 104 | if ((gd->ram_size = initdram (board_type)) > 0) { |
105 | print_size (gd->ram_size, "\n"); | 105 | print_size (gd->ram_size, "\n"); |
106 | return (0); | 106 | return (0); |
107 | } | 107 | } |
108 | puts (failed); | 108 | puts (failed); |
109 | return (1); | 109 | return (1); |
110 | } | 110 | } |
111 | 111 | ||
112 | static int display_banner(void) | 112 | static int display_banner(void) |
113 | { | 113 | { |
114 | 114 | ||
115 | printf ("\n\n%s\n\n", version_string); | 115 | printf ("\n\n%s\n\n", version_string); |
116 | return (0); | 116 | return (0); |
117 | } | 117 | } |
118 | 118 | ||
119 | static void display_flash_config(ulong size) | 119 | static void display_flash_config(ulong size) |
120 | { | 120 | { |
121 | puts ("Flash: "); | 121 | puts ("Flash: "); |
122 | print_size (size, "\n"); | 122 | print_size (size, "\n"); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | static int init_baudrate (void) | 126 | static int init_baudrate (void) |
127 | { | 127 | { |
128 | char tmp[64]; /* long enough for environment variables */ | 128 | char tmp[64]; /* long enough for environment variables */ |
129 | int i = getenv_r ("baudrate", tmp, sizeof (tmp)); | 129 | int i = getenv_r ("baudrate", tmp, sizeof (tmp)); |
130 | 130 | ||
131 | gd->baudrate = (i > 0) | 131 | gd->baudrate = (i > 0) |
132 | ? (int) simple_strtoul (tmp, NULL, 10) | 132 | ? (int) simple_strtoul (tmp, NULL, 10) |
133 | : CONFIG_BAUDRATE; | 133 | : CONFIG_BAUDRATE; |
134 | 134 | ||
135 | return (0); | 135 | return (0); |
136 | } | 136 | } |
137 | 137 | ||
138 | 138 | ||
139 | /* | 139 | /* |
140 | * Breath some life into the board... | 140 | * Breath some life into the board... |
141 | * | 141 | * |
142 | * The first part of initialization is running from Flash memory; | 142 | * The first part of initialization is running from Flash memory; |
143 | * its main purpose is to initialize the RAM so that we | 143 | * its main purpose is to initialize the RAM so that we |
144 | * can relocate the monitor code to RAM. | 144 | * can relocate the monitor code to RAM. |
145 | */ | 145 | */ |
146 | 146 | ||
147 | /* | 147 | /* |
148 | * All attempts to come up with a "common" initialization sequence | 148 | * All attempts to come up with a "common" initialization sequence |
149 | * that works for all boards and architectures failed: some of the | 149 | * that works for all boards and architectures failed: some of the |
150 | * requirements are just _too_ different. To get rid of the resulting | 150 | * requirements are just _too_ different. To get rid of the resulting |
151 | * mess of board dependend #ifdef'ed code we now make the whole | 151 | * mess of board dependend #ifdef'ed code we now make the whole |
152 | * initialization sequence configurable to the user. | 152 | * initialization sequence configurable to the user. |
153 | * | 153 | * |
154 | * The requirements for any new initalization function is simple: it | 154 | * The requirements for any new initalization function is simple: it |
155 | * receives a pointer to the "global data" structure as it's only | 155 | * receives a pointer to the "global data" structure as it's only |
156 | * argument, and returns an integer return code, where 0 means | 156 | * argument, and returns an integer return code, where 0 means |
157 | * "continue" and != 0 means "fatal error, hang the system". | 157 | * "continue" and != 0 means "fatal error, hang the system". |
158 | */ | 158 | */ |
159 | typedef int (init_fnc_t) (void); | 159 | typedef int (init_fnc_t) (void); |
160 | 160 | ||
161 | init_fnc_t *init_sequence[] = { | 161 | init_fnc_t *init_sequence[] = { |
162 | timer_init, | 162 | timer_init, |
163 | env_init, /* initialize environment */ | 163 | env_init, /* initialize environment */ |
164 | #ifdef CONFIG_INCA_IP | 164 | #ifdef CONFIG_INCA_IP |
165 | incaip_set_cpuclk, /* set cpu clock according to environment variable */ | 165 | incaip_set_cpuclk, /* set cpu clock according to environment variable */ |
166 | #endif | 166 | #endif |
167 | init_baudrate, /* initialze baudrate settings */ | 167 | init_baudrate, /* initialze baudrate settings */ |
168 | serial_init, /* serial communications setup */ | 168 | serial_init, /* serial communications setup */ |
169 | console_init_f, | 169 | console_init_f, |
170 | display_banner, /* say that we are here */ | 170 | display_banner, /* say that we are here */ |
171 | checkboard, | 171 | checkboard, |
172 | init_func_ram, | 172 | init_func_ram, |
173 | NULL, | 173 | NULL, |
174 | }; | 174 | }; |
175 | 175 | ||
176 | 176 | ||
177 | void board_init_f(ulong bootflag) | 177 | void board_init_f(ulong bootflag) |
178 | { | 178 | { |
179 | gd_t gd_data, *id; | 179 | gd_t gd_data, *id; |
180 | bd_t *bd; | 180 | bd_t *bd; |
181 | init_fnc_t **init_fnc_ptr; | 181 | init_fnc_t **init_fnc_ptr; |
182 | ulong addr, addr_sp, len = (ulong)&uboot_end - CFG_MONITOR_BASE; | 182 | ulong addr, addr_sp, len = (ulong)&uboot_end - CFG_MONITOR_BASE; |
183 | ulong *s; | 183 | ulong *s; |
184 | #ifdef CONFIG_PURPLE | 184 | #ifdef CONFIG_PURPLE |
185 | void copy_code (ulong); | 185 | void copy_code (ulong); |
186 | #endif | 186 | #endif |
187 | 187 | ||
188 | /* Pointer is writable since we allocated a register for it. | 188 | /* Pointer is writable since we allocated a register for it. |
189 | */ | 189 | */ |
190 | gd = &gd_data; | 190 | gd = &gd_data; |
191 | /* compiler optimization barrier needed for GCC >= 3.4 */ | 191 | /* compiler optimization barrier needed for GCC >= 3.4 */ |
192 | __asm__ __volatile__("": : :"memory"); | 192 | __asm__ __volatile__("": : :"memory"); |
193 | 193 | ||
194 | memset ((void *)gd, 0, sizeof (gd_t)); | 194 | memset ((void *)gd, 0, sizeof (gd_t)); |
195 | 195 | ||
196 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { | 196 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { |
197 | if ((*init_fnc_ptr)() != 0) { | 197 | if ((*init_fnc_ptr)() != 0) { |
198 | hang (); | 198 | hang (); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | /* | 202 | /* |
203 | * Now that we have DRAM mapped and working, we can | 203 | * Now that we have DRAM mapped and working, we can |
204 | * relocate the code and continue running from DRAM. | 204 | * relocate the code and continue running from DRAM. |
205 | */ | 205 | */ |
206 | addr = CFG_SDRAM_BASE + gd->ram_size; | 206 | addr = CFG_SDRAM_BASE + gd->ram_size; |
207 | 207 | ||
208 | /* We can reserve some RAM "on top" here. | 208 | /* We can reserve some RAM "on top" here. |
209 | */ | 209 | */ |
210 | 210 | ||
211 | /* round down to next 4 kB limit. | 211 | /* round down to next 4 kB limit. |
212 | */ | 212 | */ |
213 | addr &= ~(4096 - 1); | 213 | addr &= ~(4096 - 1); |
214 | debug ("Top of RAM usable for U-Boot at: %08lx\n", addr); | 214 | debug ("Top of RAM usable for U-Boot at: %08lx\n", addr); |
215 | 215 | ||
216 | /* Reserve memory for U-Boot code, data & bss | 216 | /* Reserve memory for U-Boot code, data & bss |
217 | * round down to next 16 kB limit | 217 | * round down to next 16 kB limit |
218 | */ | 218 | */ |
219 | addr -= len; | 219 | addr -= len; |
220 | addr &= ~(16 * 1024 - 1); | 220 | addr &= ~(16 * 1024 - 1); |
221 | 221 | ||
222 | debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr); | 222 | debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr); |
223 | 223 | ||
224 | /* Reserve memory for malloc() arena. | 224 | /* Reserve memory for malloc() arena. |
225 | */ | 225 | */ |
226 | addr_sp = addr - TOTAL_MALLOC_LEN; | 226 | addr_sp = addr - TOTAL_MALLOC_LEN; |
227 | debug ("Reserving %dk for malloc() at: %08lx\n", | 227 | debug ("Reserving %dk for malloc() at: %08lx\n", |
228 | TOTAL_MALLOC_LEN >> 10, addr_sp); | 228 | TOTAL_MALLOC_LEN >> 10, addr_sp); |
229 | 229 | ||
230 | /* | 230 | /* |
231 | * (permanently) allocate a Board Info struct | 231 | * (permanently) allocate a Board Info struct |
232 | * and a permanent copy of the "global" data | 232 | * and a permanent copy of the "global" data |
233 | */ | 233 | */ |
234 | addr_sp -= sizeof(bd_t); | 234 | addr_sp -= sizeof(bd_t); |
235 | bd = (bd_t *)addr_sp; | 235 | bd = (bd_t *)addr_sp; |
236 | gd->bd = bd; | 236 | gd->bd = bd; |
237 | debug ("Reserving %d Bytes for Board Info at: %08lx\n", | 237 | debug ("Reserving %d Bytes for Board Info at: %08lx\n", |
238 | sizeof(bd_t), addr_sp); | 238 | sizeof(bd_t), addr_sp); |
239 | 239 | ||
240 | addr_sp -= sizeof(gd_t); | 240 | addr_sp -= sizeof(gd_t); |
241 | id = (gd_t *)addr_sp; | 241 | id = (gd_t *)addr_sp; |
242 | debug ("Reserving %d Bytes for Global Data at: %08lx\n", | 242 | debug ("Reserving %d Bytes for Global Data at: %08lx\n", |
243 | sizeof (gd_t), addr_sp); | 243 | sizeof (gd_t), addr_sp); |
244 | 244 | ||
245 | /* Reserve memory for boot params. | 245 | /* Reserve memory for boot params. |
246 | */ | 246 | */ |
247 | addr_sp -= CFG_BOOTPARAMS_LEN; | 247 | addr_sp -= CFG_BOOTPARAMS_LEN; |
248 | bd->bi_boot_params = addr_sp; | 248 | bd->bi_boot_params = addr_sp; |
249 | debug ("Reserving %dk for boot params() at: %08lx\n", | 249 | debug ("Reserving %dk for boot params() at: %08lx\n", |
250 | CFG_BOOTPARAMS_LEN >> 10, addr_sp); | 250 | CFG_BOOTPARAMS_LEN >> 10, addr_sp); |
251 | 251 | ||
252 | /* | 252 | /* |
253 | * Finally, we set up a new (bigger) stack. | 253 | * Finally, we set up a new (bigger) stack. |
254 | * | 254 | * |
255 | * Leave some safety gap for SP, force alignment on 16 byte boundary | 255 | * Leave some safety gap for SP, force alignment on 16 byte boundary |
256 | * Clear initial stack frame | 256 | * Clear initial stack frame |
257 | */ | 257 | */ |
258 | addr_sp -= 16; | 258 | addr_sp -= 16; |
259 | addr_sp &= ~0xF; | 259 | addr_sp &= ~0xF; |
260 | s = (ulong *)addr_sp; | 260 | s = (ulong *)addr_sp; |
261 | *s-- = 0; | 261 | *s-- = 0; |
262 | *s-- = 0; | 262 | *s-- = 0; |
263 | addr_sp = (ulong)s; | 263 | addr_sp = (ulong)s; |
264 | debug ("Stack Pointer at: %08lx\n", addr_sp); | 264 | debug ("Stack Pointer at: %08lx\n", addr_sp); |
265 | 265 | ||
266 | /* | 266 | /* |
267 | * Save local variables to board info struct | 267 | * Save local variables to board info struct |
268 | */ | 268 | */ |
269 | bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */ | 269 | bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */ |
270 | bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */ | 270 | bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */ |
271 | bd->bi_baudrate = gd->baudrate; /* Console Baudrate */ | 271 | bd->bi_baudrate = gd->baudrate; /* Console Baudrate */ |
272 | 272 | ||
273 | memcpy (id, (void *)gd, sizeof (gd_t)); | 273 | memcpy (id, (void *)gd, sizeof (gd_t)); |
274 | 274 | ||
275 | /* On the purple board we copy the code in a special way | 275 | /* On the purple board we copy the code in a special way |
276 | * in order to solve flash problems | 276 | * in order to solve flash problems |
277 | */ | 277 | */ |
278 | #ifdef CONFIG_PURPLE | 278 | #ifdef CONFIG_PURPLE |
279 | copy_code(addr); | 279 | copy_code(addr); |
280 | #endif | 280 | #endif |
281 | 281 | ||
282 | relocate_code (addr_sp, id, addr); | 282 | relocate_code (addr_sp, id, addr); |
283 | 283 | ||
284 | /* NOTREACHED - relocate_code() does not return */ | 284 | /* NOTREACHED - relocate_code() does not return */ |
285 | } | 285 | } |
286 | /************************************************************************ | 286 | /************************************************************************ |
287 | * | 287 | * |
288 | * This is the next part if the initialization sequence: we are now | 288 | * This is the next part if the initialization sequence: we are now |
289 | * running from RAM and have a "normal" C environment, i. e. global | 289 | * running from RAM and have a "normal" C environment, i. e. global |
290 | * data can be written, BSS has been cleared, the stack size in not | 290 | * data can be written, BSS has been cleared, the stack size in not |
291 | * that critical any more, etc. | 291 | * that critical any more, etc. |
292 | * | 292 | * |
293 | ************************************************************************ | 293 | ************************************************************************ |
294 | */ | 294 | */ |
295 | 295 | ||
296 | void board_init_r (gd_t *id, ulong dest_addr) | 296 | void board_init_r (gd_t *id, ulong dest_addr) |
297 | { | 297 | { |
298 | cmd_tbl_t *cmdtp; | 298 | cmd_tbl_t *cmdtp; |
299 | ulong size; | 299 | ulong size; |
300 | extern void malloc_bin_reloc (void); | 300 | extern void malloc_bin_reloc (void); |
301 | #ifndef CFG_ENV_IS_NOWHERE | 301 | #ifndef CFG_ENV_IS_NOWHERE |
302 | extern char * env_name_spec; | 302 | extern char * env_name_spec; |
303 | #endif | 303 | #endif |
304 | char *s, *e; | 304 | char *s, *e; |
305 | bd_t *bd; | 305 | bd_t *bd; |
306 | int i; | 306 | int i; |
307 | 307 | ||
308 | gd = id; | 308 | gd = id; |
309 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ | 309 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ |
310 | 310 | ||
311 | debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr); | 311 | debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr); |
312 | 312 | ||
313 | gd->reloc_off = dest_addr - CFG_MONITOR_BASE; | 313 | gd->reloc_off = dest_addr - CFG_MONITOR_BASE; |
314 | 314 | ||
315 | monitor_flash_len = (ulong)&uboot_end_data - dest_addr; | 315 | monitor_flash_len = (ulong)&uboot_end_data - dest_addr; |
316 | 316 | ||
317 | /* | 317 | /* |
318 | * We have to relocate the command table manually | 318 | * We have to relocate the command table manually |
319 | */ | 319 | */ |
320 | for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { | 320 | for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { |
321 | ulong addr; | 321 | ulong addr; |
322 | 322 | ||
323 | addr = (ulong) (cmdtp->cmd) + gd->reloc_off; | 323 | addr = (ulong) (cmdtp->cmd) + gd->reloc_off; |
324 | #if 0 | 324 | #if 0 |
325 | printf ("Command \"%s\": 0x%08lx => 0x%08lx\n", | 325 | printf ("Command \"%s\": 0x%08lx => 0x%08lx\n", |
326 | cmdtp->name, (ulong) (cmdtp->cmd), addr); | 326 | cmdtp->name, (ulong) (cmdtp->cmd), addr); |
327 | #endif | 327 | #endif |
328 | cmdtp->cmd = | 328 | cmdtp->cmd = |
329 | (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; | 329 | (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; |
330 | 330 | ||
331 | addr = (ulong)(cmdtp->name) + gd->reloc_off; | 331 | addr = (ulong)(cmdtp->name) + gd->reloc_off; |
332 | cmdtp->name = (char *)addr; | 332 | cmdtp->name = (char *)addr; |
333 | 333 | ||
334 | if (cmdtp->usage) { | 334 | if (cmdtp->usage) { |
335 | addr = (ulong)(cmdtp->usage) + gd->reloc_off; | 335 | addr = (ulong)(cmdtp->usage) + gd->reloc_off; |
336 | cmdtp->usage = (char *)addr; | 336 | cmdtp->usage = (char *)addr; |
337 | } | 337 | } |
338 | #ifdef CFG_LONGHELP | 338 | #ifdef CFG_LONGHELP |
339 | if (cmdtp->help) { | 339 | if (cmdtp->help) { |
340 | addr = (ulong)(cmdtp->help) + gd->reloc_off; | 340 | addr = (ulong)(cmdtp->help) + gd->reloc_off; |
341 | cmdtp->help = (char *)addr; | 341 | cmdtp->help = (char *)addr; |
342 | } | 342 | } |
343 | #endif | 343 | #endif |
344 | } | 344 | } |
345 | /* there are some other pointer constants we must deal with */ | 345 | /* there are some other pointer constants we must deal with */ |
346 | #ifndef CFG_ENV_IS_NOWHERE | 346 | #ifndef CFG_ENV_IS_NOWHERE |
347 | env_name_spec += gd->reloc_off; | 347 | env_name_spec += gd->reloc_off; |
348 | #endif | 348 | #endif |
349 | 349 | ||
350 | /* configure available FLASH banks */ | 350 | /* configure available FLASH banks */ |
351 | size = flash_init(); | 351 | size = flash_init(); |
352 | display_flash_config (size); | 352 | display_flash_config (size); |
353 | 353 | ||
354 | bd = gd->bd; | 354 | bd = gd->bd; |
355 | bd->bi_flashstart = CFG_FLASH_BASE; | 355 | bd->bi_flashstart = CFG_FLASH_BASE; |
356 | bd->bi_flashsize = size; | 356 | bd->bi_flashsize = size; |
357 | #if CFG_MONITOR_BASE == CFG_FLASH_BASE | 357 | #if CFG_MONITOR_BASE == CFG_FLASH_BASE |
358 | bd->bi_flashoffset = monitor_flash_len; /* reserved area for U-Boot */ | 358 | bd->bi_flashoffset = monitor_flash_len; /* reserved area for U-Boot */ |
359 | #else | 359 | #else |
360 | bd->bi_flashoffset = 0; | 360 | bd->bi_flashoffset = 0; |
361 | #endif | 361 | #endif |
362 | 362 | ||
363 | /* initialize malloc() area */ | 363 | /* initialize malloc() area */ |
364 | mem_malloc_init(); | 364 | mem_malloc_init(); |
365 | malloc_bin_reloc(); | 365 | malloc_bin_reloc(); |
366 | 366 | ||
367 | /* relocate environment function pointers etc. */ | 367 | /* relocate environment function pointers etc. */ |
368 | env_relocate(); | 368 | env_relocate(); |
369 | 369 | ||
370 | /* board MAC address */ | 370 | /* board MAC address */ |
371 | s = getenv ("ethaddr"); | 371 | s = getenv ("ethaddr"); |
372 | for (i = 0; i < 6; ++i) { | 372 | for (i = 0; i < 6; ++i) { |
373 | bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0; | 373 | bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0; |
374 | if (s) | 374 | if (s) |
375 | s = (*e) ? e + 1 : e; | 375 | s = (*e) ? e + 1 : e; |
376 | } | 376 | } |
377 | 377 | ||
378 | /* IP Address */ | 378 | /* IP Address */ |
379 | bd->bi_ip_addr = getenv_IPaddr("ipaddr"); | 379 | bd->bi_ip_addr = getenv_IPaddr("ipaddr"); |
380 | 380 | ||
381 | #if defined(CONFIG_PCI) | 381 | #if defined(CONFIG_PCI) |
382 | /* | 382 | /* |
383 | * Do pci configuration | 383 | * Do pci configuration |
384 | */ | 384 | */ |
385 | pci_init(); | 385 | pci_init(); |
386 | #endif | 386 | #endif |
387 | 387 | ||
388 | /** leave this here (after malloc(), environment and PCI are working) **/ | 388 | /** leave this here (after malloc(), environment and PCI are working) **/ |
389 | /* Initialize devices */ | 389 | /* Initialize devices */ |
390 | devices_init (); | 390 | devices_init (); |
391 | 391 | ||
392 | jumptable_init (); | 392 | jumptable_init (); |
393 | 393 | ||
394 | /* Initialize the console (after the relocation and devices init) */ | 394 | /* Initialize the console (after the relocation and devices init) */ |
395 | console_init_r (); | 395 | console_init_r (); |
396 | /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ | 396 | /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ |
397 | 397 | ||
398 | /* Initialize from environment */ | 398 | /* Initialize from environment */ |
399 | if ((s = getenv ("loadaddr")) != NULL) { | 399 | if ((s = getenv ("loadaddr")) != NULL) { |
400 | load_addr = simple_strtoul (s, NULL, 16); | 400 | load_addr = simple_strtoul (s, NULL, 16); |
401 | } | 401 | } |
402 | #if (CONFIG_COMMANDS & CFG_CMD_NET) || defined(CONFIG_CMD_NET) | 402 | #if defined(CONFIG_CMD_NET) |
403 | if ((s = getenv ("bootfile")) != NULL) { | 403 | if ((s = getenv ("bootfile")) != NULL) { |
404 | copy_filename (BootFile, s, sizeof (BootFile)); | 404 | copy_filename (BootFile, s, sizeof (BootFile)); |
405 | } | 405 | } |
406 | #endif /* CFG_CMD_NET */ | 406 | #endif /* CFG_CMD_NET */ |
407 | 407 | ||
408 | #if defined(CONFIG_MISC_INIT_R) | 408 | #if defined(CONFIG_MISC_INIT_R) |
409 | /* miscellaneous platform dependent initialisations */ | 409 | /* miscellaneous platform dependent initialisations */ |
410 | misc_init_r (); | 410 | misc_init_r (); |
411 | #endif | 411 | #endif |
412 | 412 | ||
413 | #if (CONFIG_COMMANDS & CFG_CMD_NET) || defined(CONFIG_CMD_NET) | 413 | #if defined(CONFIG_CMD_NET) |
414 | #if defined(CONFIG_NET_MULTI) | 414 | #if defined(CONFIG_NET_MULTI) |
415 | puts ("Net: "); | 415 | puts ("Net: "); |
416 | #endif | 416 | #endif |
417 | eth_initialize(gd->bd); | 417 | eth_initialize(gd->bd); |
418 | #endif | 418 | #endif |
419 | 419 | ||
420 | /* main_loop() can return to retry autoboot, if so just run it again. */ | 420 | /* main_loop() can return to retry autoboot, if so just run it again. */ |
421 | for (;;) { | 421 | for (;;) { |
422 | main_loop (); | 422 | main_loop (); |
423 | } | 423 | } |
424 | 424 | ||
425 | /* NOTREACHED - no way out of command loop except booting */ | 425 | /* NOTREACHED - no way out of command loop except booting */ |
426 | } | 426 | } |
427 | 427 | ||
428 | void hang (void) | 428 | void hang (void) |
429 | { | 429 | { |
430 | puts ("### ERROR ### Please RESET the board ###\n"); | 430 | puts ("### ERROR ### Please RESET the board ###\n"); |
431 | for (;;); | 431 | for (;;); |
432 | } | 432 | } |
433 | 433 |
lib_ppc/board.c
1 | /* | 1 | /* |
2 | * (C) Copyright 2000-2006 | 2 | * (C) Copyright 2000-2006 |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
4 | * | 4 | * |
5 | * See file CREDITS for list of people who contributed to this | 5 | * See file CREDITS for list of people who contributed to this |
6 | * project. | 6 | * project. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or | 8 | * This program is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU General Public License as | 9 | * modify it under the terms of the GNU General Public License as |
10 | * published by the Free Software Foundation; either version 2 of | 10 | * published by the Free Software Foundation; either version 2 of |
11 | * the License, or (at your option) any later version. | 11 | * the License, or (at your option) any later version. |
12 | * | 12 | * |
13 | * This program is distributed in the hope that it will be useful, | 13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. | 16 | * GNU General Public License for more details. |
17 | * | 17 | * |
18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software | 19 | * along with this program; if not, write to the Free Software |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
21 | * MA 02111-1307 USA | 21 | * MA 02111-1307 USA |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <common.h> | 24 | #include <common.h> |
25 | #include <watchdog.h> | 25 | #include <watchdog.h> |
26 | #include <command.h> | 26 | #include <command.h> |
27 | #include <malloc.h> | 27 | #include <malloc.h> |
28 | #include <devices.h> | 28 | #include <devices.h> |
29 | #ifdef CONFIG_8xx | 29 | #ifdef CONFIG_8xx |
30 | #include <mpc8xx.h> | 30 | #include <mpc8xx.h> |
31 | #endif | 31 | #endif |
32 | #ifdef CONFIG_5xx | 32 | #ifdef CONFIG_5xx |
33 | #include <mpc5xx.h> | 33 | #include <mpc5xx.h> |
34 | #endif | 34 | #endif |
35 | #ifdef CONFIG_MPC5xxx | 35 | #ifdef CONFIG_MPC5xxx |
36 | #include <mpc5xxx.h> | 36 | #include <mpc5xxx.h> |
37 | #endif | 37 | #endif |
38 | #if (CONFIG_COMMANDS & CFG_CMD_IDE) || defined(CONFIG_CMD_IDE) | 38 | #if defined(CONFIG_CMD_IDE) |
39 | #include <ide.h> | 39 | #include <ide.h> |
40 | #endif | 40 | #endif |
41 | #if (CONFIG_COMMANDS & CFG_CMD_SCSI) || defined(CONFIG_CMD_SCSI) | 41 | #if defined(CONFIG_CMD_SCSI) |
42 | #include <scsi.h> | 42 | #include <scsi.h> |
43 | #endif | 43 | #endif |
44 | #if (CONFIG_COMMANDS & CFG_CMD_KGDB) || defined(CONFIG_CMD_KGDB) | 44 | #if defined(CONFIG_CMD_KGDB) |
45 | #include <kgdb.h> | 45 | #include <kgdb.h> |
46 | #endif | 46 | #endif |
47 | #ifdef CONFIG_STATUS_LED | 47 | #ifdef CONFIG_STATUS_LED |
48 | #include <status_led.h> | 48 | #include <status_led.h> |
49 | #endif | 49 | #endif |
50 | #include <net.h> | 50 | #include <net.h> |
51 | #include <serial.h> | 51 | #include <serial.h> |
52 | #ifdef CFG_ALLOC_DPRAM | 52 | #ifdef CFG_ALLOC_DPRAM |
53 | #if !defined(CONFIG_CPM2) | 53 | #if !defined(CONFIG_CPM2) |
54 | #include <commproc.h> | 54 | #include <commproc.h> |
55 | #endif | 55 | #endif |
56 | #endif | 56 | #endif |
57 | #include <version.h> | 57 | #include <version.h> |
58 | #if defined(CONFIG_BAB7xx) | 58 | #if defined(CONFIG_BAB7xx) |
59 | #include <w83c553f.h> | 59 | #include <w83c553f.h> |
60 | #endif | 60 | #endif |
61 | #include <dtt.h> | 61 | #include <dtt.h> |
62 | #if defined(CONFIG_POST) | 62 | #if defined(CONFIG_POST) |
63 | #include <post.h> | 63 | #include <post.h> |
64 | #endif | 64 | #endif |
65 | #if defined(CONFIG_LOGBUFFER) | 65 | #if defined(CONFIG_LOGBUFFER) |
66 | #include <logbuff.h> | 66 | #include <logbuff.h> |
67 | #endif | 67 | #endif |
68 | #if defined(CFG_INIT_RAM_LOCK) && defined(CONFIG_E500) | 68 | #if defined(CFG_INIT_RAM_LOCK) && defined(CONFIG_E500) |
69 | #include <asm/cache.h> | 69 | #include <asm/cache.h> |
70 | #endif | 70 | #endif |
71 | #ifdef CONFIG_PS2KBD | 71 | #ifdef CONFIG_PS2KBD |
72 | #include <keyboard.h> | 72 | #include <keyboard.h> |
73 | #endif | 73 | #endif |
74 | 74 | ||
75 | #ifdef CFG_UPDATE_FLASH_SIZE | 75 | #ifdef CFG_UPDATE_FLASH_SIZE |
76 | extern int update_flash_size (int flash_size); | 76 | extern int update_flash_size (int flash_size); |
77 | #endif | 77 | #endif |
78 | 78 | ||
79 | #if defined(CONFIG_SC3) | 79 | #if defined(CONFIG_SC3) |
80 | extern void sc3_read_eeprom(void); | 80 | extern void sc3_read_eeprom(void); |
81 | #endif | 81 | #endif |
82 | 82 | ||
83 | #if (CONFIG_COMMANDS & CFG_CMD_DOC) || defined(CONFIG_CMD_DOC) | 83 | #if defined(CONFIG_CMD_DOC) |
84 | void doc_init (void); | 84 | void doc_init (void); |
85 | #endif | 85 | #endif |
86 | #if defined(CONFIG_HARD_I2C) || \ | 86 | #if defined(CONFIG_HARD_I2C) || \ |
87 | defined(CONFIG_SOFT_I2C) | 87 | defined(CONFIG_SOFT_I2C) |
88 | #include <i2c.h> | 88 | #include <i2c.h> |
89 | #endif | 89 | #endif |
90 | #if (CONFIG_COMMANDS & CFG_CMD_NAND) || defined(CONFIG_CMD_NAND) | 90 | #if defined(CONFIG_CMD_NAND) |
91 | void nand_init (void); | 91 | void nand_init (void); |
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | static char *failed = "*** failed ***\n"; | 94 | static char *failed = "*** failed ***\n"; |
95 | 95 | ||
96 | #if defined(CONFIG_OXC) || defined(CONFIG_PCU_E) || defined(CONFIG_RMU) | 96 | #if defined(CONFIG_OXC) || defined(CONFIG_PCU_E) || defined(CONFIG_RMU) |
97 | extern flash_info_t flash_info[]; | 97 | extern flash_info_t flash_info[]; |
98 | #endif | 98 | #endif |
99 | 99 | ||
100 | #if defined(CONFIG_START_IDE) | 100 | #if defined(CONFIG_START_IDE) |
101 | extern int board_start_ide(void); | 101 | extern int board_start_ide(void); |
102 | #endif | 102 | #endif |
103 | #include <environment.h> | 103 | #include <environment.h> |
104 | 104 | ||
105 | DECLARE_GLOBAL_DATA_PTR; | 105 | DECLARE_GLOBAL_DATA_PTR; |
106 | 106 | ||
107 | #if defined(CFG_ENV_IS_EMBEDDED) | 107 | #if defined(CFG_ENV_IS_EMBEDDED) |
108 | #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN | 108 | #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN |
109 | #elif ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \ | 109 | #elif ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \ |
110 | (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \ | 110 | (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \ |
111 | defined(CFG_ENV_IS_IN_NVRAM) | 111 | defined(CFG_ENV_IS_IN_NVRAM) |
112 | #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE) | 112 | #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE) |
113 | #else | 113 | #else |
114 | #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN | 114 | #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN |
115 | #endif | 115 | #endif |
116 | 116 | ||
117 | extern ulong __init_end; | 117 | extern ulong __init_end; |
118 | extern ulong _end; | 118 | extern ulong _end; |
119 | ulong monitor_flash_len; | 119 | ulong monitor_flash_len; |
120 | 120 | ||
121 | #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG) || defined(CONFIG_CMD_BEDBUG) | 121 | #if defined(CONFIG_CMD_BEDBUG) |
122 | #include <bedbug/type.h> | 122 | #include <bedbug/type.h> |
123 | #endif | 123 | #endif |
124 | 124 | ||
125 | /* | 125 | /* |
126 | * Begin and End of memory area for malloc(), and current "brk" | 126 | * Begin and End of memory area for malloc(), and current "brk" |
127 | */ | 127 | */ |
128 | static ulong mem_malloc_start = 0; | 128 | static ulong mem_malloc_start = 0; |
129 | static ulong mem_malloc_end = 0; | 129 | static ulong mem_malloc_end = 0; |
130 | static ulong mem_malloc_brk = 0; | 130 | static ulong mem_malloc_brk = 0; |
131 | 131 | ||
132 | /************************************************************************ | 132 | /************************************************************************ |
133 | * Utilities * | 133 | * Utilities * |
134 | ************************************************************************ | 134 | ************************************************************************ |
135 | */ | 135 | */ |
136 | 136 | ||
137 | /* | 137 | /* |
138 | * The Malloc area is immediately below the monitor copy in DRAM | 138 | * The Malloc area is immediately below the monitor copy in DRAM |
139 | */ | 139 | */ |
140 | static void mem_malloc_init (void) | 140 | static void mem_malloc_init (void) |
141 | { | 141 | { |
142 | ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off; | 142 | ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off; |
143 | 143 | ||
144 | mem_malloc_end = dest_addr; | 144 | mem_malloc_end = dest_addr; |
145 | mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN; | 145 | mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN; |
146 | mem_malloc_brk = mem_malloc_start; | 146 | mem_malloc_brk = mem_malloc_start; |
147 | 147 | ||
148 | memset ((void *) mem_malloc_start, | 148 | memset ((void *) mem_malloc_start, |
149 | 0, | 149 | 0, |
150 | mem_malloc_end - mem_malloc_start); | 150 | mem_malloc_end - mem_malloc_start); |
151 | } | 151 | } |
152 | 152 | ||
153 | void *sbrk (ptrdiff_t increment) | 153 | void *sbrk (ptrdiff_t increment) |
154 | { | 154 | { |
155 | ulong old = mem_malloc_brk; | 155 | ulong old = mem_malloc_brk; |
156 | ulong new = old + increment; | 156 | ulong new = old + increment; |
157 | 157 | ||
158 | if ((new < mem_malloc_start) || (new > mem_malloc_end)) { | 158 | if ((new < mem_malloc_start) || (new > mem_malloc_end)) { |
159 | return (NULL); | 159 | return (NULL); |
160 | } | 160 | } |
161 | mem_malloc_brk = new; | 161 | mem_malloc_brk = new; |
162 | return ((void *) old); | 162 | return ((void *) old); |
163 | } | 163 | } |
164 | 164 | ||
165 | char *strmhz (char *buf, long hz) | 165 | char *strmhz (char *buf, long hz) |
166 | { | 166 | { |
167 | long l, n; | 167 | long l, n; |
168 | long m; | 168 | long m; |
169 | 169 | ||
170 | n = hz / 1000000L; | 170 | n = hz / 1000000L; |
171 | l = sprintf (buf, "%ld", n); | 171 | l = sprintf (buf, "%ld", n); |
172 | m = (hz % 1000000L) / 1000L; | 172 | m = (hz % 1000000L) / 1000L; |
173 | if (m != 0) | 173 | if (m != 0) |
174 | sprintf (buf + l, ".%03ld", m); | 174 | sprintf (buf + l, ".%03ld", m); |
175 | return (buf); | 175 | return (buf); |
176 | } | 176 | } |
177 | 177 | ||
178 | /* | 178 | /* |
179 | * All attempts to come up with a "common" initialization sequence | 179 | * All attempts to come up with a "common" initialization sequence |
180 | * that works for all boards and architectures failed: some of the | 180 | * that works for all boards and architectures failed: some of the |
181 | * requirements are just _too_ different. To get rid of the resulting | 181 | * requirements are just _too_ different. To get rid of the resulting |
182 | * mess of board dependend #ifdef'ed code we now make the whole | 182 | * mess of board dependend #ifdef'ed code we now make the whole |
183 | * initialization sequence configurable to the user. | 183 | * initialization sequence configurable to the user. |
184 | * | 184 | * |
185 | * The requirements for any new initalization function is simple: it | 185 | * The requirements for any new initalization function is simple: it |
186 | * receives a pointer to the "global data" structure as it's only | 186 | * receives a pointer to the "global data" structure as it's only |
187 | * argument, and returns an integer return code, where 0 means | 187 | * argument, and returns an integer return code, where 0 means |
188 | * "continue" and != 0 means "fatal error, hang the system". | 188 | * "continue" and != 0 means "fatal error, hang the system". |
189 | */ | 189 | */ |
190 | typedef int (init_fnc_t) (void); | 190 | typedef int (init_fnc_t) (void); |
191 | 191 | ||
192 | /************************************************************************ | 192 | /************************************************************************ |
193 | * Init Utilities * | 193 | * Init Utilities * |
194 | ************************************************************************ | 194 | ************************************************************************ |
195 | * Some of this code should be moved into the core functions, | 195 | * Some of this code should be moved into the core functions, |
196 | * but let's get it working (again) first... | 196 | * but let's get it working (again) first... |
197 | */ | 197 | */ |
198 | 198 | ||
199 | static int init_baudrate (void) | 199 | static int init_baudrate (void) |
200 | { | 200 | { |
201 | char tmp[64]; /* long enough for environment variables */ | 201 | char tmp[64]; /* long enough for environment variables */ |
202 | int i = getenv_r ("baudrate", tmp, sizeof (tmp)); | 202 | int i = getenv_r ("baudrate", tmp, sizeof (tmp)); |
203 | 203 | ||
204 | gd->baudrate = (i > 0) | 204 | gd->baudrate = (i > 0) |
205 | ? (int) simple_strtoul (tmp, NULL, 10) | 205 | ? (int) simple_strtoul (tmp, NULL, 10) |
206 | : CONFIG_BAUDRATE; | 206 | : CONFIG_BAUDRATE; |
207 | return (0); | 207 | return (0); |
208 | } | 208 | } |
209 | 209 | ||
210 | /***********************************************************************/ | 210 | /***********************************************************************/ |
211 | 211 | ||
212 | #ifdef CONFIG_ADD_RAM_INFO | 212 | #ifdef CONFIG_ADD_RAM_INFO |
213 | void board_add_ram_info(int); | 213 | void board_add_ram_info(int); |
214 | #endif | 214 | #endif |
215 | 215 | ||
216 | static int init_func_ram (void) | 216 | static int init_func_ram (void) |
217 | { | 217 | { |
218 | #ifdef CONFIG_BOARD_TYPES | 218 | #ifdef CONFIG_BOARD_TYPES |
219 | int board_type = gd->board_type; | 219 | int board_type = gd->board_type; |
220 | #else | 220 | #else |
221 | int board_type = 0; /* use dummy arg */ | 221 | int board_type = 0; /* use dummy arg */ |
222 | #endif | 222 | #endif |
223 | puts ("DRAM: "); | 223 | puts ("DRAM: "); |
224 | 224 | ||
225 | if ((gd->ram_size = initdram (board_type)) > 0) { | 225 | if ((gd->ram_size = initdram (board_type)) > 0) { |
226 | print_size (gd->ram_size, ""); | 226 | print_size (gd->ram_size, ""); |
227 | #ifdef CONFIG_ADD_RAM_INFO | 227 | #ifdef CONFIG_ADD_RAM_INFO |
228 | board_add_ram_info(0); | 228 | board_add_ram_info(0); |
229 | #endif | 229 | #endif |
230 | putc('\n'); | 230 | putc('\n'); |
231 | return (0); | 231 | return (0); |
232 | } | 232 | } |
233 | puts (failed); | 233 | puts (failed); |
234 | return (1); | 234 | return (1); |
235 | } | 235 | } |
236 | 236 | ||
237 | /***********************************************************************/ | 237 | /***********************************************************************/ |
238 | 238 | ||
239 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) | 239 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) |
240 | static int init_func_i2c (void) | 240 | static int init_func_i2c (void) |
241 | { | 241 | { |
242 | puts ("I2C: "); | 242 | puts ("I2C: "); |
243 | i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); | 243 | i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); |
244 | puts ("ready\n"); | 244 | puts ("ready\n"); |
245 | return (0); | 245 | return (0); |
246 | } | 246 | } |
247 | #endif | 247 | #endif |
248 | 248 | ||
249 | /***********************************************************************/ | 249 | /***********************************************************************/ |
250 | 250 | ||
251 | #if defined(CONFIG_WATCHDOG) | 251 | #if defined(CONFIG_WATCHDOG) |
252 | static int init_func_watchdog_init (void) | 252 | static int init_func_watchdog_init (void) |
253 | { | 253 | { |
254 | puts (" Watchdog enabled\n"); | 254 | puts (" Watchdog enabled\n"); |
255 | WATCHDOG_RESET (); | 255 | WATCHDOG_RESET (); |
256 | return (0); | 256 | return (0); |
257 | } | 257 | } |
258 | # define INIT_FUNC_WATCHDOG_INIT init_func_watchdog_init, | 258 | # define INIT_FUNC_WATCHDOG_INIT init_func_watchdog_init, |
259 | 259 | ||
260 | static int init_func_watchdog_reset (void) | 260 | static int init_func_watchdog_reset (void) |
261 | { | 261 | { |
262 | WATCHDOG_RESET (); | 262 | WATCHDOG_RESET (); |
263 | return (0); | 263 | return (0); |
264 | } | 264 | } |
265 | # define INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset, | 265 | # define INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset, |
266 | #else | 266 | #else |
267 | # define INIT_FUNC_WATCHDOG_INIT /* undef */ | 267 | # define INIT_FUNC_WATCHDOG_INIT /* undef */ |
268 | # define INIT_FUNC_WATCHDOG_RESET /* undef */ | 268 | # define INIT_FUNC_WATCHDOG_RESET /* undef */ |
269 | #endif /* CONFIG_WATCHDOG */ | 269 | #endif /* CONFIG_WATCHDOG */ |
270 | 270 | ||
271 | /************************************************************************ | 271 | /************************************************************************ |
272 | * Initialization sequence * | 272 | * Initialization sequence * |
273 | ************************************************************************ | 273 | ************************************************************************ |
274 | */ | 274 | */ |
275 | 275 | ||
276 | init_fnc_t *init_sequence[] = { | 276 | init_fnc_t *init_sequence[] = { |
277 | 277 | ||
278 | #if defined(CONFIG_BOARD_EARLY_INIT_F) | 278 | #if defined(CONFIG_BOARD_EARLY_INIT_F) |
279 | board_early_init_f, | 279 | board_early_init_f, |
280 | #endif | 280 | #endif |
281 | 281 | ||
282 | #if !defined(CONFIG_8xx_CPUCLK_DEFAULT) | 282 | #if !defined(CONFIG_8xx_CPUCLK_DEFAULT) |
283 | get_clocks, /* get CPU and bus clocks (etc.) */ | 283 | get_clocks, /* get CPU and bus clocks (etc.) */ |
284 | #if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \ | 284 | #if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \ |
285 | && !defined(CONFIG_TQM885D) | 285 | && !defined(CONFIG_TQM885D) |
286 | adjust_sdram_tbs_8xx, | 286 | adjust_sdram_tbs_8xx, |
287 | #endif | 287 | #endif |
288 | init_timebase, | 288 | init_timebase, |
289 | #endif | 289 | #endif |
290 | #ifdef CFG_ALLOC_DPRAM | 290 | #ifdef CFG_ALLOC_DPRAM |
291 | #if !defined(CONFIG_CPM2) | 291 | #if !defined(CONFIG_CPM2) |
292 | dpram_init, | 292 | dpram_init, |
293 | #endif | 293 | #endif |
294 | #endif | 294 | #endif |
295 | #if defined(CONFIG_BOARD_POSTCLK_INIT) | 295 | #if defined(CONFIG_BOARD_POSTCLK_INIT) |
296 | board_postclk_init, | 296 | board_postclk_init, |
297 | #endif | 297 | #endif |
298 | env_init, | 298 | env_init, |
299 | #if defined(CONFIG_8xx_CPUCLK_DEFAULT) | 299 | #if defined(CONFIG_8xx_CPUCLK_DEFAULT) |
300 | get_clocks_866, /* get CPU and bus clocks according to the environment variable */ | 300 | get_clocks_866, /* get CPU and bus clocks according to the environment variable */ |
301 | sdram_adjust_866, /* adjust sdram refresh rate according to the new clock */ | 301 | sdram_adjust_866, /* adjust sdram refresh rate according to the new clock */ |
302 | init_timebase, | 302 | init_timebase, |
303 | #endif | 303 | #endif |
304 | init_baudrate, | 304 | init_baudrate, |
305 | serial_init, | 305 | serial_init, |
306 | console_init_f, | 306 | console_init_f, |
307 | display_options, | 307 | display_options, |
308 | #if defined(CONFIG_8260) | 308 | #if defined(CONFIG_8260) |
309 | prt_8260_rsr, | 309 | prt_8260_rsr, |
310 | prt_8260_clks, | 310 | prt_8260_clks, |
311 | #endif /* CONFIG_8260 */ | 311 | #endif /* CONFIG_8260 */ |
312 | 312 | ||
313 | checkcpu, | 313 | checkcpu, |
314 | #if defined(CONFIG_MPC5xxx) | 314 | #if defined(CONFIG_MPC5xxx) |
315 | prt_mpc5xxx_clks, | 315 | prt_mpc5xxx_clks, |
316 | #endif /* CONFIG_MPC5xxx */ | 316 | #endif /* CONFIG_MPC5xxx */ |
317 | #if defined(CONFIG_MPC8220) | 317 | #if defined(CONFIG_MPC8220) |
318 | prt_mpc8220_clks, | 318 | prt_mpc8220_clks, |
319 | #endif | 319 | #endif |
320 | checkboard, | 320 | checkboard, |
321 | INIT_FUNC_WATCHDOG_INIT | 321 | INIT_FUNC_WATCHDOG_INIT |
322 | #if defined(CONFIG_MISC_INIT_F) | 322 | #if defined(CONFIG_MISC_INIT_F) |
323 | misc_init_f, | 323 | misc_init_f, |
324 | #endif | 324 | #endif |
325 | INIT_FUNC_WATCHDOG_RESET | 325 | INIT_FUNC_WATCHDOG_RESET |
326 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) | 326 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) |
327 | init_func_i2c, | 327 | init_func_i2c, |
328 | #endif | 328 | #endif |
329 | #if defined(CONFIG_DTT) /* Digital Thermometers and Thermostats */ | 329 | #if defined(CONFIG_DTT) /* Digital Thermometers and Thermostats */ |
330 | dtt_init, | 330 | dtt_init, |
331 | #endif | 331 | #endif |
332 | #ifdef CONFIG_POST | 332 | #ifdef CONFIG_POST |
333 | post_init_f, | 333 | post_init_f, |
334 | #endif | 334 | #endif |
335 | INIT_FUNC_WATCHDOG_RESET | 335 | INIT_FUNC_WATCHDOG_RESET |
336 | init_func_ram, | 336 | init_func_ram, |
337 | #if defined(CFG_DRAM_TEST) | 337 | #if defined(CFG_DRAM_TEST) |
338 | testdram, | 338 | testdram, |
339 | #endif /* CFG_DRAM_TEST */ | 339 | #endif /* CFG_DRAM_TEST */ |
340 | INIT_FUNC_WATCHDOG_RESET | 340 | INIT_FUNC_WATCHDOG_RESET |
341 | 341 | ||
342 | NULL, /* Terminate this list */ | 342 | NULL, /* Terminate this list */ |
343 | }; | 343 | }; |
344 | 344 | ||
345 | /************************************************************************ | 345 | /************************************************************************ |
346 | * | 346 | * |
347 | * This is the first part of the initialization sequence that is | 347 | * This is the first part of the initialization sequence that is |
348 | * implemented in C, but still running from ROM. | 348 | * implemented in C, but still running from ROM. |
349 | * | 349 | * |
350 | * The main purpose is to provide a (serial) console interface as | 350 | * The main purpose is to provide a (serial) console interface as |
351 | * soon as possible (so we can see any error messages), and to | 351 | * soon as possible (so we can see any error messages), and to |
352 | * initialize the RAM so that we can relocate the monitor code to | 352 | * initialize the RAM so that we can relocate the monitor code to |
353 | * RAM. | 353 | * RAM. |
354 | * | 354 | * |
355 | * Be aware of the restrictions: global data is read-only, BSS is not | 355 | * Be aware of the restrictions: global data is read-only, BSS is not |
356 | * initialized, and stack space is limited to a few kB. | 356 | * initialized, and stack space is limited to a few kB. |
357 | * | 357 | * |
358 | ************************************************************************ | 358 | ************************************************************************ |
359 | */ | 359 | */ |
360 | 360 | ||
361 | void board_init_f (ulong bootflag) | 361 | void board_init_f (ulong bootflag) |
362 | { | 362 | { |
363 | bd_t *bd; | 363 | bd_t *bd; |
364 | ulong len, addr, addr_sp; | 364 | ulong len, addr, addr_sp; |
365 | ulong *s; | 365 | ulong *s; |
366 | gd_t *id; | 366 | gd_t *id; |
367 | init_fnc_t **init_fnc_ptr; | 367 | init_fnc_t **init_fnc_ptr; |
368 | #ifdef CONFIG_PRAM | 368 | #ifdef CONFIG_PRAM |
369 | int i; | 369 | int i; |
370 | ulong reg; | 370 | ulong reg; |
371 | uchar tmp[64]; /* long enough for environment variables */ | 371 | uchar tmp[64]; /* long enough for environment variables */ |
372 | #endif | 372 | #endif |
373 | 373 | ||
374 | /* Pointer is writable since we allocated a register for it */ | 374 | /* Pointer is writable since we allocated a register for it */ |
375 | gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); | 375 | gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); |
376 | /* compiler optimization barrier needed for GCC >= 3.4 */ | 376 | /* compiler optimization barrier needed for GCC >= 3.4 */ |
377 | __asm__ __volatile__("": : :"memory"); | 377 | __asm__ __volatile__("": : :"memory"); |
378 | 378 | ||
379 | #if !defined(CONFIG_CPM2) | 379 | #if !defined(CONFIG_CPM2) |
380 | /* Clear initial global data */ | 380 | /* Clear initial global data */ |
381 | memset ((void *) gd, 0, sizeof (gd_t)); | 381 | memset ((void *) gd, 0, sizeof (gd_t)); |
382 | #endif | 382 | #endif |
383 | 383 | ||
384 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { | 384 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { |
385 | if ((*init_fnc_ptr) () != 0) { | 385 | if ((*init_fnc_ptr) () != 0) { |
386 | hang (); | 386 | hang (); |
387 | } | 387 | } |
388 | } | 388 | } |
389 | 389 | ||
390 | /* | 390 | /* |
391 | * Now that we have DRAM mapped and working, we can | 391 | * Now that we have DRAM mapped and working, we can |
392 | * relocate the code and continue running from DRAM. | 392 | * relocate the code and continue running from DRAM. |
393 | * | 393 | * |
394 | * Reserve memory at end of RAM for (top down in that order): | 394 | * Reserve memory at end of RAM for (top down in that order): |
395 | * - kernel log buffer | 395 | * - kernel log buffer |
396 | * - protected RAM | 396 | * - protected RAM |
397 | * - LCD framebuffer | 397 | * - LCD framebuffer |
398 | * - monitor code | 398 | * - monitor code |
399 | * - board info struct | 399 | * - board info struct |
400 | */ | 400 | */ |
401 | len = (ulong)&_end - CFG_MONITOR_BASE; | 401 | len = (ulong)&_end - CFG_MONITOR_BASE; |
402 | 402 | ||
403 | #ifndef CONFIG_VERY_BIG_RAM | 403 | #ifndef CONFIG_VERY_BIG_RAM |
404 | addr = CFG_SDRAM_BASE + gd->ram_size; | 404 | addr = CFG_SDRAM_BASE + gd->ram_size; |
405 | #else | 405 | #else |
406 | /* only allow stack below 256M */ | 406 | /* only allow stack below 256M */ |
407 | addr = CFG_SDRAM_BASE + | 407 | addr = CFG_SDRAM_BASE + |
408 | (gd->ram_size > 256 << 20) ? 256 << 20 : gd->ram_size; | 408 | (gd->ram_size > 256 << 20) ? 256 << 20 : gd->ram_size; |
409 | #endif | 409 | #endif |
410 | 410 | ||
411 | #ifdef CONFIG_LOGBUFFER | 411 | #ifdef CONFIG_LOGBUFFER |
412 | /* reserve kernel log buffer */ | 412 | /* reserve kernel log buffer */ |
413 | addr -= (LOGBUFF_RESERVE); | 413 | addr -= (LOGBUFF_RESERVE); |
414 | debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr); | 414 | debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr); |
415 | #endif | 415 | #endif |
416 | 416 | ||
417 | #ifdef CONFIG_PRAM | 417 | #ifdef CONFIG_PRAM |
418 | /* | 418 | /* |
419 | * reserve protected RAM | 419 | * reserve protected RAM |
420 | */ | 420 | */ |
421 | i = getenv_r ("pram", (char *)tmp, sizeof (tmp)); | 421 | i = getenv_r ("pram", (char *)tmp, sizeof (tmp)); |
422 | reg = (i > 0) ? simple_strtoul ((const char *)tmp, NULL, 10) : CONFIG_PRAM; | 422 | reg = (i > 0) ? simple_strtoul ((const char *)tmp, NULL, 10) : CONFIG_PRAM; |
423 | addr -= (reg << 10); /* size is in kB */ | 423 | addr -= (reg << 10); /* size is in kB */ |
424 | debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr); | 424 | debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr); |
425 | #endif /* CONFIG_PRAM */ | 425 | #endif /* CONFIG_PRAM */ |
426 | 426 | ||
427 | /* round down to next 4 kB limit */ | 427 | /* round down to next 4 kB limit */ |
428 | addr &= ~(4096 - 1); | 428 | addr &= ~(4096 - 1); |
429 | debug ("Top of RAM usable for U-Boot at: %08lx\n", addr); | 429 | debug ("Top of RAM usable for U-Boot at: %08lx\n", addr); |
430 | 430 | ||
431 | #ifdef CONFIG_LCD | 431 | #ifdef CONFIG_LCD |
432 | /* reserve memory for LCD display (always full pages) */ | 432 | /* reserve memory for LCD display (always full pages) */ |
433 | addr = lcd_setmem (addr); | 433 | addr = lcd_setmem (addr); |
434 | gd->fb_base = addr; | 434 | gd->fb_base = addr; |
435 | #endif /* CONFIG_LCD */ | 435 | #endif /* CONFIG_LCD */ |
436 | 436 | ||
437 | #if defined(CONFIG_VIDEO) && defined(CONFIG_8xx) | 437 | #if defined(CONFIG_VIDEO) && defined(CONFIG_8xx) |
438 | /* reserve memory for video display (always full pages) */ | 438 | /* reserve memory for video display (always full pages) */ |
439 | addr = video_setmem (addr); | 439 | addr = video_setmem (addr); |
440 | gd->fb_base = addr; | 440 | gd->fb_base = addr; |
441 | #endif /* CONFIG_VIDEO */ | 441 | #endif /* CONFIG_VIDEO */ |
442 | 442 | ||
443 | /* | 443 | /* |
444 | * reserve memory for U-Boot code, data & bss | 444 | * reserve memory for U-Boot code, data & bss |
445 | * round down to next 4 kB limit | 445 | * round down to next 4 kB limit |
446 | */ | 446 | */ |
447 | addr -= len; | 447 | addr -= len; |
448 | addr &= ~(4096 - 1); | 448 | addr &= ~(4096 - 1); |
449 | #ifdef CONFIG_E500 | 449 | #ifdef CONFIG_E500 |
450 | /* round down to next 64 kB limit so that IVPR stays aligned */ | 450 | /* round down to next 64 kB limit so that IVPR stays aligned */ |
451 | addr &= ~(65536 - 1); | 451 | addr &= ~(65536 - 1); |
452 | #endif | 452 | #endif |
453 | 453 | ||
454 | debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr); | 454 | debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr); |
455 | 455 | ||
456 | #ifdef CONFIG_AMIGAONEG3SE | 456 | #ifdef CONFIG_AMIGAONEG3SE |
457 | gd->relocaddr = addr; | 457 | gd->relocaddr = addr; |
458 | #endif | 458 | #endif |
459 | 459 | ||
460 | /* | 460 | /* |
461 | * reserve memory for malloc() arena | 461 | * reserve memory for malloc() arena |
462 | */ | 462 | */ |
463 | addr_sp = addr - TOTAL_MALLOC_LEN; | 463 | addr_sp = addr - TOTAL_MALLOC_LEN; |
464 | debug ("Reserving %dk for malloc() at: %08lx\n", | 464 | debug ("Reserving %dk for malloc() at: %08lx\n", |
465 | TOTAL_MALLOC_LEN >> 10, addr_sp); | 465 | TOTAL_MALLOC_LEN >> 10, addr_sp); |
466 | 466 | ||
467 | /* | 467 | /* |
468 | * (permanently) allocate a Board Info struct | 468 | * (permanently) allocate a Board Info struct |
469 | * and a permanent copy of the "global" data | 469 | * and a permanent copy of the "global" data |
470 | */ | 470 | */ |
471 | addr_sp -= sizeof (bd_t); | 471 | addr_sp -= sizeof (bd_t); |
472 | bd = (bd_t *) addr_sp; | 472 | bd = (bd_t *) addr_sp; |
473 | gd->bd = bd; | 473 | gd->bd = bd; |
474 | debug ("Reserving %d Bytes for Board Info at: %08lx\n", | 474 | debug ("Reserving %d Bytes for Board Info at: %08lx\n", |
475 | sizeof (bd_t), addr_sp); | 475 | sizeof (bd_t), addr_sp); |
476 | addr_sp -= sizeof (gd_t); | 476 | addr_sp -= sizeof (gd_t); |
477 | id = (gd_t *) addr_sp; | 477 | id = (gd_t *) addr_sp; |
478 | debug ("Reserving %d Bytes for Global Data at: %08lx\n", | 478 | debug ("Reserving %d Bytes for Global Data at: %08lx\n", |
479 | sizeof (gd_t), addr_sp); | 479 | sizeof (gd_t), addr_sp); |
480 | 480 | ||
481 | /* | 481 | /* |
482 | * Finally, we set up a new (bigger) stack. | 482 | * Finally, we set up a new (bigger) stack. |
483 | * | 483 | * |
484 | * Leave some safety gap for SP, force alignment on 16 byte boundary | 484 | * Leave some safety gap for SP, force alignment on 16 byte boundary |
485 | * Clear initial stack frame | 485 | * Clear initial stack frame |
486 | */ | 486 | */ |
487 | addr_sp -= 16; | 487 | addr_sp -= 16; |
488 | addr_sp &= ~0xF; | 488 | addr_sp &= ~0xF; |
489 | s = (ulong *)addr_sp; | 489 | s = (ulong *)addr_sp; |
490 | *s-- = 0; | 490 | *s-- = 0; |
491 | *s-- = 0; | 491 | *s-- = 0; |
492 | addr_sp = (ulong)s; | 492 | addr_sp = (ulong)s; |
493 | debug ("Stack Pointer at: %08lx\n", addr_sp); | 493 | debug ("Stack Pointer at: %08lx\n", addr_sp); |
494 | 494 | ||
495 | /* | 495 | /* |
496 | * Save local variables to board info struct | 496 | * Save local variables to board info struct |
497 | */ | 497 | */ |
498 | 498 | ||
499 | bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */ | 499 | bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */ |
500 | bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */ | 500 | bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */ |
501 | 501 | ||
502 | #ifdef CONFIG_IP860 | 502 | #ifdef CONFIG_IP860 |
503 | bd->bi_sramstart = SRAM_BASE; /* start of SRAM memory */ | 503 | bd->bi_sramstart = SRAM_BASE; /* start of SRAM memory */ |
504 | bd->bi_sramsize = SRAM_SIZE; /* size of SRAM memory */ | 504 | bd->bi_sramsize = SRAM_SIZE; /* size of SRAM memory */ |
505 | #elif defined CONFIG_MPC8220 | 505 | #elif defined CONFIG_MPC8220 |
506 | bd->bi_sramstart = CFG_SRAM_BASE; /* start of SRAM memory */ | 506 | bd->bi_sramstart = CFG_SRAM_BASE; /* start of SRAM memory */ |
507 | bd->bi_sramsize = CFG_SRAM_SIZE; /* size of SRAM memory */ | 507 | bd->bi_sramsize = CFG_SRAM_SIZE; /* size of SRAM memory */ |
508 | #else | 508 | #else |
509 | bd->bi_sramstart = 0; /* FIXME */ /* start of SRAM memory */ | 509 | bd->bi_sramstart = 0; /* FIXME */ /* start of SRAM memory */ |
510 | bd->bi_sramsize = 0; /* FIXME */ /* size of SRAM memory */ | 510 | bd->bi_sramsize = 0; /* FIXME */ /* size of SRAM memory */ |
511 | #endif | 511 | #endif |
512 | 512 | ||
513 | #if defined(CONFIG_8xx) || defined(CONFIG_8260) || defined(CONFIG_5xx) || \ | 513 | #if defined(CONFIG_8xx) || defined(CONFIG_8260) || defined(CONFIG_5xx) || \ |
514 | defined(CONFIG_E500) || defined(CONFIG_MPC86xx) | 514 | defined(CONFIG_E500) || defined(CONFIG_MPC86xx) |
515 | bd->bi_immr_base = CFG_IMMR; /* base of IMMR register */ | 515 | bd->bi_immr_base = CFG_IMMR; /* base of IMMR register */ |
516 | #endif | 516 | #endif |
517 | #if defined(CONFIG_MPC5xxx) | 517 | #if defined(CONFIG_MPC5xxx) |
518 | bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */ | 518 | bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */ |
519 | #endif | 519 | #endif |
520 | #if defined(CONFIG_MPC83XX) | 520 | #if defined(CONFIG_MPC83XX) |
521 | bd->bi_immrbar = CFG_IMMR; | 521 | bd->bi_immrbar = CFG_IMMR; |
522 | #endif | 522 | #endif |
523 | #if defined(CONFIG_MPC8220) | 523 | #if defined(CONFIG_MPC8220) |
524 | bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */ | 524 | bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */ |
525 | bd->bi_inpfreq = gd->inp_clk; | 525 | bd->bi_inpfreq = gd->inp_clk; |
526 | bd->bi_pcifreq = gd->pci_clk; | 526 | bd->bi_pcifreq = gd->pci_clk; |
527 | bd->bi_vcofreq = gd->vco_clk; | 527 | bd->bi_vcofreq = gd->vco_clk; |
528 | bd->bi_pevfreq = gd->pev_clk; | 528 | bd->bi_pevfreq = gd->pev_clk; |
529 | bd->bi_flbfreq = gd->flb_clk; | 529 | bd->bi_flbfreq = gd->flb_clk; |
530 | 530 | ||
531 | /* store bootparam to sram (backward compatible), here? */ | 531 | /* store bootparam to sram (backward compatible), here? */ |
532 | { | 532 | { |
533 | u32 *sram = (u32 *)CFG_SRAM_BASE; | 533 | u32 *sram = (u32 *)CFG_SRAM_BASE; |
534 | *sram++ = gd->ram_size; | 534 | *sram++ = gd->ram_size; |
535 | *sram++ = gd->bus_clk; | 535 | *sram++ = gd->bus_clk; |
536 | *sram++ = gd->inp_clk; | 536 | *sram++ = gd->inp_clk; |
537 | *sram++ = gd->cpu_clk; | 537 | *sram++ = gd->cpu_clk; |
538 | *sram++ = gd->vco_clk; | 538 | *sram++ = gd->vco_clk; |
539 | *sram++ = gd->flb_clk; | 539 | *sram++ = gd->flb_clk; |
540 | *sram++ = 0xb8c3ba11; /* boot signature */ | 540 | *sram++ = 0xb8c3ba11; /* boot signature */ |
541 | } | 541 | } |
542 | #endif | 542 | #endif |
543 | 543 | ||
544 | bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ | 544 | bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ |
545 | 545 | ||
546 | WATCHDOG_RESET (); | 546 | WATCHDOG_RESET (); |
547 | bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */ | 547 | bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */ |
548 | bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */ | 548 | bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */ |
549 | #if defined(CONFIG_CPM2) | 549 | #if defined(CONFIG_CPM2) |
550 | bd->bi_cpmfreq = gd->cpm_clk; | 550 | bd->bi_cpmfreq = gd->cpm_clk; |
551 | bd->bi_brgfreq = gd->brg_clk; | 551 | bd->bi_brgfreq = gd->brg_clk; |
552 | bd->bi_sccfreq = gd->scc_clk; | 552 | bd->bi_sccfreq = gd->scc_clk; |
553 | bd->bi_vco = gd->vco_out; | 553 | bd->bi_vco = gd->vco_out; |
554 | #endif /* CONFIG_CPM2 */ | 554 | #endif /* CONFIG_CPM2 */ |
555 | #if defined(CONFIG_MPC5xxx) | 555 | #if defined(CONFIG_MPC5xxx) |
556 | bd->bi_ipbfreq = gd->ipb_clk; | 556 | bd->bi_ipbfreq = gd->ipb_clk; |
557 | bd->bi_pcifreq = gd->pci_clk; | 557 | bd->bi_pcifreq = gd->pci_clk; |
558 | #endif /* CONFIG_MPC5xxx */ | 558 | #endif /* CONFIG_MPC5xxx */ |
559 | bd->bi_baudrate = gd->baudrate; /* Console Baudrate */ | 559 | bd->bi_baudrate = gd->baudrate; /* Console Baudrate */ |
560 | 560 | ||
561 | #ifdef CFG_EXTBDINFO | 561 | #ifdef CFG_EXTBDINFO |
562 | strncpy ((char *)bd->bi_s_version, "1.2", sizeof (bd->bi_s_version)); | 562 | strncpy ((char *)bd->bi_s_version, "1.2", sizeof (bd->bi_s_version)); |
563 | strncpy ((char *)bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version)); | 563 | strncpy ((char *)bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version)); |
564 | 564 | ||
565 | bd->bi_procfreq = gd->cpu_clk; /* Processor Speed, In Hz */ | 565 | bd->bi_procfreq = gd->cpu_clk; /* Processor Speed, In Hz */ |
566 | bd->bi_plb_busfreq = gd->bus_clk; | 566 | bd->bi_plb_busfreq = gd->bus_clk; |
567 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \ | 567 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \ |
568 | defined(CONFIG_440EP) || defined(CONFIG_440GR) || \ | 568 | defined(CONFIG_440EP) || defined(CONFIG_440GR) || \ |
569 | defined(CONFIG_440EPX) || defined(CONFIG_440GRX) | 569 | defined(CONFIG_440EPX) || defined(CONFIG_440GRX) |
570 | bd->bi_pci_busfreq = get_PCI_freq (); | 570 | bd->bi_pci_busfreq = get_PCI_freq (); |
571 | bd->bi_opbfreq = get_OPB_freq (); | 571 | bd->bi_opbfreq = get_OPB_freq (); |
572 | #elif defined(CONFIG_XILINX_ML300) | 572 | #elif defined(CONFIG_XILINX_ML300) |
573 | bd->bi_pci_busfreq = get_PCI_freq (); | 573 | bd->bi_pci_busfreq = get_PCI_freq (); |
574 | #endif | 574 | #endif |
575 | #endif | 575 | #endif |
576 | 576 | ||
577 | debug ("New Stack Pointer is: %08lx\n", addr_sp); | 577 | debug ("New Stack Pointer is: %08lx\n", addr_sp); |
578 | 578 | ||
579 | WATCHDOG_RESET (); | 579 | WATCHDOG_RESET (); |
580 | 580 | ||
581 | #ifdef CONFIG_POST | 581 | #ifdef CONFIG_POST |
582 | post_bootmode_init(); | 582 | post_bootmode_init(); |
583 | post_run (NULL, POST_ROM | post_bootmode_get(0)); | 583 | post_run (NULL, POST_ROM | post_bootmode_get(0)); |
584 | #endif | 584 | #endif |
585 | 585 | ||
586 | WATCHDOG_RESET(); | 586 | WATCHDOG_RESET(); |
587 | 587 | ||
588 | memcpy (id, (void *)gd, sizeof (gd_t)); | 588 | memcpy (id, (void *)gd, sizeof (gd_t)); |
589 | 589 | ||
590 | relocate_code (addr_sp, id, addr); | 590 | relocate_code (addr_sp, id, addr); |
591 | 591 | ||
592 | /* NOTREACHED - relocate_code() does not return */ | 592 | /* NOTREACHED - relocate_code() does not return */ |
593 | } | 593 | } |
594 | 594 | ||
595 | /************************************************************************ | 595 | /************************************************************************ |
596 | * | 596 | * |
597 | * This is the next part if the initialization sequence: we are now | 597 | * This is the next part if the initialization sequence: we are now |
598 | * running from RAM and have a "normal" C environment, i. e. global | 598 | * running from RAM and have a "normal" C environment, i. e. global |
599 | * data can be written, BSS has been cleared, the stack size in not | 599 | * data can be written, BSS has been cleared, the stack size in not |
600 | * that critical any more, etc. | 600 | * that critical any more, etc. |
601 | * | 601 | * |
602 | ************************************************************************ | 602 | ************************************************************************ |
603 | */ | 603 | */ |
604 | void board_init_r (gd_t *id, ulong dest_addr) | 604 | void board_init_r (gd_t *id, ulong dest_addr) |
605 | { | 605 | { |
606 | cmd_tbl_t *cmdtp; | 606 | cmd_tbl_t *cmdtp; |
607 | char *s, *e; | 607 | char *s, *e; |
608 | bd_t *bd; | 608 | bd_t *bd; |
609 | int i; | 609 | int i; |
610 | extern void malloc_bin_reloc (void); | 610 | extern void malloc_bin_reloc (void); |
611 | #ifndef CFG_ENV_IS_NOWHERE | 611 | #ifndef CFG_ENV_IS_NOWHERE |
612 | extern char * env_name_spec; | 612 | extern char * env_name_spec; |
613 | #endif | 613 | #endif |
614 | 614 | ||
615 | #ifndef CFG_NO_FLASH | 615 | #ifndef CFG_NO_FLASH |
616 | ulong flash_size; | 616 | ulong flash_size; |
617 | #endif | 617 | #endif |
618 | 618 | ||
619 | gd = id; /* initialize RAM version of global data */ | 619 | gd = id; /* initialize RAM version of global data */ |
620 | bd = gd->bd; | 620 | bd = gd->bd; |
621 | 621 | ||
622 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ | 622 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ |
623 | 623 | ||
624 | #if defined(CONFIG_RELOC_FIXUP_WORKS) | 624 | #if defined(CONFIG_RELOC_FIXUP_WORKS) |
625 | gd->reloc_off = 0; | 625 | gd->reloc_off = 0; |
626 | #else | 626 | #else |
627 | gd->reloc_off = dest_addr - CFG_MONITOR_BASE; | 627 | gd->reloc_off = dest_addr - CFG_MONITOR_BASE; |
628 | #endif | 628 | #endif |
629 | 629 | ||
630 | #ifdef CONFIG_SERIAL_MULTI | 630 | #ifdef CONFIG_SERIAL_MULTI |
631 | serial_initialize(); | 631 | serial_initialize(); |
632 | #endif | 632 | #endif |
633 | 633 | ||
634 | debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr); | 634 | debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr); |
635 | 635 | ||
636 | WATCHDOG_RESET (); | 636 | WATCHDOG_RESET (); |
637 | 637 | ||
638 | #if defined(CONFIG_BOARD_EARLY_INIT_R) | 638 | #if defined(CONFIG_BOARD_EARLY_INIT_R) |
639 | board_early_init_r (); | 639 | board_early_init_r (); |
640 | #endif | 640 | #endif |
641 | 641 | ||
642 | monitor_flash_len = (ulong)&__init_end - dest_addr; | 642 | monitor_flash_len = (ulong)&__init_end - dest_addr; |
643 | 643 | ||
644 | /* | 644 | /* |
645 | * We have to relocate the command table manually | 645 | * We have to relocate the command table manually |
646 | */ | 646 | */ |
647 | for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { | 647 | for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { |
648 | ulong addr; | 648 | ulong addr; |
649 | addr = (ulong) (cmdtp->cmd) + gd->reloc_off; | 649 | addr = (ulong) (cmdtp->cmd) + gd->reloc_off; |
650 | #if 0 | 650 | #if 0 |
651 | printf ("Command \"%s\": 0x%08lx => 0x%08lx\n", | 651 | printf ("Command \"%s\": 0x%08lx => 0x%08lx\n", |
652 | cmdtp->name, (ulong) (cmdtp->cmd), addr); | 652 | cmdtp->name, (ulong) (cmdtp->cmd), addr); |
653 | #endif | 653 | #endif |
654 | cmdtp->cmd = | 654 | cmdtp->cmd = |
655 | (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; | 655 | (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; |
656 | 656 | ||
657 | addr = (ulong)(cmdtp->name) + gd->reloc_off; | 657 | addr = (ulong)(cmdtp->name) + gd->reloc_off; |
658 | cmdtp->name = (char *)addr; | 658 | cmdtp->name = (char *)addr; |
659 | 659 | ||
660 | if (cmdtp->usage) { | 660 | if (cmdtp->usage) { |
661 | addr = (ulong)(cmdtp->usage) + gd->reloc_off; | 661 | addr = (ulong)(cmdtp->usage) + gd->reloc_off; |
662 | cmdtp->usage = (char *)addr; | 662 | cmdtp->usage = (char *)addr; |
663 | } | 663 | } |
664 | #ifdef CFG_LONGHELP | 664 | #ifdef CFG_LONGHELP |
665 | if (cmdtp->help) { | 665 | if (cmdtp->help) { |
666 | addr = (ulong)(cmdtp->help) + gd->reloc_off; | 666 | addr = (ulong)(cmdtp->help) + gd->reloc_off; |
667 | cmdtp->help = (char *)addr; | 667 | cmdtp->help = (char *)addr; |
668 | } | 668 | } |
669 | #endif | 669 | #endif |
670 | } | 670 | } |
671 | /* there are some other pointer constants we must deal with */ | 671 | /* there are some other pointer constants we must deal with */ |
672 | #ifndef CFG_ENV_IS_NOWHERE | 672 | #ifndef CFG_ENV_IS_NOWHERE |
673 | env_name_spec += gd->reloc_off; | 673 | env_name_spec += gd->reloc_off; |
674 | #endif | 674 | #endif |
675 | 675 | ||
676 | WATCHDOG_RESET (); | 676 | WATCHDOG_RESET (); |
677 | 677 | ||
678 | #ifdef CONFIG_LOGBUFFER | 678 | #ifdef CONFIG_LOGBUFFER |
679 | logbuff_init_ptrs (); | 679 | logbuff_init_ptrs (); |
680 | #endif | 680 | #endif |
681 | #ifdef CONFIG_POST | 681 | #ifdef CONFIG_POST |
682 | post_output_backlog (); | 682 | post_output_backlog (); |
683 | post_reloc (); | 683 | post_reloc (); |
684 | #endif | 684 | #endif |
685 | 685 | ||
686 | WATCHDOG_RESET(); | 686 | WATCHDOG_RESET(); |
687 | 687 | ||
688 | #if defined(CONFIG_IP860) || defined(CONFIG_PCU_E) || \ | 688 | #if defined(CONFIG_IP860) || defined(CONFIG_PCU_E) || \ |
689 | defined (CONFIG_FLAGADM) || defined(CONFIG_MPC83XX) | 689 | defined (CONFIG_FLAGADM) || defined(CONFIG_MPC83XX) |
690 | icache_enable (); /* it's time to enable the instruction cache */ | 690 | icache_enable (); /* it's time to enable the instruction cache */ |
691 | #endif | 691 | #endif |
692 | 692 | ||
693 | #if defined(CFG_INIT_RAM_LOCK) && defined(CONFIG_E500) | 693 | #if defined(CFG_INIT_RAM_LOCK) && defined(CONFIG_E500) |
694 | unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */ | 694 | unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */ |
695 | #endif | 695 | #endif |
696 | 696 | ||
697 | #if defined(CONFIG_BAB7xx) || defined(CONFIG_CPC45) | 697 | #if defined(CONFIG_BAB7xx) || defined(CONFIG_CPC45) |
698 | /* | 698 | /* |
699 | * Do PCI configuration on BAB7xx and CPC45 _before_ the flash | 699 | * Do PCI configuration on BAB7xx and CPC45 _before_ the flash |
700 | * gets initialised, because we need the ISA resp. PCI_to_LOCAL bus | 700 | * gets initialised, because we need the ISA resp. PCI_to_LOCAL bus |
701 | * bridge there. | 701 | * bridge there. |
702 | */ | 702 | */ |
703 | pci_init (); | 703 | pci_init (); |
704 | #endif | 704 | #endif |
705 | #if defined(CONFIG_BAB7xx) | 705 | #if defined(CONFIG_BAB7xx) |
706 | /* | 706 | /* |
707 | * Initialise the ISA bridge | 707 | * Initialise the ISA bridge |
708 | */ | 708 | */ |
709 | initialise_w83c553f (); | 709 | initialise_w83c553f (); |
710 | #endif | 710 | #endif |
711 | 711 | ||
712 | asm ("sync ; isync"); | 712 | asm ("sync ; isync"); |
713 | 713 | ||
714 | /* | 714 | /* |
715 | * Setup trap handlers | 715 | * Setup trap handlers |
716 | */ | 716 | */ |
717 | trap_init (dest_addr); | 717 | trap_init (dest_addr); |
718 | 718 | ||
719 | #if !defined(CFG_NO_FLASH) | 719 | #if !defined(CFG_NO_FLASH) |
720 | puts ("FLASH: "); | 720 | puts ("FLASH: "); |
721 | 721 | ||
722 | if ((flash_size = flash_init ()) > 0) { | 722 | if ((flash_size = flash_init ()) > 0) { |
723 | # ifdef CFG_FLASH_CHECKSUM | 723 | # ifdef CFG_FLASH_CHECKSUM |
724 | print_size (flash_size, ""); | 724 | print_size (flash_size, ""); |
725 | /* | 725 | /* |
726 | * Compute and print flash CRC if flashchecksum is set to 'y' | 726 | * Compute and print flash CRC if flashchecksum is set to 'y' |
727 | * | 727 | * |
728 | * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX | 728 | * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX |
729 | */ | 729 | */ |
730 | s = getenv ("flashchecksum"); | 730 | s = getenv ("flashchecksum"); |
731 | if (s && (*s == 'y')) { | 731 | if (s && (*s == 'y')) { |
732 | printf (" CRC: %08lX", | 732 | printf (" CRC: %08lX", |
733 | crc32 (0, (const unsigned char *) CFG_FLASH_BASE, flash_size) | 733 | crc32 (0, (const unsigned char *) CFG_FLASH_BASE, flash_size) |
734 | ); | 734 | ); |
735 | } | 735 | } |
736 | putc ('\n'); | 736 | putc ('\n'); |
737 | # else /* !CFG_FLASH_CHECKSUM */ | 737 | # else /* !CFG_FLASH_CHECKSUM */ |
738 | print_size (flash_size, "\n"); | 738 | print_size (flash_size, "\n"); |
739 | # endif /* CFG_FLASH_CHECKSUM */ | 739 | # endif /* CFG_FLASH_CHECKSUM */ |
740 | } else { | 740 | } else { |
741 | puts (failed); | 741 | puts (failed); |
742 | hang (); | 742 | hang (); |
743 | } | 743 | } |
744 | 744 | ||
745 | bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */ | 745 | bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */ |
746 | bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ | 746 | bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ |
747 | 747 | ||
748 | #if defined(CFG_UPDATE_FLASH_SIZE) | 748 | #if defined(CFG_UPDATE_FLASH_SIZE) |
749 | /* Make a update of the Memctrl. */ | 749 | /* Make a update of the Memctrl. */ |
750 | update_flash_size (flash_size); | 750 | update_flash_size (flash_size); |
751 | #endif | 751 | #endif |
752 | 752 | ||
753 | 753 | ||
754 | # if defined(CONFIG_PCU_E) || defined(CONFIG_OXC) || defined(CONFIG_RMU) | 754 | # if defined(CONFIG_PCU_E) || defined(CONFIG_OXC) || defined(CONFIG_RMU) |
755 | /* flash mapped at end of memory map */ | 755 | /* flash mapped at end of memory map */ |
756 | bd->bi_flashoffset = TEXT_BASE + flash_size; | 756 | bd->bi_flashoffset = TEXT_BASE + flash_size; |
757 | # elif CFG_MONITOR_BASE == CFG_FLASH_BASE | 757 | # elif CFG_MONITOR_BASE == CFG_FLASH_BASE |
758 | bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor */ | 758 | bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor */ |
759 | # else | 759 | # else |
760 | bd->bi_flashoffset = 0; | 760 | bd->bi_flashoffset = 0; |
761 | # endif | 761 | # endif |
762 | #else /* CFG_NO_FLASH */ | 762 | #else /* CFG_NO_FLASH */ |
763 | 763 | ||
764 | bd->bi_flashsize = 0; | 764 | bd->bi_flashsize = 0; |
765 | bd->bi_flashstart = 0; | 765 | bd->bi_flashstart = 0; |
766 | bd->bi_flashoffset = 0; | 766 | bd->bi_flashoffset = 0; |
767 | #endif /* !CFG_NO_FLASH */ | 767 | #endif /* !CFG_NO_FLASH */ |
768 | 768 | ||
769 | WATCHDOG_RESET (); | 769 | WATCHDOG_RESET (); |
770 | 770 | ||
771 | /* initialize higher level parts of CPU like time base and timers */ | 771 | /* initialize higher level parts of CPU like time base and timers */ |
772 | cpu_init_r (); | 772 | cpu_init_r (); |
773 | 773 | ||
774 | WATCHDOG_RESET (); | 774 | WATCHDOG_RESET (); |
775 | 775 | ||
776 | /* initialize malloc() area */ | 776 | /* initialize malloc() area */ |
777 | mem_malloc_init (); | 777 | mem_malloc_init (); |
778 | malloc_bin_reloc (); | 778 | malloc_bin_reloc (); |
779 | 779 | ||
780 | #ifdef CONFIG_SPI | 780 | #ifdef CONFIG_SPI |
781 | # if !defined(CFG_ENV_IS_IN_EEPROM) | 781 | # if !defined(CFG_ENV_IS_IN_EEPROM) |
782 | spi_init_f (); | 782 | spi_init_f (); |
783 | # endif | 783 | # endif |
784 | spi_init_r (); | 784 | spi_init_r (); |
785 | #endif | 785 | #endif |
786 | 786 | ||
787 | #if (CONFIG_COMMANDS & CFG_CMD_NAND) || defined(CONFIG_CMD_NAND) | 787 | #if defined(CONFIG_CMD_NAND) |
788 | WATCHDOG_RESET (); | 788 | WATCHDOG_RESET (); |
789 | puts ("NAND: "); | 789 | puts ("NAND: "); |
790 | nand_init(); /* go init the NAND */ | 790 | nand_init(); /* go init the NAND */ |
791 | #endif | 791 | #endif |
792 | 792 | ||
793 | /* relocate environment function pointers etc. */ | 793 | /* relocate environment function pointers etc. */ |
794 | env_relocate (); | 794 | env_relocate (); |
795 | 795 | ||
796 | /* | 796 | /* |
797 | * Fill in missing fields of bd_info. | 797 | * Fill in missing fields of bd_info. |
798 | * We do this here, where we have "normal" access to the | 798 | * We do this here, where we have "normal" access to the |
799 | * environment; we used to do this still running from ROM, | 799 | * environment; we used to do this still running from ROM, |
800 | * where had to use getenv_r(), which can be pretty slow when | 800 | * where had to use getenv_r(), which can be pretty slow when |
801 | * the environment is in EEPROM. | 801 | * the environment is in EEPROM. |
802 | */ | 802 | */ |
803 | 803 | ||
804 | #if defined(CFG_EXTBDINFO) | 804 | #if defined(CFG_EXTBDINFO) |
805 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) | 805 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) |
806 | #if defined(CONFIG_I2CFAST) | 806 | #if defined(CONFIG_I2CFAST) |
807 | /* | 807 | /* |
808 | * set bi_iic_fast for linux taking environment variable | 808 | * set bi_iic_fast for linux taking environment variable |
809 | * "i2cfast" into account | 809 | * "i2cfast" into account |
810 | */ | 810 | */ |
811 | { | 811 | { |
812 | char *s = getenv ("i2cfast"); | 812 | char *s = getenv ("i2cfast"); |
813 | if (s && ((*s == 'y') || (*s == 'Y'))) { | 813 | if (s && ((*s == 'y') || (*s == 'Y'))) { |
814 | bd->bi_iic_fast[0] = 1; | 814 | bd->bi_iic_fast[0] = 1; |
815 | bd->bi_iic_fast[1] = 1; | 815 | bd->bi_iic_fast[1] = 1; |
816 | } else { | 816 | } else { |
817 | bd->bi_iic_fast[0] = 0; | 817 | bd->bi_iic_fast[0] = 0; |
818 | bd->bi_iic_fast[1] = 0; | 818 | bd->bi_iic_fast[1] = 0; |
819 | } | 819 | } |
820 | } | 820 | } |
821 | #else | 821 | #else |
822 | bd->bi_iic_fast[0] = 0; | 822 | bd->bi_iic_fast[0] = 0; |
823 | bd->bi_iic_fast[1] = 0; | 823 | bd->bi_iic_fast[1] = 0; |
824 | #endif /* CONFIG_I2CFAST */ | 824 | #endif /* CONFIG_I2CFAST */ |
825 | #endif /* CONFIG_405GP, CONFIG_405EP */ | 825 | #endif /* CONFIG_405GP, CONFIG_405EP */ |
826 | #endif /* CFG_EXTBDINFO */ | 826 | #endif /* CFG_EXTBDINFO */ |
827 | 827 | ||
828 | #if defined(CONFIG_SC3) | 828 | #if defined(CONFIG_SC3) |
829 | sc3_read_eeprom(); | 829 | sc3_read_eeprom(); |
830 | #endif | 830 | #endif |
831 | s = getenv ("ethaddr"); | 831 | s = getenv ("ethaddr"); |
832 | #if defined (CONFIG_MBX) || \ | 832 | #if defined (CONFIG_MBX) || \ |
833 | defined (CONFIG_RPXCLASSIC) || \ | 833 | defined (CONFIG_RPXCLASSIC) || \ |
834 | defined(CONFIG_IAD210) || \ | 834 | defined(CONFIG_IAD210) || \ |
835 | defined(CONFIG_V38B) | 835 | defined(CONFIG_V38B) |
836 | if (s == NULL) | 836 | if (s == NULL) |
837 | board_get_enetaddr (bd->bi_enetaddr); | 837 | board_get_enetaddr (bd->bi_enetaddr); |
838 | else | 838 | else |
839 | #endif | 839 | #endif |
840 | for (i = 0; i < 6; ++i) { | 840 | for (i = 0; i < 6; ++i) { |
841 | bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0; | 841 | bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0; |
842 | if (s) | 842 | if (s) |
843 | s = (*e) ? e + 1 : e; | 843 | s = (*e) ? e + 1 : e; |
844 | } | 844 | } |
845 | #ifdef CONFIG_HERMES | 845 | #ifdef CONFIG_HERMES |
846 | if ((gd->board_type >> 16) == 2) | 846 | if ((gd->board_type >> 16) == 2) |
847 | bd->bi_ethspeed = gd->board_type & 0xFFFF; | 847 | bd->bi_ethspeed = gd->board_type & 0xFFFF; |
848 | else | 848 | else |
849 | bd->bi_ethspeed = 0xFFFF; | 849 | bd->bi_ethspeed = 0xFFFF; |
850 | #endif | 850 | #endif |
851 | 851 | ||
852 | #ifdef CONFIG_NX823 | 852 | #ifdef CONFIG_NX823 |
853 | load_sernum_ethaddr (); | 853 | load_sernum_ethaddr (); |
854 | #endif | 854 | #endif |
855 | 855 | ||
856 | #ifdef CONFIG_HAS_ETH1 | 856 | #ifdef CONFIG_HAS_ETH1 |
857 | /* handle the 2nd ethernet address */ | 857 | /* handle the 2nd ethernet address */ |
858 | 858 | ||
859 | s = getenv ("eth1addr"); | 859 | s = getenv ("eth1addr"); |
860 | 860 | ||
861 | for (i = 0; i < 6; ++i) { | 861 | for (i = 0; i < 6; ++i) { |
862 | bd->bi_enet1addr[i] = s ? simple_strtoul (s, &e, 16) : 0; | 862 | bd->bi_enet1addr[i] = s ? simple_strtoul (s, &e, 16) : 0; |
863 | if (s) | 863 | if (s) |
864 | s = (*e) ? e + 1 : e; | 864 | s = (*e) ? e + 1 : e; |
865 | } | 865 | } |
866 | #endif | 866 | #endif |
867 | #ifdef CONFIG_HAS_ETH2 | 867 | #ifdef CONFIG_HAS_ETH2 |
868 | /* handle the 3rd ethernet address */ | 868 | /* handle the 3rd ethernet address */ |
869 | 869 | ||
870 | s = getenv ("eth2addr"); | 870 | s = getenv ("eth2addr"); |
871 | #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF) | 871 | #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF) |
872 | if (s == NULL) | 872 | if (s == NULL) |
873 | board_get_enetaddr(bd->bi_enet2addr); | 873 | board_get_enetaddr(bd->bi_enet2addr); |
874 | else | 874 | else |
875 | #endif | 875 | #endif |
876 | for (i = 0; i < 6; ++i) { | 876 | for (i = 0; i < 6; ++i) { |
877 | bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0; | 877 | bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0; |
878 | if (s) | 878 | if (s) |
879 | s = (*e) ? e + 1 : e; | 879 | s = (*e) ? e + 1 : e; |
880 | } | 880 | } |
881 | #endif | 881 | #endif |
882 | 882 | ||
883 | #ifdef CONFIG_HAS_ETH3 | 883 | #ifdef CONFIG_HAS_ETH3 |
884 | /* handle 4th ethernet address */ | 884 | /* handle 4th ethernet address */ |
885 | s = getenv("eth3addr"); | 885 | s = getenv("eth3addr"); |
886 | #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF) | 886 | #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF) |
887 | if (s == NULL) | 887 | if (s == NULL) |
888 | board_get_enetaddr(bd->bi_enet3addr); | 888 | board_get_enetaddr(bd->bi_enet3addr); |
889 | else | 889 | else |
890 | #endif | 890 | #endif |
891 | for (i = 0; i < 6; ++i) { | 891 | for (i = 0; i < 6; ++i) { |
892 | bd->bi_enet3addr[i] = s ? simple_strtoul (s, &e, 16) : 0; | 892 | bd->bi_enet3addr[i] = s ? simple_strtoul (s, &e, 16) : 0; |
893 | if (s) | 893 | if (s) |
894 | s = (*e) ? e + 1 : e; | 894 | s = (*e) ? e + 1 : e; |
895 | } | 895 | } |
896 | #endif | 896 | #endif |
897 | 897 | ||
898 | #ifdef CFG_ID_EEPROM | 898 | #ifdef CFG_ID_EEPROM |
899 | mac_read_from_eeprom(); | 899 | mac_read_from_eeprom(); |
900 | #endif | 900 | #endif |
901 | 901 | ||
902 | #if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \ | 902 | #if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \ |
903 | defined(CONFIG_TQM8272) || \ | 903 | defined(CONFIG_TQM8272) || \ |
904 | defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X) | 904 | defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X) |
905 | load_sernum_ethaddr (); | 905 | load_sernum_ethaddr (); |
906 | #endif | 906 | #endif |
907 | /* IP Address */ | 907 | /* IP Address */ |
908 | bd->bi_ip_addr = getenv_IPaddr ("ipaddr"); | 908 | bd->bi_ip_addr = getenv_IPaddr ("ipaddr"); |
909 | 909 | ||
910 | WATCHDOG_RESET (); | 910 | WATCHDOG_RESET (); |
911 | 911 | ||
912 | #if defined(CONFIG_PCI) && !defined(CONFIG_BAB7xx) && !defined(CONFIG_CPC45) | 912 | #if defined(CONFIG_PCI) && !defined(CONFIG_BAB7xx) && !defined(CONFIG_CPC45) |
913 | /* | 913 | /* |
914 | * Do pci configuration | 914 | * Do pci configuration |
915 | */ | 915 | */ |
916 | pci_init (); | 916 | pci_init (); |
917 | #endif | 917 | #endif |
918 | 918 | ||
919 | /** leave this here (after malloc(), environment and PCI are working) **/ | 919 | /** leave this here (after malloc(), environment and PCI are working) **/ |
920 | /* Initialize devices */ | 920 | /* Initialize devices */ |
921 | devices_init (); | 921 | devices_init (); |
922 | 922 | ||
923 | /* Initialize the jump table for applications */ | 923 | /* Initialize the jump table for applications */ |
924 | jumptable_init (); | 924 | jumptable_init (); |
925 | 925 | ||
926 | /* Initialize the console (after the relocation and devices init) */ | 926 | /* Initialize the console (after the relocation and devices init) */ |
927 | console_init_r (); | 927 | console_init_r (); |
928 | 928 | ||
929 | #if defined(CONFIG_CCM) || \ | 929 | #if defined(CONFIG_CCM) || \ |
930 | defined(CONFIG_COGENT) || \ | 930 | defined(CONFIG_COGENT) || \ |
931 | defined(CONFIG_CPCI405) || \ | 931 | defined(CONFIG_CPCI405) || \ |
932 | defined(CONFIG_EVB64260) || \ | 932 | defined(CONFIG_EVB64260) || \ |
933 | defined(CONFIG_KUP4K) || \ | 933 | defined(CONFIG_KUP4K) || \ |
934 | defined(CONFIG_KUP4X) || \ | 934 | defined(CONFIG_KUP4X) || \ |
935 | defined(CONFIG_LWMON) || \ | 935 | defined(CONFIG_LWMON) || \ |
936 | defined(CONFIG_PCU_E) || \ | 936 | defined(CONFIG_PCU_E) || \ |
937 | defined(CONFIG_SC3) || \ | 937 | defined(CONFIG_SC3) || \ |
938 | defined(CONFIG_W7O) || \ | 938 | defined(CONFIG_W7O) || \ |
939 | defined(CONFIG_MISC_INIT_R) | 939 | defined(CONFIG_MISC_INIT_R) |
940 | /* miscellaneous platform dependent initialisations */ | 940 | /* miscellaneous platform dependent initialisations */ |
941 | misc_init_r (); | 941 | misc_init_r (); |
942 | #endif | 942 | #endif |
943 | 943 | ||
944 | #ifdef CONFIG_HERMES | 944 | #ifdef CONFIG_HERMES |
945 | if (bd->bi_ethspeed != 0xFFFF) | 945 | if (bd->bi_ethspeed != 0xFFFF) |
946 | hermes_start_lxt980 ((int) bd->bi_ethspeed); | 946 | hermes_start_lxt980 ((int) bd->bi_ethspeed); |
947 | #endif | 947 | #endif |
948 | 948 | ||
949 | #if (CONFIG_COMMANDS & CFG_CMD_KGDB) || defined(CONFIG_CMD_KGDB) | 949 | #if defined(CONFIG_CMD_KGDB) |
950 | WATCHDOG_RESET (); | 950 | WATCHDOG_RESET (); |
951 | puts ("KGDB: "); | 951 | puts ("KGDB: "); |
952 | kgdb_init (); | 952 | kgdb_init (); |
953 | #endif | 953 | #endif |
954 | 954 | ||
955 | debug ("U-Boot relocated to %08lx\n", dest_addr); | 955 | debug ("U-Boot relocated to %08lx\n", dest_addr); |
956 | 956 | ||
957 | /* | 957 | /* |
958 | * Enable Interrupts | 958 | * Enable Interrupts |
959 | */ | 959 | */ |
960 | interrupt_init (); | 960 | interrupt_init (); |
961 | 961 | ||
962 | /* Must happen after interrupts are initialized since | 962 | /* Must happen after interrupts are initialized since |
963 | * an irq handler gets installed | 963 | * an irq handler gets installed |
964 | */ | 964 | */ |
965 | #ifdef CONFIG_SERIAL_SOFTWARE_FIFO | 965 | #ifdef CONFIG_SERIAL_SOFTWARE_FIFO |
966 | serial_buffered_init(); | 966 | serial_buffered_init(); |
967 | #endif | 967 | #endif |
968 | 968 | ||
969 | #ifdef CONFIG_STATUS_LED | 969 | #ifdef CONFIG_STATUS_LED |
970 | status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING); | 970 | status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING); |
971 | #endif | 971 | #endif |
972 | 972 | ||
973 | udelay (20); | 973 | udelay (20); |
974 | 974 | ||
975 | set_timer (0); | 975 | set_timer (0); |
976 | 976 | ||
977 | /* Initialize from environment */ | 977 | /* Initialize from environment */ |
978 | if ((s = getenv ("loadaddr")) != NULL) { | 978 | if ((s = getenv ("loadaddr")) != NULL) { |
979 | load_addr = simple_strtoul (s, NULL, 16); | 979 | load_addr = simple_strtoul (s, NULL, 16); |
980 | } | 980 | } |
981 | #if (CONFIG_COMMANDS & CFG_CMD_NET) || defined(CONFIG_CMD_NET) | 981 | #if defined(CONFIG_CMD_NET) |
982 | if ((s = getenv ("bootfile")) != NULL) { | 982 | if ((s = getenv ("bootfile")) != NULL) { |
983 | copy_filename (BootFile, s, sizeof (BootFile)); | 983 | copy_filename (BootFile, s, sizeof (BootFile)); |
984 | } | 984 | } |
985 | #endif /* CFG_CMD_NET */ | 985 | #endif /* CFG_CMD_NET */ |
986 | 986 | ||
987 | WATCHDOG_RESET (); | 987 | WATCHDOG_RESET (); |
988 | 988 | ||
989 | #if (CONFIG_COMMANDS & CFG_CMD_SCSI) || defined(CONFIG_CMD_SCSI) | 989 | #if defined(CONFIG_CMD_SCSI) |
990 | WATCHDOG_RESET (); | 990 | WATCHDOG_RESET (); |
991 | puts ("SCSI: "); | 991 | puts ("SCSI: "); |
992 | scsi_init (); | 992 | scsi_init (); |
993 | #endif | 993 | #endif |
994 | 994 | ||
995 | #if (CONFIG_COMMANDS & CFG_CMD_DOC) || defined(CONFIG_CMD_DOC) | 995 | #if defined(CONFIG_CMD_DOC) |
996 | WATCHDOG_RESET (); | 996 | WATCHDOG_RESET (); |
997 | puts ("DOC: "); | 997 | puts ("DOC: "); |
998 | doc_init (); | 998 | doc_init (); |
999 | #endif | 999 | #endif |
1000 | 1000 | ||
1001 | #if (CONFIG_COMMANDS & CFG_CMD_NET) || defined(CONFIG_CMD_NET) | 1001 | #if defined(CONFIG_CMD_NET) |
1002 | #if defined(CONFIG_NET_MULTI) | 1002 | #if defined(CONFIG_NET_MULTI) |
1003 | WATCHDOG_RESET (); | 1003 | WATCHDOG_RESET (); |
1004 | puts ("Net: "); | 1004 | puts ("Net: "); |
1005 | #endif | 1005 | #endif |
1006 | eth_initialize (bd); | 1006 | eth_initialize (bd); |
1007 | #endif | 1007 | #endif |
1008 | 1008 | ||
1009 | #if ((CONFIG_COMMANDS & CFG_CMD_NET) || defined(CONFIG_CMD_NET)) && ( \ | 1009 | #if defined(CONFIG_CMD_NET) && ( \ |
1010 | defined(CONFIG_CCM) || \ | 1010 | defined(CONFIG_CCM) || \ |
1011 | defined(CONFIG_ELPT860) || \ | 1011 | defined(CONFIG_ELPT860) || \ |
1012 | defined(CONFIG_EP8260) || \ | 1012 | defined(CONFIG_EP8260) || \ |
1013 | defined(CONFIG_IP860) || \ | 1013 | defined(CONFIG_IP860) || \ |
1014 | defined(CONFIG_IVML24) || \ | 1014 | defined(CONFIG_IVML24) || \ |
1015 | defined(CONFIG_IVMS8) || \ | 1015 | defined(CONFIG_IVMS8) || \ |
1016 | defined(CONFIG_MPC8260ADS) || \ | 1016 | defined(CONFIG_MPC8260ADS) || \ |
1017 | defined(CONFIG_MPC8266ADS) || \ | 1017 | defined(CONFIG_MPC8266ADS) || \ |
1018 | defined(CONFIG_MPC8560ADS) || \ | 1018 | defined(CONFIG_MPC8560ADS) || \ |
1019 | defined(CONFIG_PCU_E) || \ | 1019 | defined(CONFIG_PCU_E) || \ |
1020 | defined(CONFIG_RPXSUPER) || \ | 1020 | defined(CONFIG_RPXSUPER) || \ |
1021 | defined(CONFIG_STXGP3) || \ | 1021 | defined(CONFIG_STXGP3) || \ |
1022 | defined(CONFIG_SPD823TS) || \ | 1022 | defined(CONFIG_SPD823TS) || \ |
1023 | defined(CONFIG_RESET_PHY_R) ) | 1023 | defined(CONFIG_RESET_PHY_R) ) |
1024 | 1024 | ||
1025 | WATCHDOG_RESET (); | 1025 | WATCHDOG_RESET (); |
1026 | debug ("Reset Ethernet PHY\n"); | 1026 | debug ("Reset Ethernet PHY\n"); |
1027 | reset_phy (); | 1027 | reset_phy (); |
1028 | #endif | 1028 | #endif |
1029 | 1029 | ||
1030 | #ifdef CONFIG_POST | 1030 | #ifdef CONFIG_POST |
1031 | post_run (NULL, POST_RAM | post_bootmode_get(0)); | 1031 | post_run (NULL, POST_RAM | post_bootmode_get(0)); |
1032 | #endif | 1032 | #endif |
1033 | 1033 | ||
1034 | #if ((CONFIG_COMMANDS & CFG_CMD_PCMCIA) || defined(CONFIG_CMD_PCMCIA)) \ | 1034 | #if defined(CONFIG_CMD_PCMCIA) \ |
1035 | && !((CONFIG_COMMANDS & CFG_CMD_IDE) || defined(CONFIG_CMD_IDE)) | 1035 | && !defined(CONFIG_CMD_IDE) |
1036 | WATCHDOG_RESET (); | 1036 | WATCHDOG_RESET (); |
1037 | puts ("PCMCIA:"); | 1037 | puts ("PCMCIA:"); |
1038 | pcmcia_init (); | 1038 | pcmcia_init (); |
1039 | #endif | 1039 | #endif |
1040 | 1040 | ||
1041 | #if (CONFIG_COMMANDS & CFG_CMD_IDE) || defined(CONFIG_CMD_IDE) | 1041 | #if defined(CONFIG_CMD_IDE) |
1042 | WATCHDOG_RESET (); | 1042 | WATCHDOG_RESET (); |
1043 | # ifdef CONFIG_IDE_8xx_PCCARD | 1043 | # ifdef CONFIG_IDE_8xx_PCCARD |
1044 | puts ("PCMCIA:"); | 1044 | puts ("PCMCIA:"); |
1045 | # else | 1045 | # else |
1046 | puts ("IDE: "); | 1046 | puts ("IDE: "); |
1047 | #endif | 1047 | #endif |
1048 | #if defined(CONFIG_START_IDE) | 1048 | #if defined(CONFIG_START_IDE) |
1049 | if (board_start_ide()) | 1049 | if (board_start_ide()) |
1050 | ide_init (); | 1050 | ide_init (); |
1051 | #else | 1051 | #else |
1052 | ide_init (); | 1052 | ide_init (); |
1053 | #endif | 1053 | #endif |
1054 | #endif /* CFG_CMD_IDE */ | 1054 | #endif /* CFG_CMD_IDE */ |
1055 | 1055 | ||
1056 | #ifdef CONFIG_LAST_STAGE_INIT | 1056 | #ifdef CONFIG_LAST_STAGE_INIT |
1057 | WATCHDOG_RESET (); | 1057 | WATCHDOG_RESET (); |
1058 | /* | 1058 | /* |
1059 | * Some parts can be only initialized if all others (like | 1059 | * Some parts can be only initialized if all others (like |
1060 | * Interrupts) are up and running (i.e. the PC-style ISA | 1060 | * Interrupts) are up and running (i.e. the PC-style ISA |
1061 | * keyboard). | 1061 | * keyboard). |
1062 | */ | 1062 | */ |
1063 | last_stage_init (); | 1063 | last_stage_init (); |
1064 | #endif | 1064 | #endif |
1065 | 1065 | ||
1066 | #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG) || defined(CONFIG_CMD_BEDBUG) | 1066 | #if defined(CONFIG_CMD_BEDBUG) |
1067 | WATCHDOG_RESET (); | 1067 | WATCHDOG_RESET (); |
1068 | bedbug_init (); | 1068 | bedbug_init (); |
1069 | #endif | 1069 | #endif |
1070 | 1070 | ||
1071 | #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) | 1071 | #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) |
1072 | /* | 1072 | /* |
1073 | * Export available size of memory for Linux, | 1073 | * Export available size of memory for Linux, |
1074 | * taking into account the protected RAM at top of memory | 1074 | * taking into account the protected RAM at top of memory |
1075 | */ | 1075 | */ |
1076 | { | 1076 | { |
1077 | ulong pram; | 1077 | ulong pram; |
1078 | uchar memsz[32]; | 1078 | uchar memsz[32]; |
1079 | #ifdef CONFIG_PRAM | 1079 | #ifdef CONFIG_PRAM |
1080 | char *s; | 1080 | char *s; |
1081 | 1081 | ||
1082 | if ((s = getenv ("pram")) != NULL) { | 1082 | if ((s = getenv ("pram")) != NULL) { |
1083 | pram = simple_strtoul (s, NULL, 10); | 1083 | pram = simple_strtoul (s, NULL, 10); |
1084 | } else { | 1084 | } else { |
1085 | pram = CONFIG_PRAM; | 1085 | pram = CONFIG_PRAM; |
1086 | } | 1086 | } |
1087 | #else | 1087 | #else |
1088 | pram=0; | 1088 | pram=0; |
1089 | #endif | 1089 | #endif |
1090 | #ifdef CONFIG_LOGBUFFER | 1090 | #ifdef CONFIG_LOGBUFFER |
1091 | /* Also take the logbuffer into account (pram is in kB) */ | 1091 | /* Also take the logbuffer into account (pram is in kB) */ |
1092 | pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024; | 1092 | pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024; |
1093 | #endif | 1093 | #endif |
1094 | sprintf ((char *)memsz, "%ldk", (bd->bi_memsize / 1024) - pram); | 1094 | sprintf ((char *)memsz, "%ldk", (bd->bi_memsize / 1024) - pram); |
1095 | setenv ("mem", (char *)memsz); | 1095 | setenv ("mem", (char *)memsz); |
1096 | } | 1096 | } |
1097 | #endif | 1097 | #endif |
1098 | 1098 | ||
1099 | #ifdef CONFIG_PS2KBD | 1099 | #ifdef CONFIG_PS2KBD |
1100 | puts ("PS/2: "); | 1100 | puts ("PS/2: "); |
1101 | kbd_init(); | 1101 | kbd_init(); |
1102 | #endif | 1102 | #endif |
1103 | 1103 | ||
1104 | #ifdef CONFIG_MODEM_SUPPORT | 1104 | #ifdef CONFIG_MODEM_SUPPORT |
1105 | { | 1105 | { |
1106 | extern int do_mdm_init; | 1106 | extern int do_mdm_init; |
1107 | do_mdm_init = gd->do_mdm_init; | 1107 | do_mdm_init = gd->do_mdm_init; |
1108 | } | 1108 | } |
1109 | #endif | 1109 | #endif |
1110 | 1110 | ||
1111 | /* Initialization complete - start the monitor */ | 1111 | /* Initialization complete - start the monitor */ |
1112 | 1112 | ||
1113 | /* main_loop() can return to retry autoboot, if so just run it again. */ | 1113 | /* main_loop() can return to retry autoboot, if so just run it again. */ |
1114 | for (;;) { | 1114 | for (;;) { |
1115 | WATCHDOG_RESET (); | 1115 | WATCHDOG_RESET (); |
1116 | main_loop (); | 1116 | main_loop (); |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | /* NOTREACHED - no way out of command loop except booting */ | 1119 | /* NOTREACHED - no way out of command loop except booting */ |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | void hang (void) | 1122 | void hang (void) |
1123 | { | 1123 | { |
1124 | puts ("### ERROR ### Please RESET the board ###\n"); | 1124 | puts ("### ERROR ### Please RESET the board ###\n"); |
1125 | #ifdef CONFIG_SHOW_BOOT_PROGRESS | 1125 | #ifdef CONFIG_SHOW_BOOT_PROGRESS |
1126 | show_boot_progress(-30); | 1126 | show_boot_progress(-30); |
1127 | #endif | 1127 | #endif |
1128 | for (;;); | 1128 | for (;;); |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | #ifdef CONFIG_MODEM_SUPPORT | 1131 | #ifdef CONFIG_MODEM_SUPPORT |
1132 | /* called from main loop (common/main.c) */ | 1132 | /* called from main loop (common/main.c) */ |
1133 | /* 'inline' - We have to do it fast */ | 1133 | /* 'inline' - We have to do it fast */ |
1134 | static inline void mdm_readline(char *buf, int bufsiz) | 1134 | static inline void mdm_readline(char *buf, int bufsiz) |
1135 | { | 1135 | { |
1136 | char c; | 1136 | char c; |
1137 | char *p; | 1137 | char *p; |
1138 | int n; | 1138 | int n; |
1139 | 1139 | ||
1140 | n = 0; | 1140 | n = 0; |
1141 | p = buf; | 1141 | p = buf; |
1142 | for(;;) { | 1142 | for(;;) { |
1143 | c = serial_getc(); | 1143 | c = serial_getc(); |
1144 | 1144 | ||
1145 | /* dbg("(%c)", c); */ | 1145 | /* dbg("(%c)", c); */ |
1146 | 1146 | ||
1147 | switch(c) { | 1147 | switch(c) { |
1148 | case '\r': | 1148 | case '\r': |
1149 | break; | 1149 | break; |
1150 | case '\n': | 1150 | case '\n': |
1151 | *p = '\0'; | 1151 | *p = '\0'; |
1152 | return; | 1152 | return; |
1153 | 1153 | ||
1154 | default: | 1154 | default: |
1155 | if(n++ > bufsiz) { | 1155 | if(n++ > bufsiz) { |
1156 | *p = '\0'; | 1156 | *p = '\0'; |
1157 | return; /* sanity check */ | 1157 | return; /* sanity check */ |
1158 | } | 1158 | } |
1159 | *p = c; | 1159 | *p = c; |
1160 | p++; | 1160 | p++; |
1161 | break; | 1161 | break; |
1162 | } | 1162 | } |
1163 | } | 1163 | } |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | extern void dbg(const char *fmt, ...); | 1166 | extern void dbg(const char *fmt, ...); |
1167 | int mdm_init (void) | 1167 | int mdm_init (void) |
1168 | { | 1168 | { |
1169 | char env_str[16]; | 1169 | char env_str[16]; |
1170 | char *init_str; | 1170 | char *init_str; |
1171 | int i; | 1171 | int i; |
1172 | extern char console_buffer[]; | 1172 | extern char console_buffer[]; |
1173 | extern void enable_putc(void); | 1173 | extern void enable_putc(void); |
1174 | extern int hwflow_onoff(int); | 1174 | extern int hwflow_onoff(int); |
1175 | 1175 | ||
1176 | enable_putc(); /* enable serial_putc() */ | 1176 | enable_putc(); /* enable serial_putc() */ |
1177 | 1177 | ||
1178 | #ifdef CONFIG_HWFLOW | 1178 | #ifdef CONFIG_HWFLOW |
1179 | init_str = getenv("mdm_flow_control"); | 1179 | init_str = getenv("mdm_flow_control"); |
1180 | if (init_str && (strcmp(init_str, "rts/cts") == 0)) | 1180 | if (init_str && (strcmp(init_str, "rts/cts") == 0)) |
1181 | hwflow_onoff (1); | 1181 | hwflow_onoff (1); |
1182 | else | 1182 | else |
1183 | hwflow_onoff(-1); | 1183 | hwflow_onoff(-1); |
1184 | #endif | 1184 | #endif |
1185 | 1185 | ||
1186 | for (i = 1;;i++) { | 1186 | for (i = 1;;i++) { |
1187 | sprintf(env_str, "mdm_init%d", i); | 1187 | sprintf(env_str, "mdm_init%d", i); |
1188 | if ((init_str = getenv(env_str)) != NULL) { | 1188 | if ((init_str = getenv(env_str)) != NULL) { |
1189 | serial_puts(init_str); | 1189 | serial_puts(init_str); |
1190 | serial_puts("\n"); | 1190 | serial_puts("\n"); |
1191 | for(;;) { | 1191 | for(;;) { |
1192 | mdm_readline(console_buffer, CFG_CBSIZE); | 1192 | mdm_readline(console_buffer, CFG_CBSIZE); |
1193 | dbg("ini%d: [%s]", i, console_buffer); | 1193 | dbg("ini%d: [%s]", i, console_buffer); |
1194 | 1194 | ||
1195 | if ((strcmp(console_buffer, "OK") == 0) || | 1195 | if ((strcmp(console_buffer, "OK") == 0) || |
1196 | (strcmp(console_buffer, "ERROR") == 0)) { | 1196 | (strcmp(console_buffer, "ERROR") == 0)) { |
1197 | dbg("ini%d: cmd done", i); | 1197 | dbg("ini%d: cmd done", i); |
1198 | break; | 1198 | break; |
1199 | } else /* in case we are originating call ... */ | 1199 | } else /* in case we are originating call ... */ |
1200 | if (strncmp(console_buffer, "CONNECT", 7) == 0) { | 1200 | if (strncmp(console_buffer, "CONNECT", 7) == 0) { |
1201 | dbg("ini%d: connect", i); | 1201 | dbg("ini%d: connect", i); |
1202 | return 0; | 1202 | return 0; |
1203 | } | 1203 | } |
1204 | } | 1204 | } |
1205 | } else | 1205 | } else |
1206 | break; /* no init string - stop modem init */ | 1206 | break; /* no init string - stop modem init */ |
1207 | 1207 | ||
1208 | udelay(100000); | 1208 | udelay(100000); |
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | udelay(100000); | 1211 | udelay(100000); |
1212 | 1212 | ||
1213 | /* final stage - wait for connect */ | 1213 | /* final stage - wait for connect */ |
1214 | for(;i > 1;) { /* if 'i' > 1 - wait for connection | 1214 | for(;i > 1;) { /* if 'i' > 1 - wait for connection |
1215 | message from modem */ | 1215 | message from modem */ |
1216 | mdm_readline(console_buffer, CFG_CBSIZE); | 1216 | mdm_readline(console_buffer, CFG_CBSIZE); |
1217 | dbg("ini_f: [%s]", console_buffer); | 1217 | dbg("ini_f: [%s]", console_buffer); |
1218 | if (strncmp(console_buffer, "CONNECT", 7) == 0) { | 1218 | if (strncmp(console_buffer, "CONNECT", 7) == 0) { |
1219 | dbg("ini_f: connected"); | 1219 | dbg("ini_f: connected"); |
1220 | return 0; | 1220 | return 0; |
1221 | } | 1221 | } |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | return 0; | 1224 | return 0; |
1225 | } | 1225 | } |
1226 | 1226 | ||
1227 | #endif | 1227 | #endif |
1228 | 1228 | ||
1229 | #if 0 /* We could use plain global data, but the resulting code is bigger */ | 1229 | #if 0 /* We could use plain global data, but the resulting code is bigger */ |
1230 | /* | 1230 | /* |
1231 | * Pointer to initial global data area | 1231 | * Pointer to initial global data area |
1232 | * | 1232 | * |
1233 | * Here we initialize it. | 1233 | * Here we initialize it. |
1234 | */ | 1234 | */ |
1235 | #undef XTRN_DECLARE_GLOBAL_DATA_PTR | 1235 | #undef XTRN_DECLARE_GLOBAL_DATA_PTR |
1236 | #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */ | 1236 | #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */ |
1237 | DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); | 1237 | DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); |
1238 | #endif /* 0 */ | 1238 | #endif /* 0 */ |
1239 | 1239 | ||
1240 | /************************************************************************/ | 1240 | /************************************************************************/ |
1241 | 1241 |
lib_ppc/kgdb.c
1 | #include <common.h> | 1 | #include <common.h> |
2 | #include <command.h> | 2 | #include <command.h> |
3 | 3 | ||
4 | #if (CONFIG_COMMANDS & CFG_CMD_KGDB) || defined(CONFIG_CMD_KGDB) | 4 | #if defined(CONFIG_CMD_KGDB) |
5 | 5 | ||
6 | #include <kgdb.h> | 6 | #include <kgdb.h> |
7 | #include <asm/signal.h> | 7 | #include <asm/signal.h> |
8 | #include <asm/processor.h> | 8 | #include <asm/processor.h> |
9 | 9 | ||
10 | #define PC_REGNUM 64 | 10 | #define PC_REGNUM 64 |
11 | #define SP_REGNUM 1 | 11 | #define SP_REGNUM 1 |
12 | 12 | ||
13 | void breakinst(void); | 13 | void breakinst(void); |
14 | 14 | ||
15 | int | 15 | int |
16 | kgdb_setjmp(long *buf) | 16 | kgdb_setjmp(long *buf) |
17 | { | 17 | { |
18 | asm ("mflr 0; stw 0,0(%0);" | 18 | asm ("mflr 0; stw 0,0(%0);" |
19 | "stw 1,4(%0); stw 2,8(%0);" | 19 | "stw 1,4(%0); stw 2,8(%0);" |
20 | "mfcr 0; stw 0,12(%0);" | 20 | "mfcr 0; stw 0,12(%0);" |
21 | "stmw 13,16(%0)" | 21 | "stmw 13,16(%0)" |
22 | : : "r" (buf)); | 22 | : : "r" (buf)); |
23 | /* XXX should save fp regs as well */ | 23 | /* XXX should save fp regs as well */ |
24 | return 0; | 24 | return 0; |
25 | } | 25 | } |
26 | 26 | ||
27 | void | 27 | void |
28 | kgdb_longjmp(long *buf, int val) | 28 | kgdb_longjmp(long *buf, int val) |
29 | { | 29 | { |
30 | if (val == 0) | 30 | if (val == 0) |
31 | val = 1; | 31 | val = 1; |
32 | asm ("lmw 13,16(%0);" | 32 | asm ("lmw 13,16(%0);" |
33 | "lwz 0,12(%0); mtcrf 0x38,0;" | 33 | "lwz 0,12(%0); mtcrf 0x38,0;" |
34 | "lwz 0,0(%0); lwz 1,4(%0); lwz 2,8(%0);" | 34 | "lwz 0,0(%0); lwz 1,4(%0); lwz 2,8(%0);" |
35 | "mtlr 0; mr 3,%1" | 35 | "mtlr 0; mr 3,%1" |
36 | : : "r" (buf), "r" (val)); | 36 | : : "r" (buf), "r" (val)); |
37 | } | 37 | } |
38 | 38 | ||
39 | static inline unsigned long | 39 | static inline unsigned long |
40 | get_msr(void) | 40 | get_msr(void) |
41 | { | 41 | { |
42 | unsigned long msr; | 42 | unsigned long msr; |
43 | asm volatile("mfmsr %0" : "=r" (msr):); | 43 | asm volatile("mfmsr %0" : "=r" (msr):); |
44 | return msr; | 44 | return msr; |
45 | } | 45 | } |
46 | 46 | ||
47 | static inline void | 47 | static inline void |
48 | set_msr(unsigned long msr) | 48 | set_msr(unsigned long msr) |
49 | { | 49 | { |
50 | asm volatile("mtmsr %0" : : "r" (msr)); | 50 | asm volatile("mtmsr %0" : : "r" (msr)); |
51 | } | 51 | } |
52 | 52 | ||
53 | /* Convert the SPARC hardware trap type code to a unix signal number. */ | 53 | /* Convert the SPARC hardware trap type code to a unix signal number. */ |
54 | /* | 54 | /* |
55 | * This table contains the mapping between PowerPC hardware trap types, and | 55 | * This table contains the mapping between PowerPC hardware trap types, and |
56 | * signals, which are primarily what GDB understands. | 56 | * signals, which are primarily what GDB understands. |
57 | */ | 57 | */ |
58 | static struct hard_trap_info | 58 | static struct hard_trap_info |
59 | { | 59 | { |
60 | unsigned int tt; /* Trap type code for powerpc */ | 60 | unsigned int tt; /* Trap type code for powerpc */ |
61 | unsigned char signo; /* Signal that we map this trap into */ | 61 | unsigned char signo; /* Signal that we map this trap into */ |
62 | } hard_trap_info[] = { | 62 | } hard_trap_info[] = { |
63 | { 0x200, SIGSEGV }, /* machine check */ | 63 | { 0x200, SIGSEGV }, /* machine check */ |
64 | { 0x300, SIGSEGV }, /* address error (store) */ | 64 | { 0x300, SIGSEGV }, /* address error (store) */ |
65 | { 0x400, SIGBUS }, /* instruction bus error */ | 65 | { 0x400, SIGBUS }, /* instruction bus error */ |
66 | { 0x500, SIGINT }, /* interrupt */ | 66 | { 0x500, SIGINT }, /* interrupt */ |
67 | { 0x600, SIGBUS }, /* alingment */ | 67 | { 0x600, SIGBUS }, /* alingment */ |
68 | { 0x700, SIGTRAP }, /* breakpoint trap */ | 68 | { 0x700, SIGTRAP }, /* breakpoint trap */ |
69 | { 0x800, SIGFPE }, /* fpu unavail */ | 69 | { 0x800, SIGFPE }, /* fpu unavail */ |
70 | { 0x900, SIGALRM }, /* decrementer */ | 70 | { 0x900, SIGALRM }, /* decrementer */ |
71 | { 0xa00, SIGILL }, /* reserved */ | 71 | { 0xa00, SIGILL }, /* reserved */ |
72 | { 0xb00, SIGILL }, /* reserved */ | 72 | { 0xb00, SIGILL }, /* reserved */ |
73 | { 0xc00, SIGCHLD }, /* syscall */ | 73 | { 0xc00, SIGCHLD }, /* syscall */ |
74 | { 0xd00, SIGTRAP }, /* single-step/watch */ | 74 | { 0xd00, SIGTRAP }, /* single-step/watch */ |
75 | { 0xe00, SIGFPE }, /* fp assist */ | 75 | { 0xe00, SIGFPE }, /* fp assist */ |
76 | { 0, 0} /* Must be last */ | 76 | { 0, 0} /* Must be last */ |
77 | }; | 77 | }; |
78 | 78 | ||
79 | static int | 79 | static int |
80 | computeSignal(unsigned int tt) | 80 | computeSignal(unsigned int tt) |
81 | { | 81 | { |
82 | struct hard_trap_info *ht; | 82 | struct hard_trap_info *ht; |
83 | 83 | ||
84 | for (ht = hard_trap_info; ht->tt && ht->signo; ht++) | 84 | for (ht = hard_trap_info; ht->tt && ht->signo; ht++) |
85 | if (ht->tt == tt) | 85 | if (ht->tt == tt) |
86 | return ht->signo; | 86 | return ht->signo; |
87 | 87 | ||
88 | return SIGHUP; /* default for things we don't know about */ | 88 | return SIGHUP; /* default for things we don't know about */ |
89 | } | 89 | } |
90 | 90 | ||
91 | void | 91 | void |
92 | kgdb_enter(struct pt_regs *regs, kgdb_data *kdp) | 92 | kgdb_enter(struct pt_regs *regs, kgdb_data *kdp) |
93 | { | 93 | { |
94 | unsigned long msr; | 94 | unsigned long msr; |
95 | 95 | ||
96 | kdp->private[0] = msr = get_msr(); | 96 | kdp->private[0] = msr = get_msr(); |
97 | set_msr(msr & ~MSR_EE); /* disable interrupts */ | 97 | set_msr(msr & ~MSR_EE); /* disable interrupts */ |
98 | 98 | ||
99 | if (regs->nip == (unsigned long)breakinst) { | 99 | if (regs->nip == (unsigned long)breakinst) { |
100 | /* Skip over breakpoint trap insn */ | 100 | /* Skip over breakpoint trap insn */ |
101 | regs->nip += 4; | 101 | regs->nip += 4; |
102 | } | 102 | } |
103 | regs->msr &= ~MSR_SE; | 103 | regs->msr &= ~MSR_SE; |
104 | 104 | ||
105 | /* reply to host that an exception has occurred */ | 105 | /* reply to host that an exception has occurred */ |
106 | kdp->sigval = computeSignal(regs->trap); | 106 | kdp->sigval = computeSignal(regs->trap); |
107 | 107 | ||
108 | kdp->nregs = 2; | 108 | kdp->nregs = 2; |
109 | 109 | ||
110 | kdp->regs[0].num = PC_REGNUM; | 110 | kdp->regs[0].num = PC_REGNUM; |
111 | kdp->regs[0].val = regs->nip; | 111 | kdp->regs[0].val = regs->nip; |
112 | 112 | ||
113 | kdp->regs[1].num = SP_REGNUM; | 113 | kdp->regs[1].num = SP_REGNUM; |
114 | kdp->regs[1].val = regs->gpr[SP_REGNUM]; | 114 | kdp->regs[1].val = regs->gpr[SP_REGNUM]; |
115 | } | 115 | } |
116 | 116 | ||
117 | void | 117 | void |
118 | kgdb_exit(struct pt_regs *regs, kgdb_data *kdp) | 118 | kgdb_exit(struct pt_regs *regs, kgdb_data *kdp) |
119 | { | 119 | { |
120 | unsigned long msr = kdp->private[0]; | 120 | unsigned long msr = kdp->private[0]; |
121 | 121 | ||
122 | if (kdp->extype & KGDBEXIT_WITHADDR) | 122 | if (kdp->extype & KGDBEXIT_WITHADDR) |
123 | regs->nip = kdp->exaddr; | 123 | regs->nip = kdp->exaddr; |
124 | 124 | ||
125 | switch (kdp->extype & KGDBEXIT_TYPEMASK) { | 125 | switch (kdp->extype & KGDBEXIT_TYPEMASK) { |
126 | 126 | ||
127 | case KGDBEXIT_KILL: | 127 | case KGDBEXIT_KILL: |
128 | case KGDBEXIT_CONTINUE: | 128 | case KGDBEXIT_CONTINUE: |
129 | set_msr(msr); | 129 | set_msr(msr); |
130 | break; | 130 | break; |
131 | 131 | ||
132 | case KGDBEXIT_SINGLE: | 132 | case KGDBEXIT_SINGLE: |
133 | regs->msr |= MSR_SE; | 133 | regs->msr |= MSR_SE; |
134 | #if 0 | 134 | #if 0 |
135 | set_msr(msr | MSR_SE); | 135 | set_msr(msr | MSR_SE); |
136 | #endif | 136 | #endif |
137 | break; | 137 | break; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | int | 141 | int |
142 | kgdb_trap(struct pt_regs *regs) | 142 | kgdb_trap(struct pt_regs *regs) |
143 | { | 143 | { |
144 | return (regs->trap); | 144 | return (regs->trap); |
145 | } | 145 | } |
146 | 146 | ||
147 | /* return the value of the CPU registers. | 147 | /* return the value of the CPU registers. |
148 | * some of them are non-PowerPC names :( | 148 | * some of them are non-PowerPC names :( |
149 | * they are stored in gdb like: | 149 | * they are stored in gdb like: |
150 | * struct { | 150 | * struct { |
151 | * u32 gpr[32]; | 151 | * u32 gpr[32]; |
152 | * f64 fpr[32]; | 152 | * f64 fpr[32]; |
153 | * u32 pc, ps, cnd, lr; (ps=msr) | 153 | * u32 pc, ps, cnd, lr; (ps=msr) |
154 | * u32 cnt, xer, mq; | 154 | * u32 cnt, xer, mq; |
155 | * } | 155 | * } |
156 | */ | 156 | */ |
157 | 157 | ||
158 | #define SPACE_REQUIRED ((32*4)+(32*8)+(6*4)) | 158 | #define SPACE_REQUIRED ((32*4)+(32*8)+(6*4)) |
159 | 159 | ||
160 | #ifdef CONFIG_8260 | 160 | #ifdef CONFIG_8260 |
161 | /* store floating double indexed */ | 161 | /* store floating double indexed */ |
162 | #define STFDI(n,p) __asm__ __volatile__ ("stfd " #n ",%0" : "=o"(p[2*n])) | 162 | #define STFDI(n,p) __asm__ __volatile__ ("stfd " #n ",%0" : "=o"(p[2*n])) |
163 | /* store floating double multiple */ | 163 | /* store floating double multiple */ |
164 | #define STFDM(p) { STFDI( 0,p); STFDI( 1,p); STFDI( 2,p); STFDI( 3,p); \ | 164 | #define STFDM(p) { STFDI( 0,p); STFDI( 1,p); STFDI( 2,p); STFDI( 3,p); \ |
165 | STFDI( 4,p); STFDI( 5,p); STFDI( 6,p); STFDI( 7,p); \ | 165 | STFDI( 4,p); STFDI( 5,p); STFDI( 6,p); STFDI( 7,p); \ |
166 | STFDI( 8,p); STFDI( 9,p); STFDI(10,p); STFDI(11,p); \ | 166 | STFDI( 8,p); STFDI( 9,p); STFDI(10,p); STFDI(11,p); \ |
167 | STFDI(12,p); STFDI(13,p); STFDI(14,p); STFDI(15,p); \ | 167 | STFDI(12,p); STFDI(13,p); STFDI(14,p); STFDI(15,p); \ |
168 | STFDI(16,p); STFDI(17,p); STFDI(18,p); STFDI(19,p); \ | 168 | STFDI(16,p); STFDI(17,p); STFDI(18,p); STFDI(19,p); \ |
169 | STFDI(20,p); STFDI(21,p); STFDI(22,p); STFDI(23,p); \ | 169 | STFDI(20,p); STFDI(21,p); STFDI(22,p); STFDI(23,p); \ |
170 | STFDI(24,p); STFDI(25,p); STFDI(26,p); STFDI(27,p); \ | 170 | STFDI(24,p); STFDI(25,p); STFDI(26,p); STFDI(27,p); \ |
171 | STFDI(28,p); STFDI(29,p); STFDI(30,p); STFDI(31,p); } | 171 | STFDI(28,p); STFDI(29,p); STFDI(30,p); STFDI(31,p); } |
172 | #endif | 172 | #endif |
173 | 173 | ||
174 | int | 174 | int |
175 | kgdb_getregs(struct pt_regs *regs, char *buf, int max) | 175 | kgdb_getregs(struct pt_regs *regs, char *buf, int max) |
176 | { | 176 | { |
177 | int i; | 177 | int i; |
178 | unsigned long *ptr = (unsigned long *)buf; | 178 | unsigned long *ptr = (unsigned long *)buf; |
179 | 179 | ||
180 | if (max < SPACE_REQUIRED) | 180 | if (max < SPACE_REQUIRED) |
181 | kgdb_error(KGDBERR_NOSPACE); | 181 | kgdb_error(KGDBERR_NOSPACE); |
182 | 182 | ||
183 | if ((unsigned long)ptr & 3) | 183 | if ((unsigned long)ptr & 3) |
184 | kgdb_error(KGDBERR_ALIGNFAULT); | 184 | kgdb_error(KGDBERR_ALIGNFAULT); |
185 | 185 | ||
186 | /* General Purpose Regs */ | 186 | /* General Purpose Regs */ |
187 | for (i = 0; i < 32; i++) | 187 | for (i = 0; i < 32; i++) |
188 | *ptr++ = regs->gpr[i]; | 188 | *ptr++ = regs->gpr[i]; |
189 | 189 | ||
190 | /* Floating Point Regs */ | 190 | /* Floating Point Regs */ |
191 | #ifdef CONFIG_8260 | 191 | #ifdef CONFIG_8260 |
192 | STFDM(ptr); | 192 | STFDM(ptr); |
193 | ptr += 32*2; | 193 | ptr += 32*2; |
194 | #else | 194 | #else |
195 | for (i = 0; i < 32; i++) { | 195 | for (i = 0; i < 32; i++) { |
196 | *ptr++ = 0; | 196 | *ptr++ = 0; |
197 | *ptr++ = 0; | 197 | *ptr++ = 0; |
198 | } | 198 | } |
199 | #endif | 199 | #endif |
200 | 200 | ||
201 | /* pc, msr, cr, lr, ctr, xer, (mq is unused) */ | 201 | /* pc, msr, cr, lr, ctr, xer, (mq is unused) */ |
202 | *ptr++ = regs->nip; | 202 | *ptr++ = regs->nip; |
203 | *ptr++ = regs->msr; | 203 | *ptr++ = regs->msr; |
204 | *ptr++ = regs->ccr; | 204 | *ptr++ = regs->ccr; |
205 | *ptr++ = regs->link; | 205 | *ptr++ = regs->link; |
206 | *ptr++ = regs->ctr; | 206 | *ptr++ = regs->ctr; |
207 | *ptr++ = regs->xer; | 207 | *ptr++ = regs->xer; |
208 | 208 | ||
209 | return (SPACE_REQUIRED); | 209 | return (SPACE_REQUIRED); |
210 | } | 210 | } |
211 | 211 | ||
212 | /* set the value of the CPU registers */ | 212 | /* set the value of the CPU registers */ |
213 | 213 | ||
214 | #ifdef CONFIG_8260 | 214 | #ifdef CONFIG_8260 |
215 | /* load floating double */ | 215 | /* load floating double */ |
216 | #define LFD(n,v) __asm__ __volatile__ ("lfd " #n ",%0" :: "o"(v)) | 216 | #define LFD(n,v) __asm__ __volatile__ ("lfd " #n ",%0" :: "o"(v)) |
217 | /* load floating double indexed */ | 217 | /* load floating double indexed */ |
218 | #define LFDI(n,p) __asm__ __volatile__ ("lfd " #n ",%0" :: "o"((p)[2*n])) | 218 | #define LFDI(n,p) __asm__ __volatile__ ("lfd " #n ",%0" :: "o"((p)[2*n])) |
219 | /* load floating double multiple */ | 219 | /* load floating double multiple */ |
220 | #define LFDM(p) { LFDI( 0,p); LFDI( 1,p); LFDI( 2,p); LFDI( 3,p); \ | 220 | #define LFDM(p) { LFDI( 0,p); LFDI( 1,p); LFDI( 2,p); LFDI( 3,p); \ |
221 | LFDI( 4,p); LFDI( 5,p); LFDI( 6,p); LFDI( 7,p); \ | 221 | LFDI( 4,p); LFDI( 5,p); LFDI( 6,p); LFDI( 7,p); \ |
222 | LFDI( 8,p); LFDI( 9,p); LFDI(10,p); LFDI(11,p); \ | 222 | LFDI( 8,p); LFDI( 9,p); LFDI(10,p); LFDI(11,p); \ |
223 | LFDI(12,p); LFDI(13,p); LFDI(14,p); LFDI(15,p); \ | 223 | LFDI(12,p); LFDI(13,p); LFDI(14,p); LFDI(15,p); \ |
224 | LFDI(16,p); LFDI(17,p); LFDI(18,p); LFDI(19,p); \ | 224 | LFDI(16,p); LFDI(17,p); LFDI(18,p); LFDI(19,p); \ |
225 | LFDI(20,p); LFDI(21,p); LFDI(22,p); LFDI(23,p); \ | 225 | LFDI(20,p); LFDI(21,p); LFDI(22,p); LFDI(23,p); \ |
226 | LFDI(24,p); LFDI(25,p); LFDI(26,p); LFDI(27,p); \ | 226 | LFDI(24,p); LFDI(25,p); LFDI(26,p); LFDI(27,p); \ |
227 | LFDI(28,p); LFDI(29,p); LFDI(30,p); LFDI(31,p); } | 227 | LFDI(28,p); LFDI(29,p); LFDI(30,p); LFDI(31,p); } |
228 | #endif | 228 | #endif |
229 | 229 | ||
230 | void | 230 | void |
231 | kgdb_putreg(struct pt_regs *regs, int regno, char *buf, int length) | 231 | kgdb_putreg(struct pt_regs *regs, int regno, char *buf, int length) |
232 | { | 232 | { |
233 | unsigned long *ptr = (unsigned long *)buf; | 233 | unsigned long *ptr = (unsigned long *)buf; |
234 | 234 | ||
235 | if (regno < 0 || regno >= 70) | 235 | if (regno < 0 || regno >= 70) |
236 | kgdb_error(KGDBERR_BADPARAMS); | 236 | kgdb_error(KGDBERR_BADPARAMS); |
237 | else if (regno >= 32 && regno < 64) { | 237 | else if (regno >= 32 && regno < 64) { |
238 | if (length < 8) | 238 | if (length < 8) |
239 | kgdb_error(KGDBERR_NOSPACE); | 239 | kgdb_error(KGDBERR_NOSPACE); |
240 | } | 240 | } |
241 | else { | 241 | else { |
242 | if (length < 4) | 242 | if (length < 4) |
243 | kgdb_error(KGDBERR_NOSPACE); | 243 | kgdb_error(KGDBERR_NOSPACE); |
244 | } | 244 | } |
245 | 245 | ||
246 | if ((unsigned long)ptr & 3) | 246 | if ((unsigned long)ptr & 3) |
247 | kgdb_error(KGDBERR_ALIGNFAULT); | 247 | kgdb_error(KGDBERR_ALIGNFAULT); |
248 | 248 | ||
249 | if (regno >= 0 && regno < 32) | 249 | if (regno >= 0 && regno < 32) |
250 | regs->gpr[regno] = *ptr; | 250 | regs->gpr[regno] = *ptr; |
251 | else switch (regno) { | 251 | else switch (regno) { |
252 | 252 | ||
253 | #ifdef CONFIG_8260 | 253 | #ifdef CONFIG_8260 |
254 | #define caseF(n) \ | 254 | #define caseF(n) \ |
255 | case (n) + 32: LFD(n, *ptr); break; | 255 | case (n) + 32: LFD(n, *ptr); break; |
256 | 256 | ||
257 | caseF( 0) caseF( 1) caseF( 2) caseF( 3) caseF( 4) caseF( 5) caseF( 6) caseF( 7) | 257 | caseF( 0) caseF( 1) caseF( 2) caseF( 3) caseF( 4) caseF( 5) caseF( 6) caseF( 7) |
258 | caseF( 8) caseF( 9) caseF(10) caseF(11) caseF(12) caseF(13) caseF(14) caseF(15) | 258 | caseF( 8) caseF( 9) caseF(10) caseF(11) caseF(12) caseF(13) caseF(14) caseF(15) |
259 | caseF(16) caseF(17) caseF(18) caseF(19) caseF(20) caseF(21) caseF(22) caseF(23) | 259 | caseF(16) caseF(17) caseF(18) caseF(19) caseF(20) caseF(21) caseF(22) caseF(23) |
260 | caseF(24) caseF(25) caseF(26) caseF(27) caseF(28) caseF(29) caseF(30) caseF(31) | 260 | caseF(24) caseF(25) caseF(26) caseF(27) caseF(28) caseF(29) caseF(30) caseF(31) |
261 | 261 | ||
262 | #undef caseF | 262 | #undef caseF |
263 | #endif | 263 | #endif |
264 | 264 | ||
265 | case 64: regs->nip = *ptr; break; | 265 | case 64: regs->nip = *ptr; break; |
266 | case 65: regs->msr = *ptr; break; | 266 | case 65: regs->msr = *ptr; break; |
267 | case 66: regs->ccr = *ptr; break; | 267 | case 66: regs->ccr = *ptr; break; |
268 | case 67: regs->link = *ptr; break; | 268 | case 67: regs->link = *ptr; break; |
269 | case 68: regs->ctr = *ptr; break; | 269 | case 68: regs->ctr = *ptr; break; |
270 | case 69: regs->ctr = *ptr; break; | 270 | case 69: regs->ctr = *ptr; break; |
271 | 271 | ||
272 | default: | 272 | default: |
273 | kgdb_error(KGDBERR_BADPARAMS); | 273 | kgdb_error(KGDBERR_BADPARAMS); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | 276 | ||
277 | void | 277 | void |
278 | kgdb_putregs(struct pt_regs *regs, char *buf, int length) | 278 | kgdb_putregs(struct pt_regs *regs, char *buf, int length) |
279 | { | 279 | { |
280 | int i; | 280 | int i; |
281 | unsigned long *ptr = (unsigned long *)buf; | 281 | unsigned long *ptr = (unsigned long *)buf; |
282 | 282 | ||
283 | if (length < SPACE_REQUIRED) | 283 | if (length < SPACE_REQUIRED) |
284 | kgdb_error(KGDBERR_NOSPACE); | 284 | kgdb_error(KGDBERR_NOSPACE); |
285 | 285 | ||
286 | if ((unsigned long)ptr & 3) | 286 | if ((unsigned long)ptr & 3) |
287 | kgdb_error(KGDBERR_ALIGNFAULT); | 287 | kgdb_error(KGDBERR_ALIGNFAULT); |
288 | 288 | ||
289 | /* | 289 | /* |
290 | * If the stack pointer has moved, you should pray. | 290 | * If the stack pointer has moved, you should pray. |
291 | * (cause only god can help you). | 291 | * (cause only god can help you). |
292 | */ | 292 | */ |
293 | 293 | ||
294 | /* General Purpose Regs */ | 294 | /* General Purpose Regs */ |
295 | for (i = 0; i < 32; i++) | 295 | for (i = 0; i < 32; i++) |
296 | regs->gpr[i] = *ptr++; | 296 | regs->gpr[i] = *ptr++; |
297 | 297 | ||
298 | /* Floating Point Regs */ | 298 | /* Floating Point Regs */ |
299 | #ifdef CONFIG_8260 | 299 | #ifdef CONFIG_8260 |
300 | LFDM(ptr); | 300 | LFDM(ptr); |
301 | #endif | 301 | #endif |
302 | ptr += 32*2; | 302 | ptr += 32*2; |
303 | 303 | ||
304 | /* pc, msr, cr, lr, ctr, xer, (mq is unused) */ | 304 | /* pc, msr, cr, lr, ctr, xer, (mq is unused) */ |
305 | regs->nip = *ptr++; | 305 | regs->nip = *ptr++; |
306 | regs->msr = *ptr++; | 306 | regs->msr = *ptr++; |
307 | regs->ccr = *ptr++; | 307 | regs->ccr = *ptr++; |
308 | regs->link = *ptr++; | 308 | regs->link = *ptr++; |
309 | regs->ctr = *ptr++; | 309 | regs->ctr = *ptr++; |
310 | regs->xer = *ptr++; | 310 | regs->xer = *ptr++; |
311 | } | 311 | } |
312 | 312 | ||
313 | /* This function will generate a breakpoint exception. It is used at the | 313 | /* This function will generate a breakpoint exception. It is used at the |
314 | beginning of a program to sync up with a debugger and can be used | 314 | beginning of a program to sync up with a debugger and can be used |
315 | otherwise as a quick means to stop program execution and "break" into | 315 | otherwise as a quick means to stop program execution and "break" into |
316 | the debugger. */ | 316 | the debugger. */ |
317 | 317 | ||
318 | void | 318 | void |
319 | kgdb_breakpoint(int argc, char *argv[]) | 319 | kgdb_breakpoint(int argc, char *argv[]) |
320 | { | 320 | { |
321 | asm(" .globl breakinst\n\ | 321 | asm(" .globl breakinst\n\ |
322 | breakinst: .long 0x7d821008\n\ | 322 | breakinst: .long 0x7d821008\n\ |
323 | "); | 323 | "); |
324 | } | 324 | } |
325 | 325 | ||
326 | #endif /* CFG_CMD_KGDB */ | 326 | #endif /* CFG_CMD_KGDB */ |
327 | 327 |