Skip to content
Snippets Groups Projects
cmd_bootm.c 46.4 KiB
Newer Older
Wolfgang Denk's avatar
Wolfgang Denk committed
/*
 * (C) Copyright 2000-2009
Wolfgang Denk's avatar
Wolfgang Denk committed
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

Wolfgang Denk's avatar
Wolfgang Denk committed
/*
 * Boot support
 */
#include <common.h>
#include <watchdog.h>
#include <command.h>
#include <image.h>
#include <malloc.h>
#include <bzlib.h>
#include <environment.h>
Kumar Gala's avatar
Kumar Gala committed
#include <linux/ctype.h>
Wolfgang Denk's avatar
Wolfgang Denk committed
#include <asm/byteorder.h>
#include <linux/compiler.h>
Wolfgang Denk's avatar
Wolfgang Denk committed

#if defined(CONFIG_CMD_USB)
#include <usb.h>
#endif

#ifdef CONFIG_SYS_HUSH_PARSER
Wolfgang Denk's avatar
Wolfgang Denk committed
#include <hush.h>
#endif

#if defined(CONFIG_OF_LIBFDT)
#include <libfdt.h>
#include <fdt_support.h>
#endif

#ifdef CONFIG_LZMA
#include <lzma/LzmaTypes.h>
#include <lzma/LzmaDec.h>
#include <lzma/LzmaTools.h>
#endif /* CONFIG_LZMA */

#ifdef CONFIG_LZO
#include <linux/lzo.h>
#endif /* CONFIG_LZO */

DECLARE_GLOBAL_DATA_PTR;
#ifndef CONFIG_SYS_BOOTM_LEN
#define CONFIG_SYS_BOOTM_LEN	0x800000	/* use 8MByte as default max gunzip size */
#ifdef CONFIG_BZIP2
extern void bz_internal_error(int);
Wolfgang Denk's avatar
Wolfgang Denk committed
#endif

static int image_info(unsigned long addr);
Wolfgang Denk's avatar
Wolfgang Denk committed
#endif
#if defined(CONFIG_CMD_IMLS)
#include <mtd/cfi_flash.h>
extern flash_info_t flash_info[]; /* info for FLASH chips */
#endif

#if defined(CONFIG_CMD_IMLS) || defined(CONFIG_CMD_IMLS_NAND)
static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
#include <linux/err.h>
#include <nand.h>

#if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY)
static void fixup_silent_linux(void);
Wolfgang Denk's avatar
Wolfgang Denk committed

static image_header_t *image_get_kernel(ulong img_addr, int verify);
static int fit_check_kernel(const void *fit, int os_noffset, int verify);
static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
				char * const argv[], bootm_headers_t *images,
				ulong *os_data, ulong *os_len);
Wolfgang Denk's avatar
Wolfgang Denk committed

/*
 *  Continue booting an OS image; caller already has:
 *  - copied image header to global variable `header'
 *  - checked header magic number, checksums (both header & image),
 *  - verified image architecture (PPC) and type (KERNEL or MULTI),
 *  - loaded (first part of) image to header load address,
 *  - disabled interrupts.
 */
typedef int boot_os_fn(int flag, int argc, char * const argv[],
			bootm_headers_t *images); /* pointers to os/initrd/fdt */
#ifdef CONFIG_BOOTM_LINUX
extern boot_os_fn do_bootm_linux;
#endif
#ifdef CONFIG_BOOTM_NETBSD
static boot_os_fn do_bootm_netbsd;
static boot_os_fn do_bootm_lynxkdi;
extern void lynxkdi_boot(image_header_t *);
Wolfgang Denk's avatar
Wolfgang Denk committed
#endif
#ifdef CONFIG_BOOTM_RTEMS
static boot_os_fn do_bootm_rtems;
#if defined(CONFIG_BOOTM_OSE)
static boot_os_fn do_bootm_ose;
#endif
#if defined(CONFIG_BOOTM_PLAN9)
static boot_os_fn do_bootm_plan9;
#endif
static boot_os_fn do_bootm_vxworks;
static boot_os_fn do_bootm_qnxelf;
int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
int do_bootelf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
#if defined(CONFIG_INTEGRITY)
static boot_os_fn do_bootm_integrity;
#endif
Wolfgang Denk's avatar
Wolfgang Denk committed

static boot_os_fn *boot_os[] = {
#ifdef CONFIG_BOOTM_LINUX
	[IH_OS_LINUX] = do_bootm_linux,
#endif
#ifdef CONFIG_BOOTM_NETBSD
	[IH_OS_NETBSD] = do_bootm_netbsd,
#ifdef CONFIG_LYNXKDI
	[IH_OS_LYNXOS] = do_bootm_lynxkdi,
#endif
#ifdef CONFIG_BOOTM_RTEMS
	[IH_OS_RTEMS] = do_bootm_rtems,
#if defined(CONFIG_BOOTM_OSE)
	[IH_OS_OSE] = do_bootm_ose,
#endif
#if defined(CONFIG_BOOTM_PLAN9)
	[IH_OS_PLAN9] = do_bootm_plan9,
#endif
#if defined(CONFIG_CMD_ELF)
	[IH_OS_VXWORKS] = do_bootm_vxworks,
	[IH_OS_QNX] = do_bootm_qnxelf,
#endif
#ifdef CONFIG_INTEGRITY
	[IH_OS_INTEGRITY] = do_bootm_integrity,
#endif
};

bootm_headers_t images;		/* pointers to os/initrd/fdt images */
/* Allow for arch specific config before we boot */
static void __arch_preboot_os(void)
{
	/* please define platform specific arch_preboot_os() */
}
void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));

#define IH_INITRD_ARCH IH_ARCH_DEFAULT
Wolfgang Denk's avatar
Wolfgang Denk committed

#ifdef CONFIG_LMB
static void boot_start_lmb(bootm_headers_t *images)
{
	ulong		mem_start;
	phys_size_t	mem_size;
Wolfgang Denk's avatar
Wolfgang Denk committed

	lmb_init(&images->lmb);
Wolfgang Denk's avatar
Wolfgang Denk committed

	mem_start = getenv_bootm_low();
	mem_size = getenv_bootm_size();
Wolfgang Denk's avatar
Wolfgang Denk committed

	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
Wolfgang Denk's avatar
Wolfgang Denk committed

	arch_lmb_reserve(&images->lmb);
	board_lmb_reserve(&images->lmb);
}
#define lmb_reserve(lmb, base, size)
Loading
Loading full blame...