gd_t , bd_t 结构分析

在分析板级初始化函数board_init_f 和 board_init_r 之前,先来看一下在uboot中颇为重要的 gd_t, bd_t 结构

bd_t 所对应的定义bd_info 在 arch/arm/include/asm/u-boot.h 下,主要用来保存板子参数

 typedef struct bd_info {
int bi_baudrate; /* serial console baudrate 波特率串口控制台*/
unsigned long bi_ip_addr; /* IP Address */
ulong bi_arch_number; /* unique id for this board 板子唯一的ID */
ulong bi_boot_params; /* where this board expects params 启动参数*/
struct /* RAM configuration ARM的开始位置和大小*/
{
ulong start;
ulong size;
} bi_dram[CONFIG_NR_DRAM_BANKS];
} bd_t;

bd_info

  • 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。

  * Keep it *SMALL* and remember to set GENERATED_GBL_DATA_SIZE > sizeof(gd_t)
*/ typedef struct global_data {
bd_t *bd; //与板子相关的结构
unsigned long flags; //指示标志,如设备已经初始化标志等
unsigned long baudrate; //串口波特率
unsigned long have_console; /* serial_init() was called 串口初始化标志*/
unsigned long env_addr; /* Address of Environment struct 环境变量参数地址*/
unsigned long env_valid; /* Checksum of Environment valid? 检验环境变量参数是否有效 */
unsigned long fb_base; /* base address of frame buffer
frame buffer 基址*/
#ifdef CONFIG_VFD
unsigned char vfd_type; /* display type 显示类型的logo 的VFD*/
#endif
#ifdef CONFIG_FSL_ESDHC //宏未在板子相关头文件中定义
unsigned long sdhc_clk;
#endif
#ifdef CONFIG_AT91FAMILY //宏未在板子相关头文件中定义
/* "static data" needed by at91's clock.c */
unsigned long cpu_clk_rate_hz;
unsigned long main_clk_rate_hz;
unsigned long mck_rate_hz;
unsigned long plla_rate_hz;
unsigned long pllb_rate_hz;
unsigned long at91_pllb_usb_init;
#endif
#ifdef CONFIG_ARM // 宏未定义
/* "static data" needed by most of timer.c on ARM platforms */
unsigned long timer_rate_hz;
unsigned long tbl;
unsigned long tbu;
unsigned long long timer_reset_value;
unsigned long lastinc;
#endif
unsigned long relocaddr; /* Start address of U-Boot in RAM u-boot搬移到内存后的起始地址*/
phys_size_t ram_size; /* RAM size */
unsigned long mon_len; /* monitor len */
unsigned long irq_sp; /* irq stack pointer */
unsigned long start_addr_sp; /* start_addr_stackpointer */
unsigned long reloc_off;
#if !(defined(CONFIG_SYS_NO_ICACHE) && defined(CONFIG_SYS_NO_DCACHE)) //宏未定义
unsigned long tlb_addr;
#endif
void **jt; /* jump table */
char env_buf[]; /* buffer for getenv() before reloc. reloc之前getenv()的缓冲区*/
} gd_t; #define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("r8")

global_data

上一篇:Azure CosmosDB (3) 选择适当的一致性级别


下一篇:ThinkPHP+Smarty模板中截取包含中英文混合的字符串乱码的解决方案