to make u-boot work for fat32 filesystem
[jz_uboot.git] / lib_avr32 / board.c
blob02c106b80ede83c7a64b31a095bbe63ec49289f9
1 /*
2 * Copyright (C) 2004-2006 Atmel Corporation
4 * See file CREDITS for list of people who contributed to this
5 * project.
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,
20 * MA 02111-1307 USA
22 #include <common.h>
23 #include <command.h>
24 #include <malloc.h>
25 #include <devices.h>
26 #include <version.h>
27 #include <net.h>
29 #include <asm/initcalls.h>
30 #include <asm/sections.h>
32 #ifndef CONFIG_IDENT_STRING
33 #define CONFIG_IDENT_STRING ""
34 #endif
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))
70 return NULL;
72 mem_malloc_brk = new;
73 return ((void *)old);
76 static int init_baudrate(void)
78 char tmp[64];
79 int i;
81 i = getenv_r("baudrate", tmp, sizeof(tmp));
82 if (i > 0) {
83 gd->baudrate = simple_strtoul(tmp, NULL, 10);
84 } else {
85 gd->baudrate = CONFIG_BAUDRATE;
87 return 0;
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);
96 return 0;
99 void hang(void)
101 for (;;) ;
104 static int display_dram_config (void)
106 int i;
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");
115 return 0;
118 static void display_flash_config (void)
120 puts ("Flash: ");
121 print_size(gd->bd->bi_flashsize, " ");
122 printf("at address 0x%08lx\n", gd->bd->bi_flashstart);
125 void start_u_boot (void)
127 gd_t gd_data;
129 /* Initialize the global data pointer */
130 memset(&gd_data, 0, sizeof(gd_data));
131 gd = &gd_data;
133 monitor_flash_len = _edata - _text;
135 /* Perform initialization sequence */
136 cpu_init();
137 timer_init();
138 env_init();
139 init_baudrate();
140 serial_init();
141 console_init_f();
142 display_banner();
144 board_init_memories();
145 mem_malloc_init();
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;
153 board_init_info();
154 flash_init();
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 */
166 env_relocate();
168 devices_init();
169 jumptable_init();
170 console_init_r();
172 for (;;) {
173 main_loop();