[转] uboot201106rc3的arm的board.c的board_init_f函数的注释

  1. void board_init_f (ulong bootflag)//传入r0=0=bootflag  
  2. {  
  3.  bd_t *bd;//bd_t结构体指针  
  4.  init_fnc_t **init_fnc_ptr;//init_fnc_t   是个自定义的函数指针类型,初始化板  
  5.  gd_t *id;//gd_t结构体指针  
  6.  ulong addr, addr_sp;//addr将指向用户正常访问的最高地址+1的位置;addr_sp指向堆起始位置  
  7.   
  8.  /* Pointer is writable since we allocated a register for it */  
  9.  gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07);//gd指向0x30000f80  
  10.  /* compiler optimization barrier needed for GCC >= 3.4 */  
  11.  __asm__ __volatile__("": : :"memory");//告诉编译器内存已被修改  
  12.   
  13.  memset ((void*)gd, 0, sizeof (gd_t));//gd的gd_t大小清0  
  14.   
  15.  gd->mon_len = _bss_end_ofs;//_bss_end_ofs=0x000add6c u-boot code, data & bss段大小总和  
  16.   
  17.  for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {  
  18.   if ((*init_fnc_ptr)() != 0) {//如果板的初始化函数序列出错,死循环  
  19.    hang ();  
  20.   }  
  21.  }  
  22.   
  23.  debug ("monitor len: %08lX\n", gd->mon_len);  
  24.  /* 
  25.   * Ram is setup, size stored in gd !! 
  26.   */  
  27.  debug ("ramsize: %08lX\n", gd->ram_size);  
  28. //不进入  
  29. #if defined(CONFIG_SYS_MEM_TOP_HIDE)  
  30.  /* 
  31.   * Subtract specified amount of memory to hide so that it won''t 
  32.   * get "touched" at all by U-Boot. By fixing up gd->ram_size 
  33.   * the Linux kernel should now get passed the now "corrected" 
  34.   * memory size and won''t touch it either. This should work 
  35.   * for arch/ppc and arch/powerpc. Only Linux board ports in 
  36.   * arch/powerpc with bootwrapper support, that recalculate the 
  37.   * memory size from the SDRAM controller setup will have to 
  38.   * get fixed. 
  39.   */  
  40.  gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;  
  41. #endif  
  42.  //CONFIG_SYS_SDRAM_BASE=0x30000000  gd->ram_size=4000000  addr=0x34000000  
  43.  addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;  
  44. //不进入  
  45. #ifdef CONFIG_LOGBUFFER  
  46. #ifndef CONFIG_ALT_LB_ADDR  
  47.  /* reserve kernel log buffer */  
  48.  addr -= (LOGBUFF_RESERVE);  
  49.  debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);  
  50. #endif  
  51. #endif  
  52. //不进入  
  53. #ifdef CONFIG_PRAM  
  54.  /* 
  55.   * reserve protected RAM 
  56.   */  
  57.  i = getenv_r ("pram", (char *)tmp, sizeof (tmp));  
  58.  reg = (i > 0) ? simple_strtoul ((const char *)tmp, NULL, 10) : CONFIG_PRAM;  
  59.  addr -= (reg << 10);  /* size is in kB */  
  60.  debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);  
  61. #endif /* CONFIG_PRAM */  
  62. //进入  
  63. #if !(defined(CONFIG_SYS_NO_ICACHE) && defined(CONFIG_SYS_NO_DCACHE))  
  64.  /* reserve TLB table *///保存页表缓冲  
  65.  addr -= (4096 * 4);//addr=0x33FFC000  
  66.   
  67.  /* round down to next 64 kB limit */  
  68.  addr &= ~(0x10000 - 1);//addr=0x33FF0000  
  69.   
  70.  gd->tlb_addr = addr;  
  71.  debug ("TLB table at: %08lx\n", addr);  
  72. #endif  
  73.   
  74.  /* round down to next 4 kB limit */  
  75.  addr &= ~(4096 - 1);//addr=0x33FF0000  
  76.  debug ("Top of RAM usable for U-Boot at: %08lx\n", addr);  
  77. //不进入  
  78. #ifdef CONFIG_VFD  
  79. # ifndef PAGE_SIZE  
  80. #   define PAGE_SIZE 4096  
  81. # endif  
  82.  /* 
  83.   * reserve memory for VFD display (always full pages) 
  84.   */  
  85.  addr -= vfd_setmem (addr);  
  86.  gd->fb_base = addr;  
  87. #endif /* CONFIG_VFD */  
  88. //不进入  
  89. #ifdef CONFIG_LCD  
  90. #ifdef CONFIG_FB_ADDR  
  91.  gd->fb_base = CONFIG_FB_ADDR;  
  92. #else  
  93.  /* reserve memory for LCD display (always full pages) */  
  94.  addr = lcd_setmem (addr);  
  95.  gd->fb_base = addr;  
  96. #endif /* CONFIG_FB_ADDR */  
  97. #endif /* CONFIG_LCD */  
  98.   
  99.  /* 
  100.   * reserve memory for U-Boot code, data & bss 
  101.   * round down to next 4 kB limit 
  102.   */  
  103.  addr -= gd->mon_len;//addr再去掉code, data & bss的大小 0x000add6c addr为0x33F52294  
  104.  addr &= ~(4096 - 1);//4k的页对齐 addr为0x33F52000  
  105.   
  106.  debug ("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10, addr);  
  107. //进入  
  108. #ifndef CONFIG_PRELOADER  
  109.  /* 
  110.   * reserve memory for malloc() arena 
  111.   */  
  112.   //TOTAL_MALLOC_LEN在include/common.h中定义 值为0x00410000  
  113.  addr_sp = addr - TOTAL_MALLOC_LEN;//留出0x410000的空间给malloc  addr_sp为0x33B42000  
  114.  debug ("Reserving %dk for malloc() at: %08lx\n",  
  115.    TOTAL_MALLOC_LEN >> 10, addr_sp);  
  116.  /* 
  117.   * (permanently) allocate a Board Info struct 
  118.   * and a permanent copy of the "global" data 
  119.   */  
  120.  addr_sp -= sizeof (bd_t);//留出bd_t的大小24字节 0x18 addr_sp为0x33B41FE8  
  121.  bd = (bd_t *) addr_sp;  
  122.  gd->bd = bd;  
  123.  debug ("Reserving %zu Bytes for Board Info at: %08lx\n",   
  124.    sizeof (bd_t), addr_sp);  
  125.  addr_sp -= sizeof (gd_t);//再留出gd_t的大小92字节 0x5c addr_sp为0x33B41F8C  
  126.  id = (gd_t *) addr_sp; //id为0x33B41F8C  
  127.  debug ("Reserving %zu Bytes for Global Data at: %08lx\n",  
  128.    sizeof (gd_t), addr_sp);  
  129.   
  130.  /* setup stackpointer for exeptions */  
  131.  gd->irq_sp = addr_sp;  
  132. //不进入  
  133. #ifdef CONFIG_USE_IRQ  
  134.  addr_sp -= (CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ);  
  135.  debug ("Reserving %zu Bytes for IRQ stack at: %08lx\n",  
  136.   CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ, addr_sp);  
  137. #endif  
  138.  /* leave 3 words for abort-stack    */  
  139.  addr_sp -= 12;//预留12字节 0x0c addr_sp为0x33B41F80  
  140.   
  141.  /* 8-byte alignment for ABI compliance */  
  142.  addr_sp &= ~0x07;//对齐 addr_sp为0x33B41F80  
  143. #else  
  144.  //不进入  
  145.  addr_sp += 128; /* leave 32 words for abort-stack   */  
  146.  gd->irq_sp = addr_sp;  
  147. #endif  
  148.  //addr_sp为0x33B41F80  addr为0x33F52000  
  149.  debug ("New Stack Pointer is: %08lx\n", addr_sp);//得到最终的堆指针  
  150. //不进入  
  151. #ifdef CONFIG_POST  
  152.  post_bootmode_init();  
  153.  post_run (NULL, POST_ROM | post_bootmode_get(0));  
  154. #endif  
  155.   
  156.  gd->bd->bi_baudrate = gd->baudrate;  
  157.  /* Ram ist board specific, so move it to board code ... */  
  158.  dram_init_banksize();  
  159.  display_dram_config(); /* and display it */  
  160.   
  161.  gd->relocaddr = addr;//搬运的起始地址(高位)  
  162.  gd->start_addr_sp = addr_sp;//堆栈的起始地址  
  163.  gd->reloc_off = addr - _TEXT_BASE;//搬运的偏移地址(高位)  
  164.  debug ("relocation Offset is: %08lx\n", gd->reloc_off);  
  165.  memcpy (id, (void *)gd, sizeof (gd_t));//把在低位的gd搬移到高位的id处,id为入口 id为0x33B41F8C  
  166.  //堆栈入口addr_sp gd入口id 搬运的起始地址(高位)addr 调用start.s的relocate_code子程序  
  167.  relocate_code (addr_sp, id, addr);//传参r0 r1 r2 分别为addr_sp, id, addr  
  168.   
  169.  /* NOTREACHED - relocate_code() does not return */  
  170. }  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值