u-boot分析——struct gd_t与struct bd_t
生活随笔
收集整理的這篇文章主要介紹了
u-boot分析——struct gd_t与struct bd_t
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?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。其成員主要是一些全局的系統(tǒng)初始化參數。需要用到時用宏定義: DECLARE_GLOBAL_DATA_PTR,指定占用寄存器R8。
/*
* 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在config文件中定義,start.S中會根據這個值分配棧空間給global_data
*/
typedef??? struct??? global_data {
??? bd_t??? ??? *bd;?????????????????????????????????? // struct board_info指針,保存板子信息
??? unsigned long??? flags;??????????????????? // 指示標志,如設備已經初始化標志等
??? unsigned long??? baudrate;??????????? // 串口波特率
??? unsigned long??? have_console;??? // 串口初始化標志
??? unsigned long??? reloc_off;???????????? // ?? 重定位偏移,即實際定向位置與連接指定之差
??? unsigned long??? env_addr;?? ?? // Address of Environment struct ,環(huán)境參數地址
??? unsigned long??? env_valid;??????????? // 環(huán)境參數CRC檢驗有效標志
??? unsigned long??? fb_base;????????????? // frame buffer的基址
#ifdef CONFIG_VFD
??? unsigned char??? vfd_type;??? /* display type */
#endif
#if 0
??? unsigned long??? cpu_clk;??? /* CPU clock in Hz!??? ??? */
??? unsigned long??? bus_clk;
??? unsigned long??? ram_size;??? /* RAM size */
??? 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??? ??? */
#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")
2. bd_t : board info數據結構定義,位于文件 include/asm-arm/u-boot.h。保存板子參數。
typedef struct bd_info {
??? int??? ??? ??? bi_baudrate;???????????????????????? // 串口波特率
??? unsigned long??? bi_ip_addr;??????????????? // IP地址
??? unsigned char??? bi_enetaddr[6];??????? // MAC地址
??? struct environment_s??? ?????? *bi_env;
??? ulong??? ??????? bi_arch_number;???????????? // 板子ID號
??? ulong??? ??????? bi_boot_params;???????????? // 啟動參數
??? struct??? ??? ??? ??????????????????????????????????????? // DRAM BANKS配置,起始地址與長度
??? {
??? ulong start;
??? ulong size;
??? } ??? ??? ??? bi_dram[CONFIG_NR_DRAM_BANKS];
#ifdef CONFIG_HAS_ETH1
??? unsigned char?? bi_enet1addr[6];???????? // 如果有第二塊網卡,指定MAC地址
#endif
} bd_t;
1. gd_t : global data數據結構定義,位于文件 include/asm-arm/global_data.h。其成員主要是一些全局的系統(tǒng)初始化參數。需要用到時用宏定義: DECLARE_GLOBAL_DATA_PTR,指定占用寄存器R8。
/*
* 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在config文件中定義,start.S中會根據這個值分配棧空間給global_data
*/
typedef??? struct??? global_data {
??? bd_t??? ??? *bd;?????????????????????????????????? // struct board_info指針,保存板子信息
??? unsigned long??? flags;??????????????????? // 指示標志,如設備已經初始化標志等
??? unsigned long??? baudrate;??????????? // 串口波特率
??? unsigned long??? have_console;??? // 串口初始化標志
??? unsigned long??? reloc_off;???????????? // ?? 重定位偏移,即實際定向位置與連接指定之差
??? unsigned long??? env_addr;?? ?? // Address of Environment struct ,環(huán)境參數地址
??? unsigned long??? env_valid;??????????? // 環(huán)境參數CRC檢驗有效標志
??? unsigned long??? fb_base;????????????? // frame buffer的基址
#ifdef CONFIG_VFD
??? unsigned char??? vfd_type;??? /* display type */
#endif
#if 0
??? unsigned long??? cpu_clk;??? /* CPU clock in Hz!??? ??? */
??? unsigned long??? bus_clk;
??? unsigned long??? ram_size;??? /* RAM size */
??? 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??? ??? */
#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")
2. bd_t : board info數據結構定義,位于文件 include/asm-arm/u-boot.h。保存板子參數。
typedef struct bd_info {
??? int??? ??? ??? bi_baudrate;???????????????????????? // 串口波特率
??? unsigned long??? bi_ip_addr;??????????????? // IP地址
??? unsigned char??? bi_enetaddr[6];??????? // MAC地址
??? struct environment_s??? ?????? *bi_env;
??? ulong??? ??????? bi_arch_number;???????????? // 板子ID號
??? ulong??? ??????? bi_boot_params;???????????? // 啟動參數
??? struct??? ??? ??? ??????????????????????????????????????? // DRAM BANKS配置,起始地址與長度
??? {
??? ulong start;
??? ulong size;
??? } ??? ??? ??? bi_dram[CONFIG_NR_DRAM_BANKS];
#ifdef CONFIG_HAS_ETH1
??? unsigned char?? bi_enet1addr[6];???????? // 如果有第二塊網卡,指定MAC地址
#endif
} bd_t;
轉載于:https://www.cnblogs.com/armlinux/archive/2011/10/25/2396794.html
總結
以上是生活随笔為你收集整理的u-boot分析——struct gd_t与struct bd_t的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Base64 初探
- 下一篇: NOV. 2nd, 减肥第三天