Uboot版本:u-boot-2013.01
一、gd结构体的定义与使用
gd_t 和 bd_t 是u-boot中两个重要的数据结构,在初始化操作很多都要靠这两个数据结构来保存或传递。
gd_t 定义在/u-boot-2013.01/arch/arm/include/asm/global_data.h
bd_t 定义在 ./include/asm-arm/u-boot.h
1、gd_t : global data数据结构定义
位于文件/u-boot-2013.01/arch/arm/include/asm/global_data.h 中。其成员主要是一些全局的系统初始化参数。
当使用gd_t 时需用宏定义进行声明DECLARE_GLOBAL_DATA_PTR
从这个宏的定义可以看出,gd是一个保存在ARM的r8寄存器中的gd_t结构体的指针。指定占用寄存器R8。
- typedef struct global_data {
- bd_t *bd;//struct board_info指针,保存开发板信息
- unsigned long flags;//指示标志,如设备已经初始化标志等
- unsigned int baudrate;//串口波特率
- unsigned long have_console; //串口初始化标志
- #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 */
- #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 */
- 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;
- unsigned long tlb_size;
- #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;
2.、bd_t :board info数据结构定义
位于文件u-boot-2013.01/arch/arm/include/asm/u-boot.h。保存板子参数。
- typedef struct bd_info {
- unsigned int bi_baudrate; /* 串口波特率 */
- ulong bi_arch_number; /* 开发板机器ID */
- ulong bi_boot_params; /* 启动参数 */
- unsigned long bi_arm_freq; /* arm frequency */
- unsigned long bi_dsp_freq; /* dsp core frequency */
- unsigned long bi_ddr_freq; /* ddr frequency */
- struct /* RAM configuration */
- {
- ulong start;
- ulong size;
- } bi_dram[CONFIG_NR_DRAM_BANKS];
- } bd_t;