typedefstructglobal_data { bd_t *bd; unsignedlong flags; unsignedint baudrate; unsignedlong cpu_clk; /* CPU clock in Hz! */ unsignedlong bus_clk; /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */ unsignedlong pci_clk; unsignedlong mem_clk; #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) unsignedlong fb_base; /* Base address of framebuffer mem */ #endif #if defined(CONFIG_POST) unsignedlong post_log_word; /* Record POST activities */ unsignedlong post_log_res; /* success of POST test */ unsignedlong post_init_f_time; /* When post_init_f started */ #endif #ifdef CONFIG_BOARD_TYPES unsignedlong board_type; #endif unsignedlong have_console; /* serial_init() was called */ #if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER) unsignedlong precon_buf_idx; /* Pre-Console buffer index */ #endif unsignedlong env_addr; /* Address of Environment struct */ unsignedlong env_valid; /* Environment valid? enum env_valid */ unsignedlong env_has_init; /* Bitmask of boolean of struct env_location offsets */ int env_load_prio; /* Priority of the loaded environment */
unsignedlong ram_base; /* Base address of RAM used by U-Boot */ unsignedlong ram_top; /* Top address of RAM used by U-Boot */ unsignedlong relocaddr; /* Start address of U-Boot in RAM */ phys_size_t ram_size; /* RAM size */ unsignedlong mon_len; /* monitor len */ unsignedlong irq_sp; /* irq stack pointer */ unsignedlong start_addr_sp; /* start_addr_stackpointer */ unsignedlong reloc_off; structglobal_data *new_gd;/* relocated global data */
#ifdef CONFIG_DM structudevice *dm_root;/* Root instance for Driver Model */ structudevice *dm_root_f;/* Pre-relocation root instance */ structlist_headuclass_root;/* Head of core tree */ #endif #ifdef CONFIG_TIMER structudevice *timer;/* Timer instance for Driver Model */ #endif
constvoid *fdt_blob; /* Our device tree, NULL if none */ void *new_fdt; /* Relocated FDT */ unsignedlong fdt_size; /* Space reserved for relocated FDT */ #ifdef CONFIG_OF_LIVE structdevice_node *of_root; #endif structjt_funcs *jt;/* jump table */ char env_buf[32]; /* buffer for env_get() 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 #ifdef CONFIG_SYS_I2C_MXC void *srdata[10]; #endif unsignedint timebase_h; unsignedint timebase_l; #if CONFIG_VAL(SYS_MALLOC_F_LEN) unsignedlong malloc_base; /* base address of early malloc() */ unsignedlong malloc_limit; /* limit address */ unsignedlong malloc_ptr; /* current address */ #endif #ifdef CONFIG_PCI structpci_controller *hose;/* PCI hose for early use */ phys_addr_t pci_ram_top; /* top of region accessible to PCI */ #endif #ifdef CONFIG_PCI_BOOTDELAY int pcidelay_done; #endif structudevice *cur_serial_dev;/* current serial device */ structarch_global_dataarch;/* architecture-specific data */ #ifdef CONFIG_CONSOLE_RECORD structmembuffconsole_out;/* console output */ structmembuffconsole_in;/* console input */ #endif #ifdef CONFIG_DM_VIDEO ulong video_top; /* Top of video frame buffer area */ ulong video_bottom; /* Bottom of video frame buffer area */ #endif #ifdef CONFIG_BOOTSTAGE structbootstage_data *bootstage;/* Bootstage information */ structbootstage_data *new_bootstage;/* Relocated bootstage info */ #endif #ifdef CONFIG_LOG int log_drop_count; /* Number of dropped log messages */ int default_log_level; /* For devices with no filters */ structlist_headlog_head;/* List of struct log_device */ int log_fmt; /* Mask containing log format info */ #endif } gd_t;
if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) { #ifdef CONFIG_OF_LIBFDT debug("using: FDT\n"); if (image_setup_linux(images)) { printf("FDT creation failed! hanging..."); hang(); } #endif } elseif (BOOTM_ENABLE_TAGS) { debug("using: ATAGS\n"); setup_start_tag(gd->bd); //通过bd结构体中的参数在内存中的存放位置gd->bd->bi_boot_params来构建初始化tag结构, //表明参数结构的开始 if (BOOTM_ENABLE_SERIAL_TAG) setup_serial_tag(¶ms); //构建串口参数的tag结构 if (BOOTM_ENABLE_CMDLINE_TAG) setup_commandline_tag(gd->bd, commandline); //构建命令行参数的tag结构 if (BOOTM_ENABLE_REVISION_TAG) setup_revision_tag(¶ms); if (BOOTM_ENABLE_MEMORY_TAGS) setup_memory_tags(gd->bd); if (BOOTM_ENABLE_INITRD_TAG) { /* * In boot_ramdisk_high(), it may relocate ramdisk to * a specified location. And set images->initrd_start & * images->initrd_end to relocated ramdisk's start/end * addresses. So use them instead of images->rd_start & * images->rd_end when possible. */ if (images->initrd_start && images->initrd_end) { setup_initrd_tag(gd->bd, images->initrd_start, images->initrd_end); } elseif (images->rd_start && images->rd_end) { setup_initrd_tag(gd->bd, images->rd_start, images->rd_end); } } setup_board_tags(¶ms); setup_end_tag(gd->bd); } else { printf("FDT and ATAGS support not compiled in - hanging\n"); hang(); } }
setup_start_tag
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
staticvoidsetup_start_tag(bd_t *bd) { params = (struct tag *)bd->bi_boot_params; //获取struct tag指针
if (IMAGE_ENABLE_OF_LIBFDT) boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree);
if (IMAGE_BOOT_GET_CMDLINE) { ret = boot_get_cmdline(lmb, &images->cmdline_start, &images->cmdline_end); if (ret) { puts("ERROR with allocation of cmdline\n"); return ret; } }
if (IMAGE_ENABLE_OF_LIBFDT) { ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size); if (ret) return ret; }
if (IMAGE_ENABLE_OF_LIBFDT && of_size) { ret = image_setup_libfdt(images, *of_flat_tree, of_size, lmb); //此函数中会调用fdt_chosen进行参数传递 if (ret) return ret; }
return0; }
intfdt_chosen(void *fdt) { int nodeoffset; int err; char *str; /* used to set string properties */