Chinaunix首页 | 论坛 | 博客
  • 博客访问: 217690
  • 博文数量: 49
  • 博客积分: 2101
  • 博客等级: 大尉
  • 技术积分: 525
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-07 10:38
文章分类

全部博文(49)

文章存档

2010年(49)

我的朋友

分类: 嵌入式

2010-09-07 14:38:06

1 gd

gdglobal data的缩写,它是uboot中最顶的数据结构。该数据结构在include\asm-ppc\Global_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)

 */

typedef    struct      global_data

{

……

} gd_t;

同时,在该头文件的末尾,使用gd_t定义了一个指针gd

lib_ppc\Board.c中的board_init_f()函数中,把gd指针指向MPC8xxCPM中的DPRAMDPRAM作为一个双口RAM,是可以作为用户的内存使用的。U-boot巧妙的使用了DPRAM,把gd数据存放在里面。

另外,在board_init_f()中,实际还将gd数据结构完整的复制到了下述bd结构的后面。

 

2 bd

bdlib_ppc\Board.c中的board_init_f()函数起始处定义:

bd_t *bd;

bd_t数据结构在\include\asm-ppc\U-boot.h中定义:

/*

 * Board information passed to Linux kernel from U-Boot

 *

 * include/asm-ppc/u-boot.h

*/

typedef struct bd_info

{

……

} bd_t;

注意看注释,bd_t里面的信息是u-boot传递给LINUX内核的,那么linux内核的运行参数是放在这里的吗?

现在看看bd指针具体指向哪块内存。关于内存的使用,在board_init_f()中有这么一段注释:

/*

        * Now that we have DRAM mapped and working, we can

        * relocate the code and continue running from DRAM.

        *

        * Reserve memory at end of RAM for (top down in that order):

        *  - kernel log buffer

        *  - protected RAM

        *  - LCD framebuffer

        *  - monitor code

        *  - board info struct

        */

表明,当u-boot拷贝到内存时,内存是如何使用的。上述是从上到下列出了各个逻辑块。其中,最后一块board info struct就是bd指针指向的地方。注意,在最后一块后面实际上还拷贝了gd的信息。关于,内存如何一点一点分配的,可以阅读board_init_f()代码。

 

 

3 GOT

Global offset table

据说:GOT表里放的是gd_t (global data) 变量。romram里都要用到的函数地址被放入GOT表,将来程序从rom搬至ram时,只需在GOT中变量地址的基础上加偏移量即可。start.SGET_GOT就是对GOT的调用

START_GOT
GOT_ENTRY(_GOT2_TABLE_)
GOT_ENTRY(_FIXUP_TABLE_)
GOT_ENTRY(_start)
GOT_ENTRY(_start_of_vectors)
GOT_ENTRY(_end_of_vectors)
GOT_ENTRY(transfer_to_handler)
GOT_ENTRY(__init_end)
GOT_ENTRY(_end)
GOT_ENTRY(__bss_start)
END_GOT

阅读(934) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~