Definition and use of Gd in uboot

Source: Internet
Author: User

Recently, I am working on NAND boot in uboot and have been struggling with a problem. Now I have clarified this issue. I think there are still many brothers struggling in a dark corner or in front of a computer, so I should write it down for reference.

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 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_ptrregister volatile gd_t * gd asm ("R9 ")
# Endif

We can see the definition of GD from here, and we can know that the structure definition of temperament is in the: # include <ASM-generic/global_data.h> folder.

Add a private variable to this folder to make it easier to use it !!!!!!!!!!!

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_lele_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 // random x
Void * priv;/* point to the private data */
# Endif
} Gd_t;

You can use the header file in the Process of use.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.