




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
gd_t和bd_t是u-boot中两个重要的数据结构,在初始化操作很多都要靠这两个数据结构来保存或传递.分别定义在./include/asm/global_data.h和./include/asm/u_boot.h1.gd_t: global data数据结构定义,位于文件 include/asm-arm/global_data.h。其成员主要是一些全局的系统初始化参数。需要用到时用宏定义:DECLARE_GLOBAL_DATA_PTR,指定占用寄存器R8。2.bd_t : board info数据结构定义,位于文件 include/asm-arm/u-boot.h。保存板子参数。#ifndef _ASM_GBL_DATA_H#define _ASM_GBL_DATA_H/* 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 大于gd_t的大小*/typedef struct global_databd_t*bd; /开发板相关参数,结构体变量,参考u-boot.hunsigned long flags; /指示标志,如设备已经初始化标志等unsigned long baudrate; /串行口通讯速率unsigned long have_console; /* serial_init() was called console_init()中使用控制台*/unsigned long reloc_off; /* Relocation Offset 重定位偏移,就是实际定向的位置与编译连接时 指定的位置之差,一般为0 */unsigned longenv_addr; /* Address of Environment struct 环境参数地址*/unsigned longenv_valid; /* Checksum of Environment valid? 环境参数CRC检验有效标志*/unsigned longfb_base; /* base address of frame buffer 帧缓冲区基地址*/#ifdef CONFIG_VFDunsigned charvfd_type; /* display type 显示类型*/#endif#if 0unsigned long cpu_clk; /* CPU clock in Hz! cpu时钟 */unsigned long bus_clk; / 总线时钟unsigned long ram_size; /* RAM size of ram大小 */unsigned long reset_status; /* reset status register at boot */#endifvoid *jt; /* jump table 跳转表,用来函数调用地址登记 */gd_t;/* Global Data Flags 全局数据标志*/#define GD_FLG_RELOC 0x00001 /* Code was relocated to RAM 代码装载到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)#endif /* _ASM_GBL_DATA_H */typedef struct bd_info int bi_baudrate;/* serial console baudrate 串口波特率 */unsigned long bi_ip_addr; /* IP Address IP 地址 */unsigned char bi_enetaddr6;/* Ethernet adress MAC地址*/struct environment_s *bi_env; /结构体变量定义见46行ulong bi_arch_number; /* unique id for this board 板子的id*/ulong bi_boot_params;/* where this board expects params 启动参数*/struct /* RAM configuration RAM 配置*/ulong start;ulong size; bi_dramCONFIG_NR_DRAM_BANKS;bd_t;=下面是lib_armboard.c文件分析/* Breathe some life into the board. /给开发板注入些活力* Initialize a serial port as console, and carry out some hardware* tests.*初始化串口作为控制台并实现硬件测试* The first part of initialization is running from Flash memory;* its main purpose is to initialize the RAM so that we* can relocate the monitor code to RAM.初始化的第一个阶段是在flash中运行,主要目的是初始化ram以便于可以重载监控代码到ram里*/* All attempts to come up with a common initialization sequence* that works for all boards and architectures failed: some of the* requirements are just _too_ different. To get rid of the resulting* mess of board dependent #ifdefed code we now make the whole* initialization sequence configurable to the user.*试图提出一个公共的初始化序列应用于所有开发板和体系结构几乎是不可能的。为避免开发板混乱需要依赖条件编译代码。* The requirements for any new initalization function is simple: it* receives a pointer to the global data structure as its only* argument, and returns an integer return code, where 0 means* continue and != 0 means fatal error, hang the system.任何新的初始化函数的要求都是简单的:函数接受一个指针参数作为全局数据结构,返回整型数据类型,为0表示继续,非0表示致命错误,系统挂起*/typedef int (init_fnc_t) (void); /自定义数据类型/*初始化函数序列init_sequenceinit_sequence数组保存着基本的初始化函数指针。这些函数名称和实现的程序文件在下列注释中。*/init_fnc_t*init_sequence= cpu_init, /* basic cpu dependent setup 基本的处理器相关配置- cpu/s3c44b0/cpu.c */board_init, /* basic board dependent setup 基本的板级相关配置- board/hfrk/hfrks3c44b0/hfrks3c44b0.c*/interrupt_init, /* set up exceptions 初始化例外处理- cpu/s3c44b0/interrupt.c*/env_init, /* initialize environment 初始化环境变量- common/env_flash.c*/init_baudrate, /* initialze baudrate settings 初始化波特率设置- lib_arm/board.c*/serial_init, /* serial communications setup串口通讯设置 - cpu/s3c44b0/serial.c*/console_init_f, /* stage 1 init of console控制台初始化阶段1 - common/console.c*/display_banner, /* say that we are here 打印u-boot信息 - lib_arm/board.c*/dram_init, /* configure available RAM banks 配置可用的DRAM- board/hfrk/hfrks3c44b0/hfrks3c44b0.c*/display_dram_config, /显示RAM的配置大小 - lib_arm/board.c#if defined(CONFIG_VCMA9)checkboard,#endifNULL,;/整个u-boot的执行就进入等待用户输入命令,解析并执行命令的死循环中。/start_armboot是U-Boot执行的第一个C语言函数,完成系统初始化工作,进入主循环,处理用户输入的命令。void start_armboot (void)DECLARE_GLOBAL_DATA_PTR;/*DECLARE_GLOBAL_DATA_PTR 只是一个定义的宏,这个宏定义了一个gd_t全局数据结构的指针, 这个指针存放在指定的寄存器中(386体系结构没有放到指定寄存器中)。这个宏定义在includeasm-armglobe_data.h文件中#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm(r8)声明一个寄存器变量 gd 占用r8。这个宏在所有需要引用全局数据指针gd_t *gd的源码中都有申明。这个申明也避免编译器把r8分配给其它的变量.所以gd就是r8,用r8来保存内存地址,达到全局使用目的,这个指针变量不占用内存。 总结:gd指向一个数据结构,用于保存参数。*/ ulong size;init_fnc_t*init_fnc_ptr; /这个是函数的指针,指向=硬件初始化的函数char *s;#if defined(CONFIG_VFD)unsigned long addr;#endif#if CFG_LED_FLASHLED();#endif/* gd指针可写,因为已经分配一个寄存器给它作为变量。这里就相当于把后面算出来的地址保存到r8寄存器.*/* Pointer is writable since we allocated a register for it */gd = (gd_t*)(_armboot_start -CFG_MALLOC_LEN-sizeof(gd_t); /计算出gd在RAM中的地址memset (void*)gd, 0, sizeof (gd_t);/给全局数据变量gd安排空间,用0填充全局数据表*gdgd-bd = (bd_t*)(char*)gd - sizeof(bd_t);/给板子数据变量gd-bd安排空间memset (gd-bd, 0, sizeof (bd_t); /gd区包含了bd区,gd_t,bd_t都是结构体变量,/用0填充(初始化) *gd-bd board info数据结构定义,位于文件 include/asm-arm/u-boot.hmonitor_flash_len = _bss_start - _armboot_start; / 取u-boot的长度/* 顺序执行init_sequence数组中的初始化函数 */for (init_fnc_ptr = init_sequence; *init_fnc_ptr; +init_fnc_ptr)if (*init_fnc_ptr)() != 0) hang ();/打印错误信息并死锁/* configure available FLASH banks 配置可用的Flash */size = flash_init (); /drivers/cfi_flash.c或自定义display_flash_config (size);#ifdef CONFIG_VFD /如果定义了VFD(真空荧光显示),就定义页面大小为4096B# ifndef PAGE_SIZE# define PAGE_SIZE 4096# endif/* reserve memory for VFD display (always full pages)给VFD保留内存空间,以页为单位*/* armboot_end is defined in the board-specific linker script */addr = (_bss_start + (PAGE_SIZE - 1) & (PAGE_SIZE - 1);size = vfd_setmem (addr);gd-fb_base = addr; /全局数据gd中定义的帧缓冲区的基地址#endif /* CONFIG_VFD */* armboot_start is defined in the board-specific linker script初始化堆空间*/mem_malloc_init (_armboot_start - CFG_MALLOC_LEN);/malloc使用的内存空间地址0x0c700000-129k(0x00080400)#if (CONFIG_COMMANDS & CFG_CMD_NAND) /如果有nandflash的话就在下面的代码中进行初始化puts (NAND:);nand_init(); /* go init the NAND */#endif#ifdef CONFIG_HAS_DATAFLASHAT91F_DataflashInit();dataflash_print_info();#endif/* initialize environment 重新初始化环境,重新定位环境变量参数区,它在/common/env_common.c文件中定义*/env_relocate ();#ifdef CONFIG_VFD/* must do this after the framebuffer is allocated */drv_vfd_init(); /vfd初始化,在分配帧缓冲区之后必须的#endif /* CONFIG_VFD */* IP Address 从环境变量中获取IP地址*/gd-bd-bi_ip_addr = getenv_IPaddr (ipaddr);/* MAC Address 以太网接口MAC 地址*/int i;ulong reg;char *s, *e;uchar tmp64;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 六一物业公司活动策划方案
- 六一端午节活动方案
- 六一艺术节活动方案
- 六一英文活动方案
- 六一迷宫活动方案
- 六一魔术活动方案
- 六年级套圈游戏活动方案
- 安全设备操作试题及答案
- 兰山区政府招商活动方案
- 兰州兰山冬雪活动方案
- 家校社协同劳动教育实施现状与对策研究
- 国家开放大学《农村经济管理》形考任务1-4参考答案
- 铁丝围挡施工方案
- 石家庄事业单位综合类岗位笔试真题2024
- 《宴会国际礼仪》课件
- 【博观研究院】2025年跨境进口保健品市场分析报告
- 叉车安全使用管理制度
- 2025吉林长春市轨道交通集团限公司校园招聘670人高频重点提升(共500题)附带答案详解
- 【MOOC】高分子化学-浙江大学 中国大学慕课MOOC答案
- 【MOOC】西方园林历史与艺术-北京林业大学 中国大学慕课MOOC答案
- 《中医情志护理》课件
评论
0/150
提交评论