您的位置:首页 > 理论基础 > 数据结构算法

uboot源码——gd_t和bd_t数据结构

2017-04-10 11:22 411 查看
bd_t和gd_t是u-boot中两个重要的数据结构,初始化操作中很多全局变量都要靠这两个数据结构来保存或传递。

分别定义在include/asm-arm/u-boot.h和include/asm-arm/global_data.h中。

一、bd_t 

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

(2)结构体定义

typedef struct bd_info
{
int bi_baudrate; /* serial console baudrate */
unsigned long bi_ip_addr; /* IP Address */

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

二、gd_t 

(1)global data数据结构定义,其成员主要是一些全局的系统初始化参数。当使用gd_t时需用宏定义进行声明:DECLARE_GLOBAL_DATA_PTR,指定占用寄存器R8。

(2)结构体定义

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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: