2 * Copyright (C) 2004-2006 Atmel Corporation
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 #include <asm/initcalls.h>
30 #include <asm/sections.h>
32 #ifndef CONFIG_IDENT_STRING
33 #define CONFIG_IDENT_STRING ""
36 DECLARE_GLOBAL_DATA_PTR;
38 const char version_string[] =
39 U_BOOT_VERSION " (" __DATE__ " - " __TIME__ ") " CONFIG_IDENT_STRING;
41 unsigned long monitor_flash_len;
44 * Begin and end of memory area for malloc(), and current "brk"
46 static unsigned long mem_malloc_start = 0;
47 static unsigned long mem_malloc_end = 0;
48 static unsigned long mem_malloc_brk = 0;
50 /* The malloc area is wherever the board wants it to be */
51 static void mem_malloc_init(void)
53 mem_malloc_start = CFG_MALLOC_START;
54 mem_malloc_end = CFG_MALLOC_END;
55 mem_malloc_brk = mem_malloc_start;
57 printf("malloc: Using memory from 0x%08lx to 0x%08lx\n",
58 mem_malloc_start, mem_malloc_end);
60 memset ((void *)mem_malloc_start, 0,
61 mem_malloc_end - mem_malloc_start);
64 void *sbrk(ptrdiff_t increment)
66 unsigned long old = mem_malloc_brk;
67 unsigned long new = old + increment;
69 if ((new < mem_malloc_start) || (new > mem_malloc_end))
76 static int init_baudrate(void)
81 i = getenv_r("baudrate", tmp, sizeof(tmp));
83 gd->baudrate = simple_strtoul(tmp, NULL, 10);
85 gd->baudrate = CONFIG_BAUDRATE;
91 static int display_banner (void)
93 printf ("\n\n%s\n\n", version_string);
94 printf ("U-Boot code: %p -> %p data: %p -> %p\n",
95 _text, _etext, _data, _end);
104 static int display_dram_config (void)
108 puts ("DRAM Configuration:\n");
110 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
111 printf ("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
112 print_size (gd->bd->bi_dram[i].size, "\n");
118 static void display_flash_config (void)
121 print_size(gd->bd->bi_flashsize, " ");
122 printf("at address 0x%08lx\n", gd->bd->bi_flashstart);
125 void start_u_boot (void)
129 /* Initialize the global data pointer */
130 memset(&gd_data, 0, sizeof(gd_data));
133 monitor_flash_len = _edata - _text;
135 /* Perform initialization sequence */
144 board_init_memories();
147 gd->bd = malloc(sizeof(bd_t));
148 memset(gd->bd, 0, sizeof(bd_t));
149 gd->bd->bi_baudrate = gd->baudrate;
150 gd->bd->bi_dram[0].start = CFG_SDRAM_BASE;
151 gd->bd->bi_dram[0].size = gd->sdram_size;
156 if (gd->bd->bi_flashsize)
157 display_flash_config();
158 if (gd->bd->bi_dram[0].size)
159 display_dram_config();
161 gd->bd->bi_boot_params = malloc(CFG_BOOTPARAMS_LEN);
162 if (!gd->bd->bi_boot_params)
163 puts("WARNING: Cannot allocate space for boot parameters\n");
165 /* initialize environment */