static int spl_ram_load_image(struct spl_image_info *spl_image, struct spl_boot_device *bootdev) { struct image_header *header; header = (struct image_header *)CONFIG_SPL_LOAD_FIT_ADDRESS; #if CONFIG_IS_ENABLED(DFU_SUPPORT) if (bootdev->boot_device == BOOT_DEVICE_DFU) spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0"); #endif if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) && image_get_magic(header) == FDT_MAGIC) { struct spl_load_info load; debug("Found FIT\n"); load.bl_len = 1; load.read = spl_ram_load_read; spl_load_simple_fit(spl_image, &load, 0, header); } else { ulong u_boot_pos = binman_sym(ulong, u_boot_any, pos); debug("Legacy image\n"); /* * Get the header. It will point to an address defined by * handoff which will tell where the image located inside * the flash. */ debug("u_boot_pos = %lx\n", u_boot_pos); if (u_boot_pos == BINMAN_SYM_MISSING) { /* * No binman support or no information. For now, fix it * to the address pointed to by U-Boot. */ u_boot_pos = CONFIG_SYS_TEXT_BASE - sizeof(struct image_header); } header = (struct image_header *)map_sysmem(u_boot_pos, 0); spl_parse_image_header(spl_image, header); } return 0; }
static int spl_load_image(u32 boot_device) { switch (boot_device) { #ifdef CONFIG_SPL_RAM_DEVICE case BOOT_DEVICE_RAM: return spl_ram_load_image(); #endif #ifdef CONFIG_SPL_MMC_SUPPORT case BOOT_DEVICE_MMC1: case BOOT_DEVICE_MMC2: case BOOT_DEVICE_MMC2_2: return spl_mmc_load_image(boot_device); #endif #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND: return spl_nand_load_image(); #endif #ifdef CONFIG_SPL_ONENAND_SUPPORT case BOOT_DEVICE_ONENAND: return spl_onenand_load_image(); #endif #ifdef CONFIG_SPL_NOR_SUPPORT case BOOT_DEVICE_NOR: return spl_nor_load_image(); #endif #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART: return spl_ymodem_load_image(); #endif #ifdef CONFIG_SPL_SPI_SUPPORT case BOOT_DEVICE_SPI: return spl_spi_load_image(); #endif #ifdef CONFIG_SPL_ETH_SUPPORT case BOOT_DEVICE_CPGMAC: #ifdef CONFIG_SPL_ETH_DEVICE return spl_net_load_image(CONFIG_SPL_ETH_DEVICE); #else return spl_net_load_image(NULL); #endif #endif #ifdef CONFIG_SPL_USBETH_SUPPORT case BOOT_DEVICE_USBETH: return spl_net_load_image("usb_ether"); #endif #ifdef CONFIG_SPL_USB_SUPPORT case BOOT_DEVICE_USB: return spl_usb_load_image(); #endif #ifdef CONFIG_SPL_DFU_SUPPORT case BOOT_DEVICE_DFU: spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0"); return spl_ram_load_image(); #endif #ifdef CONFIG_SPL_SATA_SUPPORT case BOOT_DEVICE_SATA: return spl_sata_load_image(); #endif #ifdef CONFIG_SPL_BOARD_LOAD_IMAGE case BOOT_DEVICE_BOARD: return spl_board_load_image(); #endif default: #if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT) puts("SPL: Unsupported Boot Device!\n"); #endif return -ENODEV; } return -EINVAL; }