spl: Pass spl_image as a parameter to load_image() methods
Rather than having a global variable, pass the spl_image as a parameter. This avoids BSS use, and makes it clearer what the function is actually doing. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
97d9df0a91
commit
2a2ee2ac35
|
@ -134,7 +134,8 @@ static int gpio_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SPL_BUILD
|
#ifdef CONFIG_SPL_BUILD
|
||||||
static int spl_board_load_image(struct spl_boot_device *bootdev)
|
static int spl_board_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
debug("Returning to FEL sp=%x, lr=%x\n", fel_stash.sp, fel_stash.lr);
|
debug("Returning to FEL sp=%x, lr=%x\n", fel_stash.sp, fel_stash.lr);
|
||||||
return_to_fel(fel_stash.sp, fel_stash.lr);
|
return_to_fel(fel_stash.sp, fel_stash.lr);
|
||||||
|
|
|
@ -65,7 +65,8 @@ int uniphier_rom_get_mmc_funcptr(int (**send_cmd)(u32, u32),
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spl_board_load_image(struct spl_boot_device *bootdev)
|
static int spl_board_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
int (*send_cmd)(u32 cmd, u32 arg);
|
int (*send_cmd)(u32 cmd, u32 arg);
|
||||||
int (*card_blockaddr)(u32 rca);
|
int (*card_blockaddr)(u32 rca);
|
||||||
|
@ -113,12 +114,12 @@ static int spl_board_load_image(struct spl_boot_device *bootdev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = spl_parse_image_header(&spl_image, (void *)CONFIG_SYS_TEXT_BASE);
|
ret = spl_parse_image_header(spl_image, (void *)CONFIG_SYS_TEXT_BASE);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = (*load_image)(dev_addr, spl_image.load_addr,
|
ret = (*load_image)(dev_addr, spl_image->load_addr,
|
||||||
spl_image.size / 512);
|
spl_image->size / 512);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("failed to load image\n");
|
printf("failed to load image\n");
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -38,7 +38,8 @@ void spl_board_announce_boot_device(void)
|
||||||
printf("%s\n", fname);
|
printf("%s\n", fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spl_board_load_image(struct spl_boot_device *bootdev)
|
static int spl_board_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
char fname[256];
|
char fname[256];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
|
@ -185,7 +185,8 @@ static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spl_ram_load_image(struct spl_boot_device *bootdev)
|
static int spl_ram_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
struct image_header *header;
|
struct image_header *header;
|
||||||
|
|
||||||
|
@ -215,7 +216,7 @@ static int spl_ram_load_image(struct spl_boot_device *bootdev)
|
||||||
header = (struct image_header *)
|
header = (struct image_header *)
|
||||||
(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));
|
(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));
|
||||||
|
|
||||||
spl_parse_image_header(&spl_image, header);
|
spl_parse_image_header(spl_image, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -381,7 +382,7 @@ static int spl_load_image(u32 boot_device)
|
||||||
bootdev.boot_device = boot_device;
|
bootdev.boot_device = boot_device;
|
||||||
bootdev.boot_device_name = NULL;
|
bootdev.boot_device_name = NULL;
|
||||||
if (loader)
|
if (loader)
|
||||||
return loader->load_image(&bootdev);
|
return loader->load_image(&spl_image, &bootdev);
|
||||||
|
|
||||||
#if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
|
#if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
|
||||||
puts("SPL: Unsupported Boot Device!\n");
|
puts("SPL: Unsupported Boot Device!\n");
|
||||||
|
|
|
@ -18,26 +18,26 @@
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
static int mmc_load_legacy(struct mmc *mmc, ulong sector,
|
static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc,
|
||||||
struct image_header *header)
|
ulong sector, struct image_header *header)
|
||||||
{
|
{
|
||||||
u32 image_size_sectors;
|
u32 image_size_sectors;
|
||||||
unsigned long count;
|
unsigned long count;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = spl_parse_image_header(&spl_image, header);
|
ret = spl_parse_image_header(spl_image, header);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* convert size to sectors - round up */
|
/* convert size to sectors - round up */
|
||||||
image_size_sectors = (spl_image.size + mmc->read_bl_len - 1) /
|
image_size_sectors = (spl_image->size + mmc->read_bl_len - 1) /
|
||||||
mmc->read_bl_len;
|
mmc->read_bl_len;
|
||||||
|
|
||||||
/* Read the header too to avoid extra memcpy */
|
/* Read the header too to avoid extra memcpy */
|
||||||
count = blk_dread(mmc_get_blk_desc(mmc), sector, image_size_sectors,
|
count = blk_dread(mmc_get_blk_desc(mmc), sector, image_size_sectors,
|
||||||
(void *)(ulong)spl_image.load_addr);
|
(void *)(ulong)spl_image->load_addr);
|
||||||
debug("read %x sectors to %x\n", image_size_sectors,
|
debug("read %x sectors to %x\n", image_size_sectors,
|
||||||
spl_image.load_addr);
|
spl_image->load_addr);
|
||||||
if (count != image_size_sectors)
|
if (count != image_size_sectors)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
|
@ -52,7 +52,8 @@ static ulong h_spl_load_read(struct spl_load_info *load, ulong sector,
|
||||||
return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf);
|
return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector)
|
static int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
|
||||||
|
struct mmc *mmc, unsigned long sector)
|
||||||
{
|
{
|
||||||
unsigned long count;
|
unsigned long count;
|
||||||
struct image_header *header;
|
struct image_header *header;
|
||||||
|
@ -81,7 +82,7 @@ static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector)
|
||||||
load.read = h_spl_load_read;
|
load.read = h_spl_load_read;
|
||||||
ret = spl_load_simple_fit(&load, sector, header);
|
ret = spl_load_simple_fit(&load, sector, header);
|
||||||
} else {
|
} else {
|
||||||
ret = mmc_load_legacy(mmc, sector, header);
|
ret = mmc_load_legacy(spl_image, mmc, sector, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
@ -150,7 +151,8 @@ static int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
|
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
|
||||||
static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
|
static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
|
||||||
|
struct mmc *mmc, int partition)
|
||||||
{
|
{
|
||||||
disk_partition_t info;
|
disk_partition_t info;
|
||||||
int err;
|
int err;
|
||||||
|
@ -164,22 +166,24 @@ static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
|
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
|
||||||
return mmc_load_image_raw_sector(mmc, info.start +
|
return mmc_load_image_raw_sector(spl_image, mmc,
|
||||||
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
|
info.start + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
|
||||||
#else
|
#else
|
||||||
return mmc_load_image_raw_sector(mmc, info.start);
|
return mmc_load_image_raw_sector(spl_image, mmc, info.start);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION -1
|
#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION -1
|
||||||
static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
|
static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
|
||||||
|
struct mmc *mmc, int partition)
|
||||||
{
|
{
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SPL_OS_BOOT
|
#ifdef CONFIG_SPL_OS_BOOT
|
||||||
static int mmc_load_image_raw_os(struct mmc *mmc)
|
static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
|
||||||
|
struct mmc *mmc)
|
||||||
{
|
{
|
||||||
unsigned long count;
|
unsigned long count;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -195,12 +199,12 @@ static int mmc_load_image_raw_os(struct mmc *mmc)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mmc_load_image_raw_sector(mmc,
|
ret = mmc_load_image_raw_sector(spl_image, mmc,
|
||||||
CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
|
CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (spl_image.os != IH_OS_LINUX) {
|
if (spl_image->os != IH_OS_LINUX) {
|
||||||
puts("Expected Linux image is not found. Trying to start U-boot\n");
|
puts("Expected Linux image is not found. Trying to start U-boot\n");
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
@ -212,14 +216,15 @@ int spl_start_uboot(void)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
static int mmc_load_image_raw_os(struct mmc *mmc)
|
static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
|
||||||
|
struct mmc *mmc)
|
||||||
{
|
{
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
|
#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
|
||||||
int spl_mmc_do_fs_boot(struct mmc *mmc)
|
static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc)
|
||||||
{
|
{
|
||||||
int err = -ENOSYS;
|
int err = -ENOSYS;
|
||||||
|
|
||||||
|
@ -261,13 +266,14 @@ int spl_mmc_do_fs_boot(struct mmc *mmc)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int spl_mmc_do_fs_boot(struct mmc *mmc)
|
static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc)
|
||||||
{
|
{
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int spl_mmc_load_image(struct spl_boot_device *bootdev)
|
static int spl_mmc_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
struct mmc *mmc = NULL;
|
struct mmc *mmc = NULL;
|
||||||
u32 boot_mode;
|
u32 boot_mode;
|
||||||
|
@ -312,17 +318,17 @@ static int spl_mmc_load_image(struct spl_boot_device *bootdev)
|
||||||
debug("spl: mmc boot mode: raw\n");
|
debug("spl: mmc boot mode: raw\n");
|
||||||
|
|
||||||
if (!spl_start_uboot()) {
|
if (!spl_start_uboot()) {
|
||||||
err = mmc_load_image_raw_os(mmc);
|
err = mmc_load_image_raw_os(spl_image, mmc);
|
||||||
if (!err)
|
if (!err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = mmc_load_image_raw_partition(mmc,
|
err = mmc_load_image_raw_partition(spl_image, mmc,
|
||||||
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
|
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
|
||||||
if (!err)
|
if (!err)
|
||||||
return err;
|
return err;
|
||||||
#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
|
#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
|
||||||
err = mmc_load_image_raw_sector(mmc,
|
err = mmc_load_image_raw_sector(spl_image, mmc,
|
||||||
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
|
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
|
||||||
if (!err)
|
if (!err)
|
||||||
return err;
|
return err;
|
||||||
|
@ -331,7 +337,7 @@ static int spl_mmc_load_image(struct spl_boot_device *bootdev)
|
||||||
case MMCSD_MODE_FS:
|
case MMCSD_MODE_FS:
|
||||||
debug("spl: mmc boot mode: fs\n");
|
debug("spl: mmc boot mode: fs\n");
|
||||||
|
|
||||||
err = spl_mmc_do_fs_boot(mmc);
|
err = spl_mmc_do_fs_boot(spl_image, mmc);
|
||||||
if (!err)
|
if (!err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,15 @@
|
||||||
#include <fdt.h>
|
#include <fdt.h>
|
||||||
|
|
||||||
#if defined(CONFIG_SPL_NAND_RAW_ONLY)
|
#if defined(CONFIG_SPL_NAND_RAW_ONLY)
|
||||||
int spl_nand_load_image(struct spl_boot_device *bootdev)
|
int spl_nand_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
nand_init();
|
nand_init();
|
||||||
|
|
||||||
nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
|
nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
|
||||||
CONFIG_SYS_NAND_U_BOOT_SIZE,
|
CONFIG_SYS_NAND_U_BOOT_SIZE,
|
||||||
(void *)CONFIG_SYS_NAND_U_BOOT_DST);
|
(void *)CONFIG_SYS_NAND_U_BOOT_DST);
|
||||||
spl_set_header_raw_uboot(&spl_image);
|
spl_set_header_raw_uboot(spl_image);
|
||||||
nand_deselect();
|
nand_deselect();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -39,7 +40,8 @@ static ulong spl_nand_fit_read(struct spl_load_info *load, ulong offs,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spl_nand_load_element(int offset, struct image_header *header)
|
static int spl_nand_load_element(struct spl_image_info *spl_image,
|
||||||
|
int offset, struct image_header *header)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -59,15 +61,16 @@ static int spl_nand_load_element(int offset, struct image_header *header)
|
||||||
load.read = spl_nand_fit_read;
|
load.read = spl_nand_fit_read;
|
||||||
return spl_load_simple_fit(&load, offset, header);
|
return spl_load_simple_fit(&load, offset, header);
|
||||||
} else {
|
} else {
|
||||||
err = spl_parse_image_header(&spl_image, header);
|
err = spl_parse_image_header(spl_image, header);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
return nand_spl_load_image(offset, spl_image.size,
|
return nand_spl_load_image(offset, spl_image->size,
|
||||||
(void *)(ulong)spl_image.load_addr);
|
(void *)(ulong)spl_image->load_addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spl_nand_load_image(struct spl_boot_device *bootdev)
|
static int spl_nand_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
struct image_header *header;
|
struct image_header *header;
|
||||||
|
@ -107,15 +110,15 @@ static int spl_nand_load_image(struct spl_boot_device *bootdev)
|
||||||
/* load linux */
|
/* load linux */
|
||||||
nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
|
nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
|
||||||
sizeof(*header), (void *)header);
|
sizeof(*header), (void *)header);
|
||||||
err = spl_parse_image_header(&spl_image, header);
|
err = spl_parse_image_header(spl_image, header);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
if (header->ih_os == IH_OS_LINUX) {
|
if (header->ih_os == IH_OS_LINUX) {
|
||||||
/* happy - was a linux */
|
/* happy - was a linux */
|
||||||
err = nand_spl_load_image(
|
err = nand_spl_load_image(
|
||||||
CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
|
CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
|
||||||
spl_image.size,
|
spl_image->size,
|
||||||
(void *)spl_image.load_addr);
|
(void *)spl_image->load_addr);
|
||||||
nand_deselect();
|
nand_deselect();
|
||||||
return err;
|
return err;
|
||||||
} else {
|
} else {
|
||||||
|
@ -127,17 +130,19 @@ static int spl_nand_load_image(struct spl_boot_device *bootdev)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_NAND_ENV_DST
|
#ifdef CONFIG_NAND_ENV_DST
|
||||||
spl_nand_load_element(CONFIG_ENV_OFFSET, header);
|
spl_nand_load_element(spl_image, CONFIG_ENV_OFFSET, header);
|
||||||
#ifdef CONFIG_ENV_OFFSET_REDUND
|
#ifdef CONFIG_ENV_OFFSET_REDUND
|
||||||
spl_nand_load_element(CONFIG_ENV_OFFSET_REDUND, header);
|
spl_nand_load_element(spl_image, CONFIG_ENV_OFFSET_REDUND, header);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/* Load u-boot */
|
/* Load u-boot */
|
||||||
err = spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header);
|
err = spl_nand_load_element(spl_image, CONFIG_SYS_NAND_U_BOOT_OFFS,
|
||||||
|
header);
|
||||||
#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
|
#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
|
||||||
#if CONFIG_SYS_NAND_U_BOOT_OFFS != CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
|
#if CONFIG_SYS_NAND_U_BOOT_OFFS != CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
|
||||||
if (err)
|
if (err)
|
||||||
err = spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND,
|
err = spl_nand_load_element(spl_image,
|
||||||
|
CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND,
|
||||||
header);
|
header);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
#if defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USBETH_SUPPORT)
|
#if defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USBETH_SUPPORT)
|
||||||
static int spl_net_load_image(struct spl_boot_device *bootdev)
|
static int spl_net_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
|
@ -35,29 +36,31 @@ static int spl_net_load_image(struct spl_boot_device *bootdev)
|
||||||
printf("Problem booting with BOOTP\n");
|
printf("Problem booting with BOOTP\n");
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
return spl_parse_image_header(&spl_image,
|
return spl_parse_image_header(spl_image,
|
||||||
(struct image_header *)load_addr);
|
(struct image_header *)load_addr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SPL_ETH_SUPPORT
|
#ifdef CONFIG_SPL_ETH_SUPPORT
|
||||||
int spl_net_load_image_cpgmac(struct spl_boot_device *bootdev)
|
int spl_net_load_image_cpgmac(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_SPL_ETH_DEVICE
|
#ifdef CONFIG_SPL_ETH_DEVICE
|
||||||
bootdev->boot_device_name = CONFIG_SPL_ETH_DEVICE;
|
bootdev->boot_device_name = CONFIG_SPL_ETH_DEVICE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return spl_net_load_image(bootdev);
|
return spl_net_load_image(spl_image, bootdev);
|
||||||
}
|
}
|
||||||
SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_CPGMAC, spl_net_load_image_cpgmac);
|
SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_CPGMAC, spl_net_load_image_cpgmac);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SPL_USBETH_SUPPORT
|
#ifdef CONFIG_SPL_USBETH_SUPPORT
|
||||||
int spl_net_load_image_usb(struct spl_boot_device *bootdev)
|
int spl_net_load_image_usb(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
bootdev->boot_device_name = "usb_ether";
|
bootdev->boot_device_name = "usb_ether";
|
||||||
|
|
||||||
return spl_net_load_image(bootdev);
|
return spl_net_load_image(spl_image, bootdev);
|
||||||
}
|
}
|
||||||
SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_USBETH, spl_net_load_image_usb);
|
SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_USBETH, spl_net_load_image_usb);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,14 +7,15 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <spl.h>
|
#include <spl.h>
|
||||||
|
|
||||||
static int spl_nor_load_image(struct spl_boot_device *bootdev)
|
static int spl_nor_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
/*
|
/*
|
||||||
* Loading of the payload to SDRAM is done with skipping of
|
* Loading of the payload to SDRAM is done with skipping of
|
||||||
* the mkimage header in this SPL NOR driver
|
* the mkimage header in this SPL NOR driver
|
||||||
*/
|
*/
|
||||||
spl_image.flags |= SPL_COPY_PAYLOAD_ONLY;
|
spl_image->flags |= SPL_COPY_PAYLOAD_ONLY;
|
||||||
|
|
||||||
#ifdef CONFIG_SPL_OS_BOOT
|
#ifdef CONFIG_SPL_OS_BOOT
|
||||||
if (!spl_start_uboot()) {
|
if (!spl_start_uboot()) {
|
||||||
|
@ -29,14 +30,14 @@ static int spl_nor_load_image(struct spl_boot_device *bootdev)
|
||||||
if (image_get_os(header) == IH_OS_LINUX) {
|
if (image_get_os(header) == IH_OS_LINUX) {
|
||||||
/* happy - was a Linux */
|
/* happy - was a Linux */
|
||||||
|
|
||||||
ret = spl_parse_image_header(&spl_image, header);
|
ret = spl_parse_image_header(spl_image, header);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
memcpy((void *)spl_image.load_addr,
|
memcpy((void *)spl_image->load_addr,
|
||||||
(void *)(CONFIG_SYS_OS_BASE +
|
(void *)(CONFIG_SYS_OS_BASE +
|
||||||
sizeof(struct image_header)),
|
sizeof(struct image_header)),
|
||||||
spl_image.size);
|
spl_image->size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy DT blob (fdt) to SDRAM. Passing pointer to
|
* Copy DT blob (fdt) to SDRAM. Passing pointer to
|
||||||
|
@ -59,14 +60,14 @@ static int spl_nor_load_image(struct spl_boot_device *bootdev)
|
||||||
* Load real U-Boot from its location in NOR flash to its
|
* Load real U-Boot from its location in NOR flash to its
|
||||||
* defined location in SDRAM
|
* defined location in SDRAM
|
||||||
*/
|
*/
|
||||||
ret = spl_parse_image_header(&spl_image,
|
ret = spl_parse_image_header(spl_image,
|
||||||
(const struct image_header *)CONFIG_SYS_UBOOT_BASE);
|
(const struct image_header *)CONFIG_SYS_UBOOT_BASE);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
memcpy((void *)(unsigned long)spl_image.load_addr,
|
memcpy((void *)(unsigned long)spl_image->load_addr,
|
||||||
(void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)),
|
(void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)),
|
||||||
spl_image.size);
|
spl_image->size);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include <onenand_uboot.h>
|
#include <onenand_uboot.h>
|
||||||
|
|
||||||
static int spl_onenand_load_image(struct spl_boot_device *bootdev)
|
static int spl_onenand_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
struct image_header *header;
|
struct image_header *header;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -26,11 +27,11 @@ static int spl_onenand_load_image(struct spl_boot_device *bootdev)
|
||||||
/* Load u-boot */
|
/* Load u-boot */
|
||||||
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
|
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
|
||||||
CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header);
|
CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header);
|
||||||
ret = spl_parse_image_header(&spl_image, header);
|
ret = spl_parse_image_header(spl_image, header);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
|
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
|
||||||
spl_image.size, (void *)spl_image.load_addr);
|
spl_image->size, (void *)spl_image->load_addr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
static int spl_sata_load_image(struct spl_boot_device *bootdev)
|
static int spl_sata_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
struct blk_desc *stor_dev;
|
struct blk_desc *stor_dev;
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
* Load the kernel, check for a valid header we can parse, and if found load
|
* Load the kernel, check for a valid header we can parse, and if found load
|
||||||
* the kernel and then device tree.
|
* the kernel and then device tree.
|
||||||
*/
|
*/
|
||||||
static int spi_load_image_os(struct spi_flash *flash,
|
static int spi_load_image_os(struct spl_image_info *spl_image,
|
||||||
|
struct spi_flash *flash,
|
||||||
struct image_header *header)
|
struct image_header *header)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
@ -32,12 +33,12 @@ static int spi_load_image_os(struct spi_flash *flash,
|
||||||
if (image_get_magic(header) != IH_MAGIC)
|
if (image_get_magic(header) != IH_MAGIC)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
err = spl_parse_image_header(&spl_image, header);
|
err = spl_parse_image_header(spl_image, header);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS,
|
spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS,
|
||||||
spl_image.size, (void *)spl_image.load_addr);
|
spl_image->size, (void *)spl_image->load_addr);
|
||||||
|
|
||||||
/* Read device tree. */
|
/* Read device tree. */
|
||||||
spi_flash_read(flash, CONFIG_SYS_SPI_ARGS_OFFS,
|
spi_flash_read(flash, CONFIG_SYS_SPI_ARGS_OFFS,
|
||||||
|
@ -65,7 +66,8 @@ static ulong spl_spi_fit_read(struct spl_load_info *load, ulong sector,
|
||||||
* configured and available since this code loads the main U-Boot image
|
* configured and available since this code loads the main U-Boot image
|
||||||
* from SPI into SDRAM and starts it from there.
|
* from SPI into SDRAM and starts it from there.
|
||||||
*/
|
*/
|
||||||
static int spl_spi_load_image(struct spl_boot_device *bootdev)
|
static int spl_spi_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
struct spi_flash *flash;
|
struct spi_flash *flash;
|
||||||
|
@ -88,7 +90,7 @@ static int spl_spi_load_image(struct spl_boot_device *bootdev)
|
||||||
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
|
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
|
||||||
|
|
||||||
#ifdef CONFIG_SPL_OS_BOOT
|
#ifdef CONFIG_SPL_OS_BOOT
|
||||||
if (spl_start_uboot() || spi_load_image_os(flash, header))
|
if (spl_start_uboot() || spi_load_image_os(spl_image, flash, header))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Load u-boot, mkimage header is 64 bytes. */
|
/* Load u-boot, mkimage header is 64 bytes. */
|
||||||
|
@ -110,12 +112,12 @@ static int spl_spi_load_image(struct spl_boot_device *bootdev)
|
||||||
CONFIG_SYS_SPI_U_BOOT_OFFS,
|
CONFIG_SYS_SPI_U_BOOT_OFFS,
|
||||||
header);
|
header);
|
||||||
} else {
|
} else {
|
||||||
err = spl_parse_image_header(&spl_image, header);
|
err = spl_parse_image_header(spl_image, header);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,
|
err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,
|
||||||
spl_image.size,
|
spl_image->size,
|
||||||
(void *)spl_image.load_addr);
|
(void *)spl_image->load_addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
#include <ubispl.h>
|
#include <ubispl.h>
|
||||||
#include <spl.h>
|
#include <spl.h>
|
||||||
|
|
||||||
int spl_ubi_load_image(struct spl_boot_device *bootdev)
|
int spl_ubi_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
struct image_header *header;
|
struct image_header *header;
|
||||||
struct ubispl_info info;
|
struct ubispl_info info;
|
||||||
|
@ -54,7 +55,7 @@ int spl_ubi_load_image(struct spl_boot_device *bootdev)
|
||||||
ret = ubispl_load_volumes(&info, volumes, 2);
|
ret = ubispl_load_volumes(&info, volumes, 2);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
header = (struct image_header *)volumes[0].load_addr;
|
header = (struct image_header *)volumes[0].load_addr;
|
||||||
spl_parse_image_header(&spl_image, header);
|
spl_parse_image_header(spl_image, header);
|
||||||
puts("Linux loaded.\n");
|
puts("Linux loaded.\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +69,7 @@ int spl_ubi_load_image(struct spl_boot_device *bootdev)
|
||||||
|
|
||||||
ret = ubispl_load_volumes(&info, volumes, 1);
|
ret = ubispl_load_volumes(&info, volumes, 1);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
spl_parse_image_header(&spl_image, header);
|
spl_parse_image_header(spl_image, header);
|
||||||
out:
|
out:
|
||||||
#ifdef CONFIG_SPL_NAND_SUPPORT
|
#ifdef CONFIG_SPL_NAND_SUPPORT
|
||||||
if (bootdev->boot_device == BOOT_DEVICE_NAND)
|
if (bootdev->boot_device == BOOT_DEVICE_NAND)
|
||||||
|
|
|
@ -22,7 +22,8 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||||
static int usb_stor_curr_dev = -1; /* current device */
|
static int usb_stor_curr_dev = -1; /* current device */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int spl_usb_load_image(struct spl_boot_device *bootdev)
|
static int spl_usb_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
struct blk_desc *stor_dev;
|
struct blk_desc *stor_dev;
|
||||||
|
|
|
@ -68,7 +68,8 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset,
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spl_ymodem_load_image(struct spl_boot_device *bootdev)
|
static int spl_ymodem_load_image(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev)
|
||||||
{
|
{
|
||||||
int size = 0;
|
int size = 0;
|
||||||
int err;
|
int err;
|
||||||
|
@ -108,12 +109,12 @@ static int spl_ymodem_load_image(struct spl_boot_device *bootdev)
|
||||||
while ((res = xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0)
|
while ((res = xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0)
|
||||||
size += res;
|
size += res;
|
||||||
} else {
|
} else {
|
||||||
spl_parse_image_header(&spl_image, (struct image_header *)buf);
|
spl_parse_image_header(spl_image, (struct image_header *)buf);
|
||||||
ret = spl_parse_image_header(&spl_image,
|
ret = spl_parse_image_header(spl_image,
|
||||||
(struct image_header *)buf);
|
(struct image_header *)buf);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
addr = spl_image.load_addr;
|
addr = spl_image->load_addr;
|
||||||
memcpy((void *)addr, buf, res);
|
memcpy((void *)addr, buf, res);
|
||||||
size += res;
|
size += res;
|
||||||
addr += res;
|
addr += res;
|
||||||
|
|
|
@ -160,9 +160,11 @@ struct spl_image_loader {
|
||||||
/**
|
/**
|
||||||
* load_image() - Load an SPL image
|
* load_image() - Load an SPL image
|
||||||
*
|
*
|
||||||
|
* @spl_image: place to put image information
|
||||||
* @bootdev: describes the boot device to load from
|
* @bootdev: describes the boot device to load from
|
||||||
*/
|
*/
|
||||||
int (*load_image)(struct spl_boot_device *bootdev);
|
int (*load_image)(struct spl_image_info *spl_image,
|
||||||
|
struct spl_boot_device *bootdev);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Declare an SPL image loader */
|
/* Declare an SPL image loader */
|
||||||
|
|
Loading…
Reference in New Issue