X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fcmd_bootm.c;h=365ceebdf0672c0260ac5c2314939a1b65552845;hb=9179dd3bf5c257d1479fb4a154b57f33e3d839be;hp=68f167594ccca38e37bf7fe5341f1c83d802924c;hpb=62c3ae7c6ef215b1afa614abdf61acf077752207;p=oweals%2Fu-boot.git diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 68f167594c..365ceebdf0 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 @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -52,9 +52,8 @@ #endif #ifdef CONFIG_LZMA -#define _7ZIP_BYTE_DEFINED /* Byte already defined by zlib */ #include -#include +#include #include #endif /* CONFIG_LZMA */ @@ -167,6 +166,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__) @@ -340,8 +346,10 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) } else { printf (" Loading %s ... ", type_name); - memmove_wd ((void *)load, - (void *)image_start, image_len, CHUNKSZ); + if (load != image_start) { + memmove_wd ((void *)load, + (void *)image_start, image_len, CHUNKSZ); + } } *load_end = load + image_len; puts("OK\n"); @@ -388,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); @@ -416,6 +424,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[] = { @@ -524,6 +550,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; } @@ -547,7 +574,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) 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; } @@ -627,6 +655,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 @@ -635,6 +671,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); @@ -816,6 +864,13 @@ 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: + if (argc >2) { + hdr->ih_load = htonl(simple_strtoul(argv[2], NULL, 16)); + } + *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); @@ -913,7 +968,7 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] U_BOOT_CMD( bootm, CONFIG_SYS_MAXARGS, 1, do_bootm, - "bootm - boot application image from memory\n", + "boot application image from memory", "[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" @@ -946,7 +1001,7 @@ U_BOOT_CMD( "\tbdt - OS specific bd_t processing\n" "\tcmdline - OS specific command line processing/setup\n" "\tprep - OS specific prep before relocation or go\n" - "\tgo - start OS\n" + "\tgo - start OS" ); /*******************************************************************/ @@ -970,15 +1025,15 @@ int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( boot, 1, 1, do_bootd, - "boot - boot default, i.e., run 'bootcmd'\n", - NULL + "boot default, i.e., run 'bootcmd'", + "" ); /* keep old command name "bootd" for backward compatibility */ U_BOOT_CMD( bootd, 1, 1, do_bootd, - "bootd - boot default, i.e., run 'bootcmd'\n", - NULL + "boot default, i.e., run 'bootcmd'", + "" ); #endif @@ -1062,11 +1117,11 @@ static int image_info (ulong addr) U_BOOT_CMD( iminfo, CONFIG_SYS_MAXARGS, 1, do_iminfo, - "iminfo - print header information for application image\n", + "print header information for application image", "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 @@ -1130,10 +1185,10 @@ next_bank: ; U_BOOT_CMD( imls, 1, 1, do_imls, - "imls - list all images found in flash\n", + "list all images found in flash", "\n" " - Prints information about all images found at sector\n" - " boundaries in flash.\n" + " boundaries in flash." ); #endif