X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fspl%2Fspl.c;h=163e960a1e865041cbef21b66755ef37321eb42d;hb=b67eefdb6ec9467c41b1c0081f0823bbfff36b00;hp=932e6ab98ac4cd5d4c0fd5263bcc9c54183f1ff6;hpb=ad647690b1346f57847d4c9251293293af8928a8;p=oweals%2Fu-boot.git diff --git a/common/spl/spl.c b/common/spl/spl.c index 932e6ab98a..163e960a1e 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -254,6 +254,14 @@ static int spl_load_fit_image(struct spl_image_info *spl_image, } #endif +__weak int spl_parse_legacy_header(struct spl_image_info *spl_image, + const struct image_header *header) +{ + /* LEGACY image not supported */ + debug("Legacy boot image support not enabled, proceeding to other boot methods\n"); + return -EINVAL; +} + int spl_parse_image_header(struct spl_image_info *spl_image, const struct image_header *header) { @@ -264,51 +272,11 @@ int spl_parse_image_header(struct spl_image_info *spl_image, return ret; #endif if (image_get_magic(header) == IH_MAGIC) { -#ifdef CONFIG_SPL_LEGACY_IMAGE_SUPPORT - u32 header_size = sizeof(struct image_header); - -#ifdef CONFIG_SPL_LEGACY_IMAGE_CRC_CHECK - /* check uImage header CRC */ - if (!image_check_hcrc(header)) { - puts("SPL: Image header CRC check failed!\n"); - return -EINVAL; - } -#endif - - if (spl_image->flags & SPL_COPY_PAYLOAD_ONLY) { - /* - * On some system (e.g. powerpc), the load-address and - * entry-point is located at address 0. We can't load - * to 0-0x40. So skip header in this case. - */ - spl_image->load_addr = image_get_load(header); - spl_image->entry_point = image_get_ep(header); - spl_image->size = image_get_data_size(header); - } else { - spl_image->entry_point = image_get_ep(header); - /* Load including the header */ - spl_image->load_addr = image_get_load(header) - - header_size; - spl_image->size = image_get_data_size(header) + - header_size; - } -#ifdef CONFIG_SPL_LEGACY_IMAGE_CRC_CHECK - /* store uImage data length and CRC to check later */ - spl_image->dcrc_data = image_get_load(header); - spl_image->dcrc_length = image_get_data_size(header); - spl_image->dcrc = image_get_dcrc(header); -#endif + int ret; - spl_image->os = image_get_os(header); - spl_image->name = image_get_name(header); - debug(SPL_TPL_PROMPT - "payload image: %32s load addr: 0x%lx size: %d\n", - spl_image->name, spl_image->load_addr, spl_image->size); -#else - /* LEGACY image not supported */ - debug("Legacy boot image support not enabled, proceeding to other boot methods\n"); - return -EINVAL; -#endif + ret = spl_parse_legacy_header(spl_image, header); + if (ret) + return ret; } else { #ifdef CONFIG_SPL_PANIC_ON_RAW_IMAGE /* @@ -455,11 +423,11 @@ static int spl_common_init(bool setup_malloc) } } if (CONFIG_IS_ENABLED(DM)) { - bootstage_start(BOOTSTATE_ID_ACCUM_DM_SPL, + bootstage_start(BOOTSTAGE_ID_ACCUM_DM_SPL, spl_phase() == PHASE_TPL ? "dm tpl" : "dm_spl"); /* With CONFIG_SPL_OF_PLATDATA, bring in all devices */ ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA)); - bootstage_accum(BOOTSTATE_ID_ACCUM_DM_SPL); + bootstage_accum(BOOTSTAGE_ID_ACCUM_DM_SPL); if (ret) { debug("dm_init_and_scan() returned error %d\n", ret); return ret; @@ -606,8 +574,7 @@ void board_init_f(ulong dummy) } } - if (CONFIG_IS_ENABLED(SERIAL_SUPPORT)) - preloader_console_init(); + preloader_console_init(); } #endif @@ -756,13 +723,13 @@ void board_init_r(gd_t *dummy1, ulong dummy2) jump_to_image_no_args(&spl_image); } -#ifdef CONFIG_SPL_SERIAL_SUPPORT /* * This requires UART clocks to be enabled. In order for this to work the * caller must ensure that the gd pointer is valid. */ void preloader_console_init(void) { +#ifdef CONFIG_SPL_SERIAL_SUPPORT gd->baudrate = CONFIG_BAUDRATE; serial_init(); /* serial communications setup */ @@ -776,8 +743,8 @@ void preloader_console_init(void) #ifdef CONFIG_SPL_DISPLAY_PRINT spl_display_print(); #endif -} #endif +} /** * This function is called before the stack is changed from initial stack to