设为首页 加入收藏

TOP

U-Boot中gd的定义和使用
2014-11-23 23:16:52 来源: 作者: 【 】 浏览:9
Tags:U-Boot 义和 使用

最近在做uboot中nand启动相关的工作,遇到一个问题一直纠结着。现在终于明白了这个问题,想想还有好多兄弟在某个黑暗的角落里或者某台电脑前纠结着呢,所以赶紧写下来以供查阅。


#ifdef CONFIG_OMAP
struct omap_boot_parameters omap_boot_params;
#endif
};


#include


#ifdef CONFIG_ARM64
#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("x18")
#else
#define DECLARE_GLOBAL_DATA_PTR
register volatile gd_t *gd asm ("r9")
#endif


从这里看到了gd的定义,并且可以知道气质这个结构体的定义是在:#include 这个目录下。

那么就去这个目录下添加一个私有变量使得在后续的使用过程中更加方便吧!!!!!!!!!!!

typedef struct global_data {
bd_t *bd;
unsigned long flags;
unsigned int baudrate;
unsigned long cpu_clk;
/* CPU clock in Hz! */
unsigned long bus_clk;
/* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
unsigned long pci_clk;
unsigned long mem_clk;
#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
unsigned long fb_base;
/* Base address of framebuffer mem */
#endif
#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
#ifdef CONFIG_BOARD_TYPES
unsigned long board_type;
#endif
unsigned long have_console;
/* serial_init() was called */
#ifdef CONFIG_PRE_CONSOLE_BUFFER
unsigned long precon_buf_idx;
/* Pre-Console buffer index */
#endif
#ifdef CONFIG_MODEM_SUPPORT
unsigned long do_mdm_init;
unsigned long be_quiet;
#endif
unsigned long env_addr;
/* Address of Environment struct */
unsigned long env_valid;
/* Checksum of Environment valid */


unsigned long ram_top;
/* Top address of RAM used by U-Boot */


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;
struct global_data *new_gd;
/* relocated global data */


#ifdef CONFIG_DM
struct device *dm_root; /* Root instance for Driver Model */
struct list_head uclass_root;
/* Head of core tree */
#endif


const void *fdt_blob;
/* Our device tree, NULL if none */
void *new_fdt;
/* Relocated FDT */
unsigned long fdt_size;
/* Space reserved for relocated FDT */
void **jt; /* jump table */
char env_buf[32];
/* buffer for getenv() before reloc. */
#ifdef CONFIG_TRACE
void *trace_buff;
/* The trace buffer */
#endif
#if defined(CONFIG_SYS_I2C)
int cur_i2c_bus;
/* current used i2c bus */
#endif
unsigned long timebase_h;
unsigned long timebase_l;
struct arch_global_data arch;
/* architecture-specific data */


#ifdef CONFIG_xxxxx //此处随便x
void *priv;
/* point to the private data */
#endif
} gd_t;


在使用的过程中包含头文件,就可以使用了。


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇MySQL 以及 Python 实现排名窗口.. 下一篇利用C++对象确定性析构的原则来解..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: