do_run
{
arg = getenv (argv[i]));run的参数从环境变量中获得
run_command (arg, flag);
}
bootcmd=run nand_boot
nand_boot=1.echo Booting from nand ...;
2.run nand_args;
nand_args=1.run bootargs_defaults;
bootargs_defaults=setenv bootargs console=${console} ${optargs}
2.setenv bootargs ${bootargs} root=${nand_root} noinitrd rootfstype=${nand_root_fs_type} ip=${ip_method}
*bootargs= console=ttyO0,115200n8 root=ubi0:rootfs rw ubi.mtd=3,2048 noinitrd rootfstype=ubifs rootwait=1 ip=none
3.nand read.i ${kloadaddr} ${nand_src_addr} ${nand_img_siz};
kloadaddr=0x80007fc0;nand_src_addr=0x280000;nand_img_siz=0x400000/4MB
4.bootm ${kloadaddr}
bootm 0x80007fc0=0x80008000-0x40
do_bootm
{
bootm_start
{
bootm_start_lmb//??
boot_get_kernel
{
genimg_get_format ((void *)img_addr); return IMAGE_FORMAT_LEGACY
image_get_kernel (img_addr, images->verify)
{
image_check_magic
image_check_hcrc//对image_header进行crc校验
image_print_contents
if (verify) image_check_dcrc//对数据区进行crc校验
image_check_target_arch
}
case IH_TYPE_KERNEL:
images.os.image_start : *os_data = image_get_data (hdr);//返回内核的入口点地址,0x80008000
images.os.image_len : *os_len = image_get_data_size (hdr);
return (void *)img_addr;//0x80007fc0
}
images.os.type = image_get_type (os_hdr);
images.os.comp = image_get_comp (os_hdr);
images.os.os = image_get_os (os_hdr);
images.os.end = image_get_image_end (os_hdr);
images.os.load = image_get_load (os_hdr);
/* find kernel entry point */
images.ep = image_get_ep (&images.legacy_hdr_os_copy);//0x80008000
boot_get_ramdisk//return 0,No init Ramdisk
images.os.start = (ulong)os_hdr;//0x80007fc0
images.state = BOOTM_STATE_START;
return 0;
}
disable_interrupts();
usb_stop();
bootm_load_os(images.os, &load_end, 1);
{
flush_cache(load, (*load_end - load) * sizeof(ulong));
return BOOTM_ERR_OVERLAP;
}
lmb_reserve
boot_fn = boot_os[images.os.os];//boot_os[5]=do_bootm_linux
arch_preboot_os();
boot_fn(0, argc, argv, &images);//do_bootm_linux
{
int machid = bd->bi_arch_number;//3589
char *commandline = getenv ("bootargs");
//console=ttyO0,115200n8 root=ubi0:rootfs rw ubi.mtd=3,2048 noinitrd rootfstype=ubifs rootwait=1 ip=none
kernel_entry = (void (*)(int, int, uint))images->ep;//0x80008000
//TAG 设置
setup_start_tag (bd);
{
params = (struct tag *) bd->bi_boot_params;//0x80000100
params->hdr.tag = ATAG_CORE;
params->hdr.size = tag_size (tag_core);
params->u.core.flags = 0;
params->u.core.pagesize = 0;
params->u.core.rootdev = 0;
params = tag_next (params);
}
setup_memory_tags (bd);
setup_commandline_tag (bd, commandline);
{
params->hdr.tag = ATAG_CMDLINE;
params->hdr.size =(sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2;
strcpy (params->u.cmdline.cmdline, p);
params = tag_next (params);
}
setup_end_tag(bd);
announce_and_cleanup();
{
cleanup_before_linux();*******
{
}
}
kernel_entry(0, machid, bd->bi_boot_params);//machid=3589;bd->bi_boot_params=0x80000100,保存tag
/* does not return */ //跳转到Linux kernel执行
}
}