在分析板级初始化函数board_init_f 和 board_init_r 之前,先来看一下在uboot中颇为重要的 gd_t, bd_t 结构
bd_t 所对应的定义bd_info 在 arch/arm/include/asm/u-boot.h 下,主要用来保存板子参数
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*/
传递给内核的参数的保存地址
gd_t 对应的global_data 在 arch/arm/include/asm/global_data.h,其成员主要是一些全局的系统初始化参数。当使用gd_t时需用宏定义进行声明:DECLARE_GLOBAL_DATA_PTR,指定占用寄存器R8。
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")