在分析板級初始化函數board_init_f 和 board_init_r 以前,先來看一下在uboot中頗爲重要的 gd_t, bd_t 結構ide
bd_t 所對應的定義bd_info 在 arch/arm/include/asm/u-boot.h 下,主要用來保存板子參數
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
1 typedef struct bd_info { 2 int bi_baudrate; /* serial console baudrate 波特率串口控制檯*/ 3 unsigned long bi_ip_addr; /* IP Address */ 4 ulong bi_arch_number; /* unique id for this board 板子惟一的ID */ 5 ulong bi_boot_params; /* where this board expects params 啓動參數*/ 6 struct /* RAM configuration ARM的開始位置和大小*/ 7 { 8 ulong start; 9 ulong size; 10 } bi_dram[CONFIG_NR_DRAM_BANKS]; 11 } bd_t;
- ulong bi_arch_number; /* unique id for this board 開發板ID*/
該變量標識每一種開發板相關的ID,該值將傳遞給內核,若是這個參數與內核配置的不相同,那麼內核啓動解壓縮完成後將出現「Error:a」錯誤,開發板ID能夠在內核arch/arm/tools/mach-types中查看函數
- ulong bi_boot_params; /* where this board expects params u-boot*/
傳遞給內核的參數的保存地址this
gd_t 對應的global_data 在 arch/arm/include/asm/global_data.h,其成員主要是一些全局的系統初始化參數。當使用gd_t時需用宏定義進行聲明:DECLARE_GLOBAL_DATA_PTR,指定佔用寄存器R8。
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
1 * Keep it *SMALL* and remember to set GENERATED_GBL_DATA_SIZE > sizeof(gd_t) 2 */ 3 4 5 typedef struct global_data { 6 bd_t *bd; //與板子相關的結構 7 unsigned long flags; //指示標誌,如設備已經初始化標誌等 8 unsigned long baudrate; //串口波特率 9 unsigned long have_console; /* serial_init() was called 串口初始化標誌*/ 10 unsigned long env_addr; /* Address of Environment struct 環境變量參數地址*/ 11 unsigned long env_valid; /* Checksum of Environment valid? 檢驗環境變量參數是否有效 */ 12 unsigned long fb_base; /* base address of frame buffer 13 frame buffer 基址*/ 14 #ifdef CONFIG_VFD 15 unsigned char vfd_type; /* display type 顯示類型的logo 的VFD*/ 16 #endif 17 #ifdef CONFIG_FSL_ESDHC //宏未在板子相關頭文件中定義 18 unsigned long sdhc_clk; 19 #endif 20 #ifdef CONFIG_AT91FAMILY //宏未在板子相關頭文件中定義 21 /* "static data" needed by at91's clock.c */ 22 unsigned long cpu_clk_rate_hz; 23 unsigned long main_clk_rate_hz; 24 unsigned long mck_rate_hz; 25 unsigned long plla_rate_hz; 26 unsigned long pllb_rate_hz; 27 unsigned long at91_pllb_usb_init; 28 #endif 29 #ifdef CONFIG_ARM // 宏未定義 30 /* "static data" needed by most of timer.c on ARM platforms */ 31 unsigned long timer_rate_hz; 32 unsigned long tbl; 33 unsigned long tbu; 34 unsigned long long timer_reset_value; 35 unsigned long lastinc; 36 #endif 37 unsigned long relocaddr; /* Start address of U-Boot in RAM u-boot搬移到內存後的起始地址*/ 38 phys_size_t ram_size; /* RAM size */ 39 unsigned long mon_len; /* monitor len */ 40 unsigned long irq_sp; /* irq stack pointer */ 41 unsigned long start_addr_sp; /* start_addr_stackpointer */ 42 unsigned long reloc_off; 43 #if !(defined(CONFIG_SYS_NO_ICACHE) && defined(CONFIG_SYS_NO_DCACHE)) //宏未定義 44 unsigned long tlb_addr; 45 #endif 46 void **jt; /* jump table */ 47 char env_buf[32]; /* buffer for getenv() before reloc. reloc以前getenv()的緩衝區*/ 48 } gd_t; 49 50 51 52 #define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("r8")