一、global_data(include/asm-arm/global_data.h)
typedef struct global_data { bd_t *bd; unsigned long flags; unsigned long baudrate; unsigned long have_console; /* serial_init() was called */ unsigned long reloc_off; /* Relocation Offset */ unsigned long env_addr; /* Address of Environment struct */ unsigned long env_valid; /* Checksum of Environment valid? */ unsigned long fb_base; /* base address of frame buffer */ #ifdef CONFIG_VFD unsigned char vfd_type; /* display type */ #endif #if 0 unsigned long cpu_clk; /* CPU clock in Hz! */ unsigned long bus_clk; unsigned long ram_size; /* RAM size */ unsigned long reset_status; /* reset status register at boot */ #endif void **jt; /* jump table */ } gd_t;
include/asm-arm/global_data.h,定义了全局变量指针r8,可以说全局变量区不像普通变量可以用变量名访问,它只能用指针访问。
#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("r8")
r8在start_armboot(lib_arm/board.c)函数的开始处赋值
/* Pointer is writable since we allocated a register for it */ gd = (gd_t*)(_armboot_start - CFG_MALLOC_LEN - sizeof(gd_t));
通过计算便能得到r8的值,不同的开发板配置可能不一样,但是算法是一样的,这里算得的结果是0x33f4ffdc。从内存中查看到底存的是什么东东。
1、bd =>>0x33f4ffb8,bd指针
2、flag =>>0x02
3、 baudrate =>>0x0001c200=115200,串口波特率
4、have_console =>>0x01
5、reloc_off =>>0x0
6、env_addr =>>0x33f5a164,环境变量的分配内存地址,这个值在堆区
7、 env_valid =>>0x01,环境变量已经设置完成
8、fb_base =>>0x0,显示器缓冲区
9、jt =>>0x33f61bc0,跳转函数表指针
总共:36 Bytes
二、bd_info (include/asm-arm/u-boot.h)
typedef struct bd_info { int bi_baudrate; /* serial console baudrate */ unsigned long bi_ip_addr; /* IP Address */ unsigned char bi_enetaddr[6]; /* Ethernet adress */ struct environment_s *bi_env; ulong bi_arch_number; /* unique id for this board */ ulong bi_boot_params; /* where this board expects params */ struct /* RAM configuration */ { ulong start; ulong size; } bi_dram[CONFIG_NR_DRAM_BANKS]; #ifdef CONFIG_HAS_ETH1 /* second onboard ethernet port */ unsigned char bi_enet1addr[6]; #endif } bd_t;
1、 bi_baudrate=>>0x0001c200,串口波特率
2、 bi_ip_addr=>>0x6e00000a,ip地址
3、 bi_enetaddr=>>0x00000000 、0x00000000
注意:它虽然需要6个字节,但编译器对齐分配的时候取了8个字节
4、bi_env=>>0x0
5、 bi_arch_number=>>0xc1,机器码,对应着MACH_TYPE_S3C2410
6、bi_boot_params=>>0x30000100,启动参数
7、 bi_dram[CONFIG_NR_DRAM_BANKS],DRAM信息
smdk2410中定义CONFIG_NR_DRAM_BANKS为1
1> start=>>0x30000000,DRAM起始地址
2> size=>>0x04000000,DRAM大小
总共:36 Bytes
三、environment_s(include/environment.h)
typedef struct environment_s { unsigned long crc; /* CRC32 over data bytes */ #ifdef CFG_REDUNDAND_ENVIRONMENT unsigned char flags; /* active/obsolete flags */ #endif unsigned char data[ENV_SIZE]; /* Environment data */ } env_t;
1、crc
crc校验值如图所示为0x48ec48fd
2、环境变量打印效果
所有的环境变量打印的效果,打印的顺序是依据其在内存中排放的先后顺序
65532为分配的环境变量区大小,127是当前使用大小
3、环境变量完整内存
环境变量对应的二进制内存值
结论:
1>一个环境变量以“空”结束
2>每个环境变量等号前边的是其名字,等号后边的是其值(值也是以字符串存储在内存中,计算机真正使用
还需要转换)
3>所有环境变量的最后边以“空”结束