Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / U-Boot启动Linux内核

1、U_BOOT_CMD(
   bootm, CFG_MAXARGS, 1,do_bootm,
  "bootm   - boot application image from memory ",
  "[addr [arg ...]]    - boot application image stored in memory "
  " passing arguments "arg ..."; when booting a Linux kernel, "
  " "arg" can be the address of an initrd image "
#ifdef CONFIG_OF_FLAT_TREE
" When booting a Linux kernel which requires a flat device-tree "
" a third argument is required which is the address of the of the "
" device-tree blob. To boot that kernel without an initrd image, "
" use a "-" for the second argument. If you do not pass a third "
" a bd_info struct will be passed instead "
#endif
);
根据上面可知:bootm命令的执行函数是do_bootm,函数的最大参数是CFG_MAXARGS。U-Boot源代码下载地址 http://www.linuxidc.com/Linux/2011-07/38897.htm2、do_bootm函数源码摘要:SHOW_BOOT_PROGRESS (8);


#if defined(CONFIG_ZIMAGE_BOOT) || defined(CONFIG_IMAGE_BOOT)
after_header_check:
#endif
switch (hdr->ih_os) {
default: /* handled by (original) Linux case */
case IH_OS_LINUX:
#ifdef CONFIG_SILENT_CONSOLE
   fixup_silent_linux();
#endif
   do_bootm_linux  (cmdtp, flag, argc, argv,
    addr, len_ptr, verify);
   break;
case IH_OS_NETBSD:
   do_bootm_netbsd (cmdtp, flag, argc, argv,
    addr, len_ptr, verify);
   break;


#ifdef CONFIG_LYNXKDI
case IH_OS_LYNXOS:
   do_bootm_lynxkdi (cmdtp, flag, argc, argv,
    addr, len_ptr, verify);
   break;
#endif


case IH_OS_RTEMS:
   do_bootm_rtems (cmdtp, flag, argc, argv,
    addr, len_ptr, verify);
   break;


#if (CONFIG_COMMANDS & CFG_CMD_ELF)
case IH_OS_VXWORKS:
   do_bootm_vxworks (cmdtp, flag, argc, argv,
     addr, len_ptr, verify);
   break;
case IH_OS_QNX:
   do_bootm_qnxelf (cmdtp, flag, argc, argv,
     addr, len_ptr, verify);
   break;
#endif /* CFG_CMD_ELF */
#ifdef CONFIG_ARTOS
case IH_OS_ARTOS:
   do_bootm_artos  (cmdtp, flag, argc, argv,
    addr, len_ptr, verify);
   break;
#endif
}
可知,do_bootm函数调用do_bootm_linux函数启动Linux内核,当定义了CONFIG_PPC是,将使用common/cmd_bootm.c文件中的do_bootm_linux;当没有定义时,将调用lib_arm/armlinux.c文件中的do_bootm_linux函数。