int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { ulong iflag; ulong load_end = 0; int ret; boot_os_fn *boot_fn; #ifndef CONFIG_RELOC_FIXUP_WORKS static int relocated = 0; /* relocate boot function table */ if (!relocated) { int i; for (i = 0; i < ARRAY_SIZE(boot_os); i++) if (boot_os[i] != NULL) boot_os[i] += gd->reloc_off; relocated = 1; } #endif /* determine if we have a sub command */ if (argc > 1) { char *endp;
simple_strtoul(argv[1], &endp, 16); if ((*endp != 0) && (*endp != ':') && (*endp != '#')) return do_bootm_subcommand(cmdtp, flag, argc, argv); }
if (bootm_start(cmdtp, flag, argc, argv)) //提取mkimage生成的文件头部,放到bootm_headers_t结构体中 return 1;
iflag = disable_interrupts();
#if defined(CONFIG_CMD_USB) usb_stop(); #endif
#ifdef CONFIG_AMIGAONEG3SE /* * We've possible left the caches enabled during * bios emulation, so turn them off again */ icache_disable(); dcache_disable(); #endif
ret = bootm_load_os(images.os, &load_end, 1); //加载操作系统的关键部分 确定使用的地址 if (ret < 0) { //出错处理 if (ret == BOOTM_ERR_RESET) do_reset (cmdtp, flag, argc, argv); if (ret == BOOTM_ERR_OVERLAP) { if (images.legacy_hdr_valid) { if (image_get_type (&images.legacy_hdr_os_copy) == IH_TYPE_MULTI) puts ("WARNING: legacy format multi component " "image overwritten\n"); } else { puts ("ERROR: new format image overwritten - " "must RESET the board to recover\n"); show_boot_progress (-113); do_reset (cmdtp, flag, argc, argv); } } if (ret == BOOTM_ERR_UNIMPLEMENTED) { if (iflag) enable_interrupts(); show_boot_progress (-7); return 1; } } lmb_reserve(&images.lmb, images.os.load, (load_end - images.os.load));
if (images.os.type == IH_TYPE_STANDALONE) {//独立的应用程序 if (iflag) enable_interrupts(); /* This may return when 'autostart' is 'no' */ bootm_start_standalone(iflag, argc, argv); return 0; } show_boot_progress (8);
#ifdef CONFIG_SILENT_CONSOLE //这里处理Linux操作系统 if (images.os.os == IH_OS_LINUX) fixup_silent_linux(); //该函数中处理bootarg参数 #endif boot_fn = boot_os[images.os.os]; if (boot_fn == NULL) { if (iflag) enable_interrupts(); printf ("ERROR: booting os '%s' (%d) is not supported\n", genimg_get_os_name(images.os.os), images.os.os); show_boot_progress (-8); return 1; }
arch_preboot_os(); /*下面的函数,继续引导内核的镜像,复制image header 到全局变量header; 检查header的魔数,检查数,header和image中的这两个。确定image的体系结构和类型(KERNEL or MULTI),关闭中断,加载image到header中的加载地址*/ boot_fn(0, argc, argv, &images); //调用do_bootm_linux()函数 show_boot_progress (-9); #ifdef DEBUG puts ("\n## Control returned to monitor - resetting...\n"); #endif do_reset (cmdtp, flag, argc, argv);
return 1; }
|