初始化linux内核镜像结构
static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc,char * const argv[])
{memset((void *)&images, 0, sizeof(images));images.verify = env_get_yesno("verify");boot_start_lmb(&images);bootstage_mark_name(BOOTSTAGE_ID_BOOTM_START, "bootm_start");images.state = BOOTM_STATE_START;return 0;
}
读取内核镜像头部,获取os和initrd基地址和大小
static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc,char * const argv[])
{/* get kernel image header, start address and length */os_hdr = boot_get_kernel(cmdtp, flag, argc, argv,&images, &images.os.image_start, &images.os.image_len);}
修正上一步获取的initrd基地址
int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,ulong *initrd_start, ulong *initrd_end)
{*initrd_start = (ulong)lmb_alloc_base(lmb, rd_len, 0x1000, initrd_high);//挪到新的地址memmove_wd((void *)*initrd_start, (void *)rd_data, rd_len, CHUNKSZ);return 0;
}
将initrd地址保存在设备树,将来用于内核解析
int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end)
{err = fdt_setprop_uxx(fdt, nodeoffset, "linux,initrd-start",(uint64_t)initrd_start, is_u64);err = fdt_setprop_uxx(fdt, nodeoffset, "linux,initrd-end",(uint64_t)initrd_end, is_u64);
}
ramdisk与 initrd、initramfs的关系
https://blog.csdn.net/findstr/article/details/6990801