---恢复内容开始---
1:初始化堆管理器
malloc的初始化只设置了堆的start地址和end地址、以及一个malloc_brk,uboot的堆内存管理机制重新开一个章节详解介绍;
1 #ifdef CONFIG_MEMORY_UPPER_CODE /* by scsuh */
2 mem_malloc_init (CFG_UBOOT_BASE + CFG_UBOOT_SIZE - CFG_MALLOC_LEN - CFG_STACK_SIZE);
3 #else
4 mem_malloc_init (_armboot_start - CFG_MALLOC_LEN);
5 #endif
1 static void mem_malloc_init (ulong dest_addr)
2 {
3 mem_malloc_start = dest_addr;
4 mem_malloc_end = dest_addr + CFG_MALLOC_LEN;
5 mem_malloc_brk = mem_malloc_start;
6
7 memset ((void *) mem_malloc_start, 0,
8 mem_malloc_end - mem_malloc_start);
9 }
---------------------------------------------------------------------------
2:SD/MMC的初始化:输出SD/MMC:真正执行硬件初始化的函数是 cpu_mmc_init(bis);
1 #if defined(CONFIG_X210) 2 3 #if defined(CONFIG_GENERIC_MMC) 4 puts ("SD/MMC: "); 5 ///* //lqm masked 6 mmc_exist = mmc_initialize(gd->bd); 7 if (mmc_exist != 0) 8 { 9 puts ("0 MB "); 10 } 11 //*/ 12 #endif 13 14 #if defined(CONFIG_MTD_ONENAND) 15 puts("OneNAND: "); 16 onenand_init(); 17 /*setenv("bootcmd", "onenand read c0008000 80000 380000;bootm c0008000");*/ 18 #else 19 //puts("OneNAND: (FSR layer enabled) "); 20 #endif 21 22 #if defined(CONFIG_CMD_NAND) 23 puts("NAND: "); 24 nand_init(); 25 #endif 26 27 #endif /* CONFIG_X210 */
1 int mmc_initialize(bd_t *bis)
2 {
3 struct mmc *mmc;
4 int err;
5
6 INIT_LIST_HEAD(&mmc_devices);
7 cur_dev_num = 0;
8
9 if (board_mmc_init(bis) < 0)
10 cpu_mmc_init(bis);
11
12 #if defined(DEBUG_S3C_HSMMC)
13 print_mmc_devices(',');
14 #endif
15
16 mmc = find_mmc_device(0);
17 if (mmc) {
18 err = mmc_init(mmc);
19 if (err)
20 err = mmc_init(mmc);
21 if (err) {
22 printf("Card init fail!
");
23 return err;
24 }
25 }
26 printf("%ldMB
", (mmc->capacity/(1024*1024/(1<<9))));
27 return 0;
---------------------------------------------------------------
3:env_relocate ();环境变量的重定位
1 void env_relocate (void)
2 {
3 DEBUGF ("%s[%d] offset = 0x%lx
", __FUNCTION__,__LINE__,
4 gd->reloc_off);
5
6 #ifdef CONFIG_AMIGAONEG3SE
7 enable_nvram();
8 #endif
9
10 #ifdef ENV_IS_EMBEDDED
11 /*
12 * The environment buffer is embedded with the text segment,
13 * just relocate the environment pointer
14 */
15 env_ptr = (env_t *)((ulong)env_ptr + gd->reloc_off);
16 DEBUGF ("%s[%d] embedded ENV at %p
", __FUNCTION__,__LINE__,env_ptr);
17 #else
18 /*
19 * We must allocate a buffer for the environment
20 */
21 env_ptr = (env_t *)malloc (CFG_ENV_SIZE);
22 DEBUGF ("%s[%d] malloced ENV at %p
", __FUNCTION__,__LINE__,env_ptr);
23 #endif
24
25 if (gd->env_valid == 0) {
26 #if defined(CONFIG_GTH) || defined(CFG_ENV_IS_NOWHERE) /* Environment not changable */
27 puts ("Using default environment
");
28 #else
29 puts ("*** Warning - bad CRC, using default environment
");
30 show_boot_progress (-60);
31 #endif
32 set_default_env();
33 }
34 else {
35 env_relocate_spec ();
36 }
37 gd->env_addr = (ulong)&(env_ptr->data);
38
39 #ifdef CONFIG_AMIGAONEG3SE
40 disable_nvram();
41 #endif
42 }