X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fcmd_bootm.c;h=05feb39464952f54734211b71bed457882629ad2;hb=a7709d926dbc7cb1541034fcf2b21ce3e838cb12;hp=bd1813ad422a75261b67f7412692999ac5bcd7d2;hpb=0a9403c8c753837a27b14ac33bc2b80d362c0e80;p=u-boot diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index bd1813ad42..05feb39464 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -1,5 +1,5 @@ /* - * (C) Copyright 2000-2006 + * (C) Copyright 2000-2009 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * See file CREDITS for list of people who contributed to this @@ -52,15 +52,17 @@ #endif #ifdef CONFIG_LZMA -#define _7ZIP_BYTE_DEFINED /* Byte already defined by zlib */ #include -#include +#include #include #endif /* CONFIG_LZMA */ +#ifdef CONFIG_LZO +#include +#endif /* CONFIG_LZO */ + DECLARE_GLOBAL_DATA_PTR; -extern int gunzip (void *dst, int dstlen, unsigned char *src, unsigned long *lenp); #ifndef CONFIG_SYS_BOOTM_LEN #define CONFIG_SYS_BOOTM_LEN 0x800000 /* use 8MByte as default max gunzip size */ #endif @@ -103,10 +105,6 @@ extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); typedef int boot_os_fn (int flag, int argc, char *argv[], bootm_headers_t *images); /* pointers to os/initrd/fdt */ -#define CONFIG_BOOTM_LINUX 1 -#define CONFIG_BOOTM_NETBSD 1 -#define CONFIG_BOOTM_RTEMS 1 - #ifdef CONFIG_BOOTM_LINUX extern boot_os_fn do_bootm_linux; #endif @@ -130,7 +128,7 @@ int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); static boot_os_fn do_bootm_integrity; #endif -boot_os_fn * boot_os[] = { +static boot_os_fn *boot_os[] = { #ifdef CONFIG_BOOTM_LINUX [IH_OS_LINUX] = do_bootm_linux, #endif @@ -167,6 +165,13 @@ void __arch_lmb_reserve(struct lmb *lmb) } void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__arch_lmb_reserve"))); +/* Allow for arch specific config before we boot */ +void __arch_preboot_os(void) +{ + /* please define platform specific arch_preboot_os() */ +} +void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os"))); + #if defined(__ARM__) #define IH_INITRD_ARCH IH_ARCH_ARM #elif defined(__avr32__) @@ -288,7 +293,8 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; } - if (images.os.os == IH_OS_LINUX) { + if ((images.os.type == IH_TYPE_KERNEL) && + (images.os.os == IH_OS_LINUX)) { /* find ramdisk */ ret = boot_get_ramdisk (argc, argv, &images, IH_INITRD_ARCH, &images.rd_start, &images.rd_end); @@ -390,7 +396,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) int ret = lzmaBuffToBuffDecompress( (unsigned char *)load, &unc_len, (unsigned char *)image_start, image_len); - if (ret != LZMA_RESULT_OK) { + if (ret != SZ_OK) { printf ("LZMA: uncompress or overwrite error %d " "- must RESET board to recover\n", ret); show_boot_progress (-6); @@ -399,6 +405,24 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) *load_end = load + unc_len; break; #endif /* CONFIG_LZMA */ +#ifdef CONFIG_LZO + case IH_COMP_LZO: + printf (" Uncompressing %s ... ", type_name); + + int ret = lzop_decompress((const unsigned char *)image_start, + image_len, (unsigned char *)load, + &unc_len); + if (ret != LZO_E_OK) { + printf ("LZO: uncompress or overwrite error %d " + "- must RESET board to recover\n", ret); + if (boot_progress) + show_boot_progress (-6); + return BOOTM_ERR_RESET; + } + + *load_end = load + unc_len; + break; +#endif /* CONFIG_LZO */ default: printf ("Unimplemented compression type %d\n", comp); return BOOTM_ERR_UNIMPLEMENTED; @@ -418,6 +442,24 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) return 0; } +static int bootm_start_standalone(ulong iflag, int argc, char *argv[]) +{ + char *s; + int (*appl)(int, char *[]); + + /* Don't start if "autostart" is set to "no" */ + if (((s = getenv("autostart")) != NULL) && (strcmp(s, "no") == 0)) { + char buf[32]; + sprintf(buf, "%lX", images.os.image_len); + setenv("filesize", buf); + return 0; + } + appl = (int (*)(int, char *[]))ntohl(images.ep); + (*appl)(argc-1, &argv[1]); + + return 0; +} + /* we overload the cmd field with our state machine info instead of a * function pointer */ cmd_tbl_t cmd_bootm_sub[] = { @@ -429,8 +471,8 @@ cmd_tbl_t cmd_bootm_sub[] = { #ifdef CONFIG_OF_LIBFDT U_BOOT_CMD_MKENT(fdt, 0, 1, (void *)BOOTM_STATE_FDT, "", ""), #endif - U_BOOT_CMD_MKENT(bdt, 0, 1, (void *)BOOTM_STATE_OS_BD_T, "", ""), U_BOOT_CMD_MKENT(cmdline, 0, 1, (void *)BOOTM_STATE_OS_CMDLINE, "", ""), + U_BOOT_CMD_MKENT(bdt, 0, 1, (void *)BOOTM_STATE_OS_BD_T, "", ""), U_BOOT_CMD_MKENT(prep, 0, 1, (void *)BOOTM_STATE_OS_PREP, "", ""), U_BOOT_CMD_MKENT(go, 0, 1, (void *)BOOTM_STATE_OS_GO, "", ""), }; @@ -500,7 +542,7 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } break; #endif -#ifdef CONFIG_OF_LIBFDT +#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_SYS_BOOTMAPSZ) case BOOTM_STATE_FDT: { ulong bootmap_base = getenv_bootm_low(); @@ -526,6 +568,7 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) break; case BOOTM_STATE_OS_GO: disable_interrupts(); + arch_preboot_os(); boot_fn(BOOTM_STATE_OS_GO, argc, argv, &images); break; } @@ -536,7 +579,6 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /*******************************************************************/ /* bootm - boot application image from image in memory */ /*******************************************************************/ -static int relocated = 0; int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { @@ -544,14 +586,18 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) 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++) - boot_os[i] += gd->reloc_off; + if (boot_os[i] != NULL) + boot_os[i] += gd->reloc_off; relocated = 1; } +#endif /* determine if we have a sub command */ if (argc > 1) { @@ -629,6 +675,14 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) 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 @@ -637,6 +691,18 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #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(); + boot_fn(0, argc, argv, &images); show_boot_progress (-9); @@ -818,6 +884,10 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] case IH_TYPE_MULTI: image_multi_getimg (hdr, 0, os_data, os_len); break; + case IH_TYPE_STANDALONE: + *os_data = image_get_data (hdr); + *os_len = image_get_data_size (hdr); + break; default: printf ("Wrong Image Type for %s command\n", cmdtp->name); show_boot_progress (-5); @@ -945,10 +1015,10 @@ U_BOOT_CMD( #if defined(CONFIG_OF_LIBFDT) "\tfdt - relocate flat device tree\n" #endif - "\tbdt - OS specific bd_t processing\n" "\tcmdline - OS specific command line processing/setup\n" + "\tbdt - OS specific bd_t processing\n" "\tprep - OS specific prep before relocation or go\n" - "\tgo - start OS\n" + "\tgo - start OS" ); /*******************************************************************/ @@ -973,14 +1043,14 @@ int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( boot, 1, 1, do_bootd, "boot default, i.e., run 'bootcmd'", - NULL + "" ); /* keep old command name "bootd" for backward compatibility */ U_BOOT_CMD( bootd, 1, 1, do_bootd, "boot default, i.e., run 'bootcmd'", - NULL + "" ); #endif @@ -1068,7 +1138,7 @@ U_BOOT_CMD( "addr [addr ...]\n" " - print header information for application image starting at\n" " address 'addr' in memory; this includes verification of the\n" - " image contents (magic number, header and payload checksums)\n" + " image contents (magic number, header and payload checksums)" ); #endif @@ -1135,7 +1205,7 @@ U_BOOT_CMD( "list all images found in flash", "\n" " - Prints information about all images found at sector\n" - " boundaries in flash.\n" + " boundaries in flash." ); #endif