uboot中gd_t和bd_t数据结构简介

bd_t和gd_t是u-boot中两个重要的数据结构,在初始化操作很多都要靠这两个数据结构来保存或传递。分别定义在include/asm-arm/u-boot.h和 include/asm-arm/global_data.h

1、bd_t :board info数据结构定义,主要是用来保存板子参数。

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 该变量标识每一种开发板相关的ID,该值将传递给内核,如果这个参数与内核配置的不相同,那么内核启动解压缩完成后将出现“Error:a”错误,开发板ID可以在内核arch/arm/tools/mach-types中查看*/

    ulong bi_boot_params; /* where this board expects params u-boot传递给内核的参数的保存地址*/
    struct /* RAM configuration 内存的起始地址及大小 */
    {
            ulong start;
            ulong size;
    } bi_dram[CONFIG_NR_DRAM_BANKS];
} bd_t;

2、gd_t : global data数据结构定义,位于文件 include/asm-arm/global_data.h。其成员主要是一些全局的系统初始化参数。当使用gd_t时需用宏定义进行声明:DECLARE_GLOBAL_DATA_PTR,指定占用寄存器R8。

typedef struct global_data {
    bd_t *bd; //与板子相关的结构,同上
    unsigned long flags; //指示标志,如设备已经初始化标志等
    unsigned long baudrate; //串口波特率
    unsigned long have_console; /* serial_init() was called */ //串口初始化标志
#ifdef CONFIG_PRE_CONSOLE_BUFFER //宏未定义
    unsigned long precon_buf_idx; /* Pre-Console buffer index */
#endif
    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_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

#ifdef CONFIG_IXP425 //宏未在板子相关头文件中定义
    unsigned long timestamp;
#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_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) //宏未定义
    unsigned long tlb_addr;
#endif

   const void *fdt_blob; /* Our device tree, NULL if none */
   void **jt; /* jump table */
   char env_buf[32]; /* buffer for getenv() before reloc. */
#if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER) //宏未定义
     unsigned long post_log_word; /* Record POST activities */
     unsigned long post_log_res; /* success of POST test */
     unsigned long post_init_f_time; /* When post_init_f started */
#endif
} gd_t;
/*

http://www.embedu.org/Column/Column586.htm

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值