UBOOT分析一

U-boot第二阶段总结来说主要可以概括为下面几点

1、硬件的初始化

2、运行环境的初始化

3、载入内核并启动内核

4、运行u-boot调试的命令机制


OK6410之 uboot 分析



void start_armboot (void)
{
init_fnc_t **init_fnc_ptr;
char *s;
#ifndef CFG_NO_FLASH
ulong size;
#endif


#if defined(CONFIG_VFD) || defined(CONFIG_LCD)
unsigned long addr;
#endif


#if defined(CONFIG_BOOT_MOVINAND)
uint *magic = (uint *) (PHYS_SDRAM_1);
#endif


/* Pointer is writable since we allocated a register for it */
#ifdef CONFIG_MEMORY_UPPER_CODE /* by scsuh */
ulong gd_base;


gd_base = CFG_UBOOT_BASE + CFG_UBOOT_SIZE - CFG_MALLOC_LEN - CFG_STACK_SIZE - sizeof(gd_t);
#ifdef CONFIG_USE_IRQ
gd_base -= (CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ);
#endif
gd = (gd_t*)gd_base;
#else
gd = (gd_t*)(_armboot_start - CFG_MALLOC_LEN - sizeof(gd_t));
#endif


/* compiler optimization barrier needed for GCC >= 3.4 */
__asm__ __volatile__("": : :"memory");


memset ((void*)gd, 0, sizeof (gd_t));
gd->bd = (bd_t*)((char*)gd - sizeof(bd_t));
memset (gd->bd, 0, sizeof (bd_t));


monitor_flash_len = _bss_start - _armboot_start;


for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
if ((*init_fnc_ptr)() != 0) {
hang ();
}
}


#ifndef CFG_NO_FLASH
/* configure available FLASH banks */
size = flash_init ();
display_flash_config (size);
#endif /* CFG_NO_FLASH */


#ifdef CONFIG_VFD
# ifndef PAGE_SIZE
#  define PAGE_SIZE 4096
# endif
/*
* reserve memory for VFD display (always full pages)
*/
/* bss_end is defined in the board-specific linker script */
addr = (_bss_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
size = vfd_setmem (addr);
gd->fb_base = addr;
#endif /* CONFIG_VFD */


#ifdef CONFIG_LCD
# ifndef PAGE_SIZE
#  define PAGE_SIZE 4096
# endif
/*
* reserve memory for LCD display (always full pages)
*/
/* bss_end is defined in the board-specific linker script */
#ifdef LCD_FRAMEBUFFER_ADDR
addr =  (void*)LCD_FRAMEBUFFER_ADDR;
#else
addr = (_bss_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
#endif
size = lcd_setmem (addr);
gd->fb_base = addr;
#endif /* CONFIG_LCD */


/* armboot_start is defined in the board-specific linker script */
#ifdef CONFIG_MEMORY_UPPER_CODE /* by scsuh */
mem_malloc_init (CFG_UBOOT_BASE + CFG_UBOOT_SIZE - CFG_MALLOC_LEN - CFG_STACK_SIZE);
#else
mem_malloc_init (_armboot_start - CFG_MALLOC_LEN);
#endif


#if defined(CONFIG_SMDK6400) || defined(CONFIG_SMDK6410) || defined(CONFIG_SMDK6430) || defined(CONFIG_SMDK2450) || defined(CONFIG_SMDK2416)


#if defined(CONFIG_NAND)


#ifdef FORLINX_DEBUG
           printf("NandFlash Information:\n");
#else
           puts ("NAND:    ");
#endif


nand_init(); /* go init the NAND */
#endif


#if defined(CONFIG_ONENAND)
puts ("OneNAND: ");
onenand_init(); /* go init the One-NAND */
#endif


#if defined(CONFIG_BOOT_MOVINAND)
puts ("SD/MMC:  ");


if ((0x24564236 == magic[0]) && (0x20764316 == magic[1])) {
printf("Boot up for burning\n");
} else {
movi_set_capacity();
movi_set_ofs(MOVI_TOTAL_BLKCNT);
movi_init();
}
#endif


#else


#if (CONFIG_COMMANDS & CFG_CMD_NAND)
puts ("NAND:    ");
nand_init(); /* go init the NAND */
#endif


#endif


#ifdef CONFIG_HAS_DATAFLASH
AT91F_DataflashInit();
dataflash_print_info();
#endif


/* initialize environment */
env_relocate ();

#ifdef CONFIG_VFD
/* must do this after the framebuffer is allocated */
drv_vfd_init();
#endif /* CONFIG_VFD */


/* IP Address */
gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr");


/* MAC Address */
{
int i;
ulong reg;
char *s, *e;
char 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;
}


#ifdef CONFIG_HAS_ETH1
i = getenv_r ("eth1addr", tmp, sizeof (tmp));
s = (i > 0) ? tmp : NULL;


for (reg = 0; reg < 6; ++reg) {
gd->bd->bi_enet1addr[reg] = s ? simple_strtoul (s, &e, 16) : 0;
if (s)
s = (*e) ? e + 1 : e;
}
#endif
}


devices_init (); /* get the devices list going. */


#ifdef CONFIG_CMC_PU2
load_sernum_ethaddr ();
#endif /* CONFIG_CMC_PU2 */


jumptable_init ();


console_init_r (); /* fully init console as a device */


#if defined(CONFIG_MISC_INIT_R)
/* miscellaneous platform dependent initialisations */
misc_init_r ();
#endif


/* enable exceptions */
enable_interrupts ();


/* Perform network card initialisation if necessary */
#ifdef CONFIG_DRIVER_CS8900
//cs8900_get_enetaddr (gd->bd->bi_enetaddr);
#endif


#if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96)
if (getenv ("ethaddr")) {
smc_set_mac_addr(gd->bd->bi_enetaddr);
}
#endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */


/* Initialize from environment */
if ((s = getenv ("loadaddr")) != NULL) {
load_addr = simple_strtoul (s, NULL, 16);
}
#if (CONFIG_COMMANDS & CFG_CMD_NET)
if ((s = getenv ("bootfile")) != NULL) {
copy_filename (BootFile, s, sizeof (BootFile));
}
#endif /* CFG_CMD_NET */


#ifdef BOARD_LATE_INIT
board_late_init ();
#endif
#if (CONFIG_COMMANDS & CFG_CMD_NET)
#if defined(CONFIG_NET_MULTI)
puts ("Net:     ");
#endif
eth_initialize(gd->bd);
#endif


    led_init();     /*led all off --forlinx add */


/* main_loop() can return to retry autoboot, if so just run it again. */
for (;;) {
main_loop ();
}


/* NOTREACHED - no way out of command loop except booting */

}



int  led_init(void)
{
    unsigned int  uConValue = readl(REG_GPMCON);
    unsigned int uDatValue = 0xFF;


    uConValue |= 0x1111;
    writel(uConValue,REG_GPMCON);
    writel(uDatValue,REG_GPMDAT);


    return 1;
}


#define readl(addr) (*(volatile unsigned int*)(addr))
#define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b))


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值