您的位置:首页 > 其它

u-boot第二阶段之start_armboot()函数

2012-03-29 20:13 543 查看
1、#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));

为gd_t和bd_t结构体分配内存并初始化

2、调用通用初始化函数

for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {

if ((*init_fnc_ptr)() != 0) {

hang ();

}

}

init_sequence[]是init_fnc_t 函数指针数组,这个数组包含了众多初始化函数,比如cpu_init,

board_init 等。

//init_fnc_t *init_sequence[] = {

// cpu_init, /* basic cpu dependent setup */

// board_init, /* basic board dependent setup */

// interrupt_init, /* set up exceptions */

// env_init, /* initialize environment */

// init_baudrate, /* initialze baudrate settings */

// serial_init, /* serial communications setup */

// display_banner,

// dram_init, /* configure available RAM banks */

// display_dram_config,

// NULL,

// };

3、具体设备初始化

#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 */

addr = (_bss_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);

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)

puts ("NAND: ");

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

4、环境变量初始化

环境变量在通用初始化函数里面,已经初始化一次(env_init ),这里调用env_relocate 对环

境变量进行重新定位。

/* initialize environment */

env_relocate ();

5、进入主循环

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

for (;;) {

main_loop ();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: