blob: cec49c767a64e69bb01b97b75176eb5f603a64b3 [file] [log] [blame]
/*
* Copyright Codito Technologies (www.codito.com) Aug 15 , 2005
*
* lib_arc/board.c
*
* Copyright (C)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Authors : Sandeep Patil (sandeep.patil@codito.com)
* Pradeep Sawlani (pradeep.sawlani@codito.com)
*/
#include <common.h> /* Serial functions */
#include <linux/types.h> /* ulong typedef */
#include <asm/uboot-arc.h> /* _start */
#include <asm/global_data.h> /* For global data structre */
#include <version.h>
#include <config.h>
#include <net.h>
#include <devices.h>
const char version_string[] =
U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
static int display_banner (void);
typedef int (init_fnc_t) (void);
int board_init(void);
init_fnc_t *init_sequence[] = {
cpu_init, /* cpu specific initialisations*/
board_init,
serial_init, /* serial communications setup */
env_init, /* intialise environment */
console_init_f, /* stage 1 init of console */
display_banner, /* say that we are here */
NULL,
};
/*
* Begin and End of memory area for malloc(), and current "brk"
*/
static ulong mem_malloc_start = 0;
static ulong mem_malloc_end = 0;
static ulong mem_malloc_brk = 0;
static int display_banner (void)
{
DECLARE_GLOBAL_DATA_PTR;
printf ("\n\n%s\n\n", version_string);
printf ("running at %dHZ\n", (unsigned)gd->cpu_clk);
#ifndef CONFIG_ARC_AA4_BOARD
printf ("using timer: %i\n", ARC_BOARD_TIMER);
#endif
printf ("global data pointer: 0x%x\n", (unsigned)gd);
printf ("load addr @ 0x%x\n", CONFIG_LOADADDR);
printf (".text @ 0x%x\n", TEXT_BASE);
printf (".vector @ 0x%x (0x%x bytes)\n", (unsigned)&__vector_start,
(unsigned)&__vector_end - (unsigned)&__vector_start);
printf (".data @ 0x%x (0x%x bytes)\n", (unsigned)&__data_start,
(unsigned)&__data_end - (unsigned)&__data_start);
printf (".bss @ 0x%x (0x%x bytes)\n", (unsigned)&__bss_start,
(unsigned)&__bss_end - (unsigned)&__bss_start);
return 0;
}
static void mem_malloc_init (ulong dest_addr)
{
mem_malloc_start = dest_addr;
mem_malloc_end = dest_addr + CONFIG_SYS_MALLOC_LEN;
mem_malloc_brk = mem_malloc_start;
memset ((void *) mem_malloc_start, 0,mem_malloc_end - mem_malloc_start);
printf (".heap @ 0x%x (0x%x bytes)\n", mem_malloc_start,
mem_malloc_end - mem_malloc_start);
}
void *sbrk (ptrdiff_t increment)
{
ulong old = mem_malloc_brk;
ulong new = old + increment;
if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
return (NULL);
}
mem_malloc_brk = new;
return ((void *) old);
}
#ifndef CONFIG_SYS_NO_FLASH
static void display_flash_config (ulong size)
{
puts ("Flash: ");
print_size (size, "\n");
}
#endif
unsigned round_page(unsigned x)
{
x += 0xfff;
x &= ~0xfff;
return x;
}
gd_t *global_data;
gd_t *gd;
void start_arcboot(void)
{
DECLARE_GLOBAL_DATA_PTR;
static gd_t gd_data;
static bd_t bd_data;
init_fnc_t **init_fnc_ptr;
extern void *__text_end;
//cmd_tbl_t *cmdtp;
unsigned stage = 0xf;
show_boot_progress(stage--);
dcache_disable();
gd = global_data = &gd_data;
gd->bd = &bd_data;
gd->baudrate = CONFIG_ARC_SERIAL_BAUD;
gd->cpu_clk = CONFIG_ARC_CLK;
/* frame buffer will sit after end of program */
gd->fb_base = round_page((unsigned)__text_end);
for (init_fnc_ptr = init_sequence;*init_fnc_ptr;++init_fnc_ptr) {
show_boot_progress(stage--);
if ((*init_fnc_ptr)() != 0) {
hang();
}
}
/* Setup malloc area */
#ifndef CONFIG_ARC_AA4_BOARD
mem_malloc_init((unsigned)&__bss_end);
#else
mem_malloc_init(TEXT_BASE - CONFIG_SYS_MALLOC_LEN);
#endif
#ifndef CONFIG_SYS_NO_FLASH
display_flash_config(flash_init());
#endif
env_relocate();
/*IP Address */
gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
/* MAC Address */
{
int i;
ulong reg;
char *s, *e;
uchar tmp[64];
i = getenv_r ("ethaddr", tmp, sizeof (tmp));
s = (i > 0) ? tmp : NULL;
for (reg = 0; reg < 6; ++reg) {
gd->bd->bi_enetaddr[reg] = s ? simple_strtoul (s, &e, 16) : 0;
if (s)
s = (*e) ? e + 1 : e;
}
}
devices_init(); /* get the devices list going. */
jumptable_init();
console_init_r();
#if defined(CONFIG_CMD_NET)
#if defined(CONFIG_ARC_AA4_BOARD)
eth_initialize(gd->bd);
#else
eth_init(gd->bd);
#endif
#endif
for(;;) {
main_loop();
}
}
void hang()
{
printf("please reset....\n");
for(;;);
}