一、整体流程

start_amboot()函数是执行完start.S汇编文件后第一个C语言函数,完成的功能自然还是初始化的工作 。

1、全局变量指针r8设定,以及全局变量区清零

2、执行一些类初始化函数,详细见init_sequence所对应的函数

3、初始化norflash

4、初始化显示器

5、初始化堆区

6、初始化nandflash

7、环境变量重定位,详见uboot环境变量(env)初始化

8、网络设置

9、设备初始化,详见uboot的devices_init函数分析

10、函数跳转表初始化,详见uboot的jumptable_init函数分析

11、控制台初始化

12、中断使能

最终:进入main_loop

二、函数注释

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 /* Pointer is writable since we allocated a register for it */
gd = (gd_t*)(_armboot_start - CFG_MALLOC_LEN - sizeof(gd_t)); //给全局变量指针gd赋值
/* compiler optimization barrier needed for GCC >= 3.4 */
__asm__ __volatile__("": : :"memory"); //实验中这句话没什么作用 memset ((void*)gd, 0, sizeof (gd_t)); //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 (); //norflash的初始化
display_flash_config (size); //打印norflash的大小
#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 */
mem_malloc_init (_armboot_start - CFG_MALLOC_LEN); #if (CONFIG_COMMANDS & CFG_CMD_NAND) //如果定义了CFG_CMD_NAND,就
puts ("NAND: ");//打印nand信息
nand_init(); //进行nand 初始化
#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地址并填充gd结构体变量  /* 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) {//读取环境变量loadaddr到全局变量load_addr中
load_addr = simple_strtoul (s, NULL, 16);
}
#if (CONFIG_COMMANDS & CFG_CMD_NET)
if ((s = getenv ("bootfile")) != NULL) {//读取环境变量bootfile到全局变量BootFile中
        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
/* 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 */
}

start_amboot()函数分析的更多相关文章

  1. split(),preg_split()与explode()函数分析与介

    split(),preg_split()与explode()函数分析与介 发布时间:2013-06-01 18:32:45   来源:尔玉毕业设计   评论:0 点击:965 split()函数可以实 ...

  2. string函数分析

    string函数分析string函数包含在string.c文件中,经常被C文件使用.1. strcpy函数原型: char* strcpy(char* str1,char* str2);函数功能: 把 ...

  3. uboot的jumptable_init函数分析

    一.函数说明 函数功能:安装系统函数指针 函数位置:common/exports.c 二.函数分析 void jumptable_init (void) { int i; gd->jt = (v ...

  4. Linux-0.11内核源代码分析系列:内存管理get_free_page()函数分析

    Linux-0.11内存管理模块是源码中比較难以理解的部分,如今把笔者个人的理解发表 先发Linux-0.11内核内存管理get_free_page()函数分析 有时间再写其它函数或者文件的:) /* ...

  5. 31.QPainter-rotate()函数分析-文字旋转不倾斜,图片旋转实现等待

    在上章和上上上章: 28.QT-QPainter介绍 30.QT-渐变之QLinearGradient. QConicalGradient.QRadialGradient 学习了QPainter基础绘 ...

  6. 如何验证一个地址可否使用—— MmIsAddressValid函数分析

    又是一篇内核函数分析的博文,我个人觉得Windows的内核是最好的老师,当你想实现一个功能之前可以看看Windows内核是怎么做的,说不定就有灵感呢:) 首先看下官方的注释说明: /*++ Routi ...

  7. STM32F10X固件库函数——串口清状态位函数分析

    STM32F10X固件库函数——串口清状态位函数分析 最近在测试串口热插拔功能的时候,意外发现STM32F10X的串口库函数中,清理串口状态位函数稍稍有点不解.下面是改函数的源码: /******** ...

  8. 常用string函数分析

    string函数分析string函数包含在string.c文件中,经常被C文件使用.1. strcpy函数原型: char* strcpy(char* str1,char* str2);函数功能: 把 ...

  9. linux C函数之strdup函数分析【转】

    本文转载自:http://blog.csdn.net/tigerjibo/article/details/12784823 linux C函数之strdup函数分析 一.函数分析 1.函数原型: #i ...

随机推荐

  1. js 日期插件 datepicker

    点击图片出现  时间 ,增加一个点击事件 <label for="" class="width80">创建日:</label> < ...

  2. [rxjs] Shares a single subscription -- publish()

    If have an observable and you subscribe it twice, those tow subscritions have no connection. console ...

  3. 利用京东云擎架设免费Wordpress 博客(git方式)

    京东云擎(JAE)是京东推出的一款公有云产品,是京东云平台生态圈的核心组成部分.与百度的BAE.新浪的SAE同样.可是JAE刚上线不久,可能非常多人都还没听说过或不太了解.我尝试在JAE安装WordP ...

  4. Js判断对象是否为空,Js判断字符串是否为空

    Js判断对象是否为空,Js判断字符串是否为空,JS检查字符串是否为空字符串 >>>>>>>>>>>>>>>&g ...

  5. sendkeys && appactivate

    sendkeys    用于输入键盘按键 appactivate 用于聚焦程序 on error resume next set ws = createObject("wscript.she ...

  6. java实现的可以无限级别添加子节点的菜单树

    网上大部分菜单树,都是单独用js代码来实现的,这样做的缺点是:用户无法动态的设置菜单项,比如,超级管理员可能需要根据每个用户的权限,赋予他们不同的系统功能,不同的功能对应着不同数量的菜单项. 对于此问 ...

  7. 使用Preference保存设置

    http://blog.csdn.net/barryhappy/article/details/7381544 Android中有四种持久化数据的方法:SQLite数据库.文件存储.Preferenc ...

  8. Android Studio中常用插件及浅释

    博客: 安卓之家 微博: 追风917 CSDN: 蒋朋的家 简书: 追风917 博客园:追风917 插件可以来这个仓库查找:Android Studio Plugins 这里给出几个平时常用到的as插 ...

  9. error MSB6006: “CL.exe”已退出

    解决方案之一: 删除 \Windows\System32 目录下 mspdb110.dll. 试试吧.

  10. Twisted介绍

    Twisted诞生于2000年初,作者为Glyph,目的是为了开发网络游戏. Twisted的历史 Glyph开始采用Java多线程,来开发Twisted Reality,结果多线程使得开发变得复杂, ...