博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
uboot中gd的定义和使用
阅读量:7167 次
发布时间:2019-06-29

本文共 3386 字,大约阅读时间需要 11 分钟。

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

uboot version 2014.4

/* Architecture-specific global data */

struct arch_global_data {
#if defined(CONFIG_FSL_ESDHC)
u32 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
/* "static data" needed by most of timer.c on ARM platforms */
unsigned long timer_rate_hz;
unsigned long tbu;
unsigned long tbl;
unsigned long lastinc;
unsigned long long timer_reset_value;
#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
unsigned long tlb_addr;
unsigned long tlb_size;
#endif
#ifdef CONFIG_OMAP
struct omap_boot_parameters omap_boot_params;
#endif
};
#include <asm-generic/global_data.h>
#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 <asm-generic/global_data.h>这个文件夹下。

那么就去这个文件夹下加入一个私有变量使得在兴许的使用过程中更加方便吧!!!!!!!!!!!

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;

在使用的过程中包括头文件,就能够使用了。

转载地址:http://ecmwm.baihongyu.com/

你可能感兴趣的文章
File native method
查看>>
JAVA中的enum
查看>>
物联网平台构架系列 (一):Amazon, Microsoft, IBM IoT 解决方案导论 之 概览
查看>>
转载和积累系列 - Page cache和Buffer cache
查看>>
Java中如何利用Selenium获取元素分析网页内容
查看>>
ssh不能远程登录问题解决 & hosts.allow/howts.deny书写规则
查看>>
【Spring】HttpMessageConverter的作用及替换
查看>>
kvm sr-iov 热插拔 简介
查看>>
hibernate inverse作用
查看>>
cv::Mat 结构
查看>>
Centos6.9 安装docker与docker-compose
查看>>
Aug 09 使用AVAudioPlayer轻松搞定音频播放
查看>>
VC++中使用ADO连接数据库
查看>>
创建多个电脑账户需要赋予不用的权限方法
查看>>
改变单选按钮radio圆点的颜色
查看>>
我的友情链接
查看>>
《12月份的算法更改总结》
查看>>
一段代码的时间复杂度计算
查看>>
类似系统alerview 的弹出框动画
查看>>
Xocde插件实效的解决办法
查看>>