Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2600962
  • 博文数量: 877
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 5920
  • 用 户 组: 普通用户
  • 注册时间: 2013-12-05 12:25
个人简介

技术的乐趣在于分享,欢迎多多交流,多多沟通。

文章分类

全部博文(877)

文章存档

2021年(2)

2016年(20)

2015年(471)

2014年(358)

2013年(26)

分类: LINUX

2013-12-11 20:26:33

  1. void start_armboot (void)
  2. {
  3.     init_fnc_t **init_fnc_ptr;
  4.     char *s;
  5. #if defined(CONFIG_VFD) || defined(CONFIG_LCD)
  6.     unsigned long addr;
  7. #endif

  8.     /* Pointer is writable since we allocated a register for it */
  9.     gd = (gd_t*)(_armboot_start - CONFIG_SYS_MALLOC_LEN - sizeof(gd_t));
  10.     /* compiler optimization barrier needed for GCC >= 3.4 */
  11.     __asm__ __volatile__("": : :"memory");

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

  15.     gd->flags |= GD_FLG_RELOC;

  16.     monitor_flash_len = _bss_start - _armboot_start;

  17.     for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  18.         if ((*init_fnc_ptr)() != 0) {
  19.             hang ();
  20.         }
  21.     }
首先定义了两个全局变量,然后执行一个for循环,进行相应的初始化,
  1. for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  2.         if ((*init_fnc_ptr)() != 0) {
  3.             hang ();
  4.         }
  5.     }

来看下下init_sequence数组都执行了那些函数:
  1. init_fnc_t *init_sequence[] = {
  2. #if defined(CONFIG_ARCH_CPU_INIT)
  3.     arch_cpu_init,        /* basic arch cpu dependent setup */
  4. #endif
  5.     board_init,        /* basic board dependent setup */
  6. #if defined(CONFIG_USE_IRQ)
  7.     interrupt_init,        /* set up exceptions */
  8. #endif
  9.     timer_init,        /* initialize timer */
  10. #ifdef CONFIG_FSL_ESDHC
  11.     get_clocks,
  12. #endif
  13.     env_init,        /* initialize environment */
  14.     init_baudrate,        /* initialze baudrate settings */
  15.     serial_init,        /* serial communications setup */
  16.     console_init_f,        /* stage 1 init of console */
  17.     display_banner,        /* say that we are here */
  18. #if defined(CONFIG_DISPLAY_CPUINFO)
  19.     print_cpuinfo,        /* display cpu info (and speed) */
  20. #endif
  21. #if defined(CONFIG_DISPLAY_BOARDINFO)
  22.     checkboard,        /* display board info */
  23. #endif
  24. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
  25.     init_func_i2c,
  26. #endif
  27.     dram_init,        /* configure available RAM banks */
  28. #if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
  29.     arm_pci_init,
  30. #endif
  31.     display_dram_config,
  32.     NULL,
  33. };
上面都有注释,就不解释了,值得一提的是,在display _banner函数中,可以添加一些打印信息。
还有一个技巧就是这个数组里面的最后一个元素定义为NULL,用来给for循环使用,来判断是否所有的函数都执行完毕。
执行完这些函数之后,又执行了一些函数,最后执行了一个死循环
  1. /* main_loop() can return to retry autoboot, if so just run it again. */
  2.     for (;;) {
  3.         main_loop ();
  4.     }

  5.     /* NOTREACHED - no way out of command loop except booting */
  6. }

简单分析到这,具体的源代码我也没有跟踪,仅仅看了个框架。



















阅读(585) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~