X-Git-Url: https://git.kernelconcepts.de/?a=blobdiff_plain;f=common%2Fcmd_bootm.c;h=880320211ee6f36f95a49f1694deae1e234d5c94;hb=1117cbf2adac59050af1751af6c6a524afa5c3ef;hp=86c81220d2cd88030c8d6c0e2050b3ddf06d6d49;hpb=cb32ed1fc298875845f166d326a3f2704a0d5364;p=karo-tx-uboot.git diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 86c81220d2..880320211e 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -57,9 +57,12 @@ #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 @@ -102,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 @@ -129,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 @@ -154,17 +153,12 @@ boot_os_fn * boot_os[] = { ulong load_addr = CONFIG_SYS_LOAD_ADDR; /* Default Load Address */ static bootm_headers_t images; /* pointers to os/initrd/fdt images */ -void __board_lmb_reserve(struct lmb *lmb) -{ - /* please define platform specific board_lmb_reserve() */ -} -void board_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__board_lmb_reserve"))); - -void __arch_lmb_reserve(struct lmb *lmb) +/* Allow for arch specific config before we boot */ +void __arch_preboot_os(void) { - /* please define platform specific arch_lmb_reserve() */ + /* please define platform specific arch_preboot_os() */ } -void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__arch_lmb_reserve"))); +void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os"))); #if defined(__ARM__) #define IH_INITRD_ARCH IH_ARCH_ARM @@ -180,8 +174,6 @@ void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__arch_lmb_re #define IH_INITRD_ARCH IH_ARCH_MICROBLAZE #elif defined(__mips__) #define IH_INITRD_ARCH IH_ARCH_MIPS -#elif defined(__nios__) - #define IH_INITRD_ARCH IH_ARCH_NIOS #elif defined(__nios2__) #define IH_INITRD_ARCH IH_ARCH_NIOS2 #elif defined(__PPC__) @@ -194,15 +186,11 @@ void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__arch_lmb_re # error Unknown CPU type #endif -static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +static void bootm_start_lmb(void) { +#ifdef CONFIG_LMB ulong mem_start; phys_size_t mem_size; - void *os_hdr; - int ret; - - memset ((void *)&images, 0, sizeof (images)); - images.verify = getenv_yesno ("verify"); lmb_init(&images.lmb); @@ -213,6 +201,20 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) arch_lmb_reserve(&images.lmb); board_lmb_reserve(&images.lmb); +#else +# define lmb_reserve(lmb, base, size) +#endif +} + +static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + void *os_hdr; + int ret; + + memset ((void *)&images, 0, sizeof (images)); + images.verify = getenv_yesno ("verify"); + + bootm_start_lmb(); /* get kernel image header, start address and length */ os_hdr = boot_get_kernel (cmdtp, flag, argc, argv, @@ -287,7 +289,9 @@ 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.type == IH_TYPE_MULTI)) && + (images.os.os == IH_OS_LINUX)) { /* find ramdisk */ ret = boot_get_ramdisk (argc, argv, &images, IH_INITRD_ARCH, &images.rd_start, &images.rd_end); @@ -338,15 +342,13 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) printf (" XIP %s ... ", type_name); } else { printf (" Loading %s ... ", type_name); - - if (load != image_start) { - memmove_wd ((void *)load, - (void *)image_start, image_len, CHUNKSZ); - } + memmove_wd ((void *)load, (void *)image_start, + image_len, CHUNKSZ); } *load_end = load + image_len; puts("OK\n"); break; +#ifdef CONFIG_GZIP case IH_COMP_GZIP: printf (" Uncompressing %s ... ", type_name); if (gunzip ((void *)load, unc_len, @@ -360,6 +362,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) *load_end = load + image_len; break; +#endif /* CONFIG_GZIP */ #ifdef CONFIG_BZIP2 case IH_COMP_BZIP2: printf (" Uncompressing %s ... ", type_name); @@ -398,6 +401,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; @@ -437,7 +458,7 @@ static int bootm_start_standalone(ulong iflag, int argc, char *argv[]) /* we overload the cmd field with our state machine info instead of a * function pointer */ -cmd_tbl_t cmd_bootm_sub[] = { +static cmd_tbl_t cmd_bootm_sub[] = { U_BOOT_CMD_MKENT(start, 0, 1, (void *)BOOTM_STATE_START, "", ""), U_BOOT_CMD_MKENT(loados, 0, 1, (void *)BOOTM_STATE_LOADOS, "", ""), #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SPARC) @@ -446,8 +467,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, "", ""), }; @@ -517,7 +538,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(); @@ -543,6 +564,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; } @@ -553,7 +575,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[]) { @@ -561,6 +582,8 @@ 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) { @@ -570,6 +593,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) boot_os[i] += gd->reloc_off; relocated = 1; } +#endif /* determine if we have a sub command */ if (argc > 1) { @@ -673,6 +697,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; } + arch_preboot_os(); + boot_fn(0, argc, argv, &images); show_boot_progress (-9); @@ -855,9 +881,6 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] 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; @@ -988,8 +1011,8 @@ 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" );