1、init_raw_area_table函数调用关系
start.s
start_armboot()
mmc_initialize()
mmc_init()
mmc_startup()
init_raw_area_table()
2、struct raw_area结构体 & struct member结构体
typedef struct raw_area {
uint magic_number;
uint start_blk;
uint total_blk;
uint next_raw_area;
char description[16];
member_t image[15];
} raw_area_t;
typedef struct member {
uint start_blk;
uint used_blk;
uint size;
uint attribute;
char description[16];
} member_t;
3、init_raw_area_table()函数功能分析
(1)主要是就是初始化全局变量raw_area_control的image成员变量,image数组里记录了每个分区的起始扇区、大小等信息; (2)初始化image数组的宏定义在./include/movi.h中定义; (3)uboot在读写分区时,就是按照iamge中描述的分区信息(扇区号、大小)进行操作;
4、init_raw_area_table()函数代码
raw_area_t raw_area_control;
int init_raw_area_table (block_dev_desc_t * dev_desc)
{
struct mmc *host = find_mmc_device(dev_desc->dev);
if (raw_area_control.magic_number != MAGIC_NUMBER_MOVI) {
int i = 0;
member_t *image;
u32 capacity;
if (host->high_capacity) {
capacity = host->capacity;
} else {
capacity = host->capacity;
}
dev_desc->block_read(dev_desc->dev,
capacity - (eFUSE_SIZE/MOVI_BLKSIZE) - 1,
1, &raw_area_control);
if (raw_area_control.magic_number == MAGIC_NUMBER_MOVI) {
return 0;
}
dbg("Warning: cannot find the raw area table(%p) %08x\n",
&raw_area_control, raw_area_control.magic_number);
raw_area_control.magic_number = MAGIC_NUMBER_MOVI;
raw_area_control.start_blk = 16*1024*1024/MOVI_BLKSIZE;
raw_area_control.total_blk = capacity;
raw_area_control.next_raw_area = 0;
strcpy(raw_area_control.description, "initial raw table");
image = raw_area_control.image;
image[1].start_blk = (eFUSE_SIZE/MOVI_BLKSIZE);
image[1].used_blk = MOVI_BL1_BLKCNT;
image[1].size = SS_SIZE;
image[1].attribute = 0x1;
strcpy(image[1].description, "u-boot parted");
dbg("bl1: %d\n", image[1].start_blk);
image[2].start_blk = image[1].start_blk + MOVI_BL1_BLKCNT;
image[2].used_blk = MOVI_ENV_BLKCNT;
image[2].size = CFG_ENV_SIZE;
image[2].attribute = 0x10;
strcpy(image[2].description, "environment");
dbg("env: %d\n", image[2].start_blk);
image[3].start_blk = image[2].start_blk + MOVI_ENV_BLKCNT;
image[3].start_blk = image[2].start_blk - MOVI_BL2_BLKCNT;
image[3].used_blk = MOVI_BL2_BLKCNT;
image[3].size = PART_SIZE_BL;
image[3].attribute = 0x2;
strcpy(image[3].description, "u-boot");
dbg("bl2: %d\n", image[3].start_blk);
image[4].start_blk = image[3].start_blk + MOVI_BL2_BLKCNT;
image[4].used_blk = MOVI_ZIMAGE_BLKCNT;
image[4].size = PART_SIZE_KERNEL;
image[4].attribute = 0x4;
strcpy(image[4].description, "kernel");
dbg("knl: %d\n", image[4].start_blk);
image[5].start_blk = image[4].start_blk + MOVI_ZIMAGE_BLKCNT;
image[5].used_blk = MOVI_ROOTFS_BLKCNT;
image[5].size = PART_SIZE_ROOTFS;
image[5].attribute = 0x8;
strcpy(image[5].description, "rfs");
dbg("rfs: %d\n", image[5].start_blk);
for (i=6; i<15; i++) {
raw_area_control.image[i].start_blk = 0;
raw_area_control.image[i].used_blk = 0;
}
}
}
5、SD卡/iNand的分区情况
iamge数组 | 扇区号 | 分区名 | 大小 | 分区名 |
---|
0 | 0 | MBR | 512B | 引导扇区 | 1 | 1-16 | BL1 | 8KB | u-boot parted(BL1) | 2 | 17-48 | environment | 16KB | environment | 3 | 49-1072 | BL2 | 512KB | u-boot(BL2,完整的uboot) | 4 | 1073-9264 | kernel | 4MB | kernel | 5 | 9265-62512 | rootfs | 26MB | rfs | 6-14 | 62512-100% | 未分配 | 剩余全部 | 未分配 |
|