u-boot中的两个数据结构gd

it2022-05-05  109

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

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

2.bd_t : board info数据结构定义,位于文件 include/asm-arm/u-boot.h。保存板子参数。

#ifndef __ASM_GBL_DATA_H#define __ASM_GBL_DATA_H/** The following data structure is placed in some memory wich is* available very early after boot (like DPRAM on MPC8xx/MPC82xx, or* some locked parts of the data cache) to allow for a minimum set of* global variables during system initialization (until we have set* up the memory controller so that we can use RAM).* Keep it *SMALL* and remember to set CFG_GBL_DATA_SIZE > sizeof(gd_t)*下面的数据结构在引导后放在内存里,在系统初始化期间给全局变量进行最小化设置。* 保持简单且不要忘了使CFG_GBL_DATA_SIZE 大于gd_t的大小*/

typedef struct global_data

{bd_t  *bd;                           /*开发板相关参数,结构体变量,参考u-boot.h */unsigned long flags;                 /*指示标志,如设备已经初始化标志等*/unsigned long baudrate;              /*串行口通讯速率 */unsigned long have_console;          /* serial_init() was called console_init()中使用控制台*/unsigned long reloc_off;             /* Relocation Offset 重定位偏移,就是实际定向的位置与编译连接时指定的位置之差,一般为0 */unsigned longenv_addr;               /* Address of Environment struct 环境参数地址*/unsigned longenv_valid;              /* Checksum of Environment valid? 环境参数CRC检验有效标志*/unsigned longfb_base;                /* base address of frame buffer 帧缓冲区基地址*/

#ifdef CONFIG_VFDunsigned charvfd_type;               /* display type 显示类型*/#endif

#if  0     unsigned long cpu_clk;               /*  CPU clock in Hz!   cpu时钟  */unsigned long bus_clk;               /* 总线时钟 */unsigned long ram_size;              /*  RAM  size  of ram大小 */unsigned long reset_status;          /* reset status register at boot */#endif

void   **jt;                         /* jump table 跳转表,用来"函数调用地址登记" */}gd_t;

/** Global Data Flags   全局数据标志*/#define GD_FLG_RELOC 0x00001         /* Code was relocated to RAM   代码装载到RAM里*/#define GD_FLG_DEVINIT 0x00002       /* Devices have been initialized 设备已经初始化*/#define GD_FLG_SILENT 0x00004        /* Silent mode     */

#define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("r8")/*DECLARE_GLOBAL_DATA_PTR 只是一个定义的宏,这个宏定义了一个gd_t全局数据结构的指针 声明一个寄存器变量 gd 占用r8。这个宏在所有需要引用全局数据指针gd_t *gd的源码中都有申明。这个申明也避免编译器把r8分配给其它的变量. 所以gd就是r8,用r8来保存内存地址,达到全局使用目的,这个指针变量不占用内存。gd指向一个数据结构,用于保存参数。。*/

#endif /* __ASM_GBL_DATA_H */

#ifndef _U_BOOT_H_#define _U_BOOT_H_ 1

typedef struct bd_info {int bi_baudrate;             /* serial console baudrate    串口波特率 */unsigned long   bi_ip_addr;         /* IP Address    IP 地址 */unsigned char  bi_enetaddr[6];      /* Ethernet adress    MAC地址*/struct environment_s *bi_env;       /*结构体变量定义见46行 */ulong   bi_arch_number;        /* unique id for this board    板子的id*/ulong   bi_boot_params;             /* where this board expects params 启动参数*/struct           /* RAM configuration    RAM 配置*/{ulong start;ulong size;}     bi_dram[CONFIG_NR_DRAM_BANKS];}bd_t;

#endif /* _U_BOOT_H_ */

 

转载于:https://www.cnblogs.com/huxingkeji/archive/2012/07/16/2593879.html

相关资源:各显卡算力对照表!

最新回复(0)