歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> Linux內核

U-Boot啟動Linux內核

1、

U_BOOT_CMD(
   bootm, CFG_MAXARGS, 1,do_bootm,
  "bootm   - boot application image from memory\n",
  "[addr [arg ...]]\n    - boot application image stored in memory\n"
  "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
  "\t'arg' can be the address of an initrd image\n"
#ifdef CONFIG_OF_FLAT_TREE
"\tWhen booting a Linux kernel which requires a flat device-tree\n"
"\ta third argument is required which is the address of the of the\n"
"\tdevice-tree blob. To boot that kernel without an initrd image,\n"
"\tuse a '-' for the second argument. If you do not pass a third\n"
"\ta bd_info struct will be passed instead\n"
#endif
);

根據上面可知:bootm命令的執行函數是do_bootm,函數的最大參數是CFG_MAXARGS。

U-Boot源代碼下載地址 http://www.linuxidc.com/Linux/2011-07/38897.htm

2、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函數。

Copyright © Linux教程網 All Rights Reserved