幸福散论阅读:u-boot笔记

来源:百度文库 编辑:偶看新闻 时间:2024/06/12 12:04:43
Under Unix, the system and various applications programs (especially the linker) distinguish between types of executable file by looking for a magic number.
GOT的意思就是全局表
从START_GOT到END_GOT这段代码定义了一个got2段,在这个段里面就定义了一张供调用的全局表。此表中的每条表项有两个字段,第一个为此当前表项距got2表起始地址的偏移,第二个为这条表项目的值,此值其实就是"NAME" symbol对应的编译时的值.
GOT_ENTRY宏的目的是为了初始化r14寄存器,在此宏中通过计算得到了got2表实际的虚拟地址并存放在r14中。

GPR:
r0 :在函数开始时使用
r1 :存放堆栈指针,相当于ia32架构中的esp寄存器
r2 :存放内容(toc)指针,
r3 :存放第一个参数和返回地址
r4-r10 :存放函数的参数
r11 :用在指针的调用和当前一些语言的环境指针
r12 :用于存放异常处理
r13 :保留做为系统线程ID
r14-r31 :作为本地变量,具有非易失性
 CFG_LOAD_ADDR? What load adress is it? For the kernel or for u-boot It's the default value for the "loadaddr"environment variable. It hasnothing to do with the relocation of U-Boot to RAM.
loadaddr: Default load address for commands like tftp or loads.
> relocated in RAM? And in the board-specific file config.mk, what exactly > describes TEXT_BASE?It's the address where the text segment of your image will start. Inother words, TEXT_BASE+0x100 is typically the reset entry point foryour system. See cpu/*/start.S

CONFIG_SYS_TEXT_BASE变量在uboot的两次链接过程都用到,对应的选项是-Ttext $(CONFIG_SYS_TEXT_BASE)指定了
text segment的起始链接地址。
从lowlevel_init出来之后执行call_board_init_f,通过读取OMR_OFFSET寄存器的值,对启动设备进行判断,看看是从mmc启动还是nand启动,判断好后跳入mmc_boot.c或nand_cp.c中,将UBOOT代码拷贝到内存中,地址为_TEXT_BASE:在tiny210.h中定义为0x23e0_0000,换成别的地方也可以,比如3000_0000(注:在跳转到内存中执行之前,所有的语句都是基于PC寻址的,也就是说和代码具体存放的地址没有关系,进行跳转的时候都会计算出跳转目标相对与PC的位置,在跳转过去。)。
为UBOOT的重定向设置物理地址,重定向后UBOOT可使用的end地址为0x3fff_0000,UBOOT镜像起始地址为0x3ff8_5000。
+- CONFIG_SYS_TEXT_BASE:+- ARM:+Is the address of the u-boot code that is loaded in memory. +This value can be in ROM space since u-boot can run from+within ROM. CONFIG_SYS_TEXT_BASE is simply called _TEXT_BASE+in some files, like arch/arm/lib/board.c.+This value has nothing to do with the relocation destination+in RAM. See doc/README.arm-relocation for more info.