diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/spl/spl.c | 7 | ||||
-rw-r--r-- | common/spl/spl_mmc.c | 54 | ||||
-rw-r--r-- | common/spl/spl_nand.c | 33 | ||||
-rw-r--r-- | common/spl/spl_net.c | 15 | ||||
-rw-r--r-- | common/spl/spl_nor.c | 17 | ||||
-rw-r--r-- | common/spl/spl_onenand.c | 7 | ||||
-rw-r--r-- | common/spl/spl_sata.c | 3 | ||||
-rw-r--r-- | common/spl/spl_spi.c | 18 | ||||
-rw-r--r-- | common/spl/spl_ubi.c | 7 | ||||
-rw-r--r-- | common/spl/spl_usb.c | 3 | ||||
-rw-r--r-- | common/spl/spl_ymodem.c | 9 |
11 files changed, 98 insertions, 75 deletions
diff --git a/common/spl/spl.c b/common/spl/spl.c index 84c80345b69..fae3dbc7190 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -185,7 +185,8 @@ static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector, 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; @@ -215,7 +216,7 @@ static int spl_ram_load_image(struct spl_boot_device *bootdev) header = (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; @@ -381,7 +382,7 @@ static int spl_load_image(u32 boot_device) bootdev.boot_device = boot_device; bootdev.boot_device_name = NULL; 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) puts("SPL: Unsupported Boot Device!\n"); diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 5e8172e5bf9..6536e66ab0c 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -18,26 +18,26 @@ DECLARE_GLOBAL_DATA_PTR; -static int mmc_load_legacy(struct mmc *mmc, ulong sector, - struct image_header *header) +static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc, + ulong sector, struct image_header *header) { u32 image_size_sectors; unsigned long count; int ret; - ret = spl_parse_image_header(&spl_image, header); + ret = spl_parse_image_header(spl_image, header); if (ret) return ret; /* 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; /* Read the header too to avoid extra memcpy */ 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, - spl_image.load_addr); + spl_image->load_addr); if (count != image_size_sectors) 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); } -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; 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; ret = spl_load_simple_fit(&load, sector, header); } else { - ret = mmc_load_legacy(mmc, sector, header); + ret = mmc_load_legacy(spl_image, mmc, sector, header); } 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 -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; 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 - return mmc_load_image_raw_sector(mmc, info.start + - CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); + return mmc_load_image_raw_sector(spl_image, mmc, + info.start + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); #else - return mmc_load_image_raw_sector(mmc, info.start); + return mmc_load_image_raw_sector(spl_image, mmc, info.start); #endif } #else #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; } #endif #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; int ret; @@ -195,12 +199,12 @@ static int mmc_load_image_raw_os(struct mmc *mmc) 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); if (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"); return -ENOENT; } @@ -212,14 +216,15 @@ int spl_start_uboot(void) { 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; } #endif #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; @@ -261,13 +266,14 @@ int spl_mmc_do_fs_boot(struct mmc *mmc) return err; } #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; } #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; 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"); if (!spl_start_uboot()) { - err = mmc_load_image_raw_os(mmc); + err = mmc_load_image_raw_os(spl_image, mmc); if (!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); if (!err) return err; #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); if (!err) return err; @@ -331,7 +337,7 @@ static int spl_mmc_load_image(struct spl_boot_device *bootdev) case MMCSD_MODE_FS: 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) return err; diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c index ed758e518ca..5cf712e29af 100644 --- a/common/spl/spl_nand.c +++ b/common/spl/spl_nand.c @@ -13,14 +13,15 @@ #include <fdt.h> #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_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, CONFIG_SYS_NAND_U_BOOT_SIZE, (void *)CONFIG_SYS_NAND_U_BOOT_DST); - spl_set_header_raw_uboot(&spl_image); + spl_set_header_raw_uboot(spl_image); nand_deselect(); return 0; @@ -39,7 +40,8 @@ static ulong spl_nand_fit_read(struct spl_load_info *load, ulong offs, 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; @@ -59,15 +61,16 @@ static int spl_nand_load_element(int offset, struct image_header *header) load.read = spl_nand_fit_read; return spl_load_simple_fit(&load, offset, header); } else { - err = spl_parse_image_header(&spl_image, header); + err = spl_parse_image_header(spl_image, header); if (err) return err; - return nand_spl_load_image(offset, spl_image.size, - (void *)(ulong)spl_image.load_addr); + return nand_spl_load_image(offset, spl_image->size, + (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; struct image_header *header; @@ -107,15 +110,15 @@ static int spl_nand_load_image(struct spl_boot_device *bootdev) /* load linux */ nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS, sizeof(*header), (void *)header); - err = spl_parse_image_header(&spl_image, header); + err = spl_parse_image_header(spl_image, header); if (err) return err; if (header->ih_os == IH_OS_LINUX) { /* happy - was a linux */ err = nand_spl_load_image( CONFIG_SYS_NAND_SPL_KERNEL_OFFS, - spl_image.size, - (void *)spl_image.load_addr); + spl_image->size, + (void *)spl_image->load_addr); nand_deselect(); return err; } else { @@ -127,17 +130,19 @@ static int spl_nand_load_image(struct spl_boot_device *bootdev) } #endif #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 - spl_nand_load_element(CONFIG_ENV_OFFSET_REDUND, header); + spl_nand_load_element(spl_image, CONFIG_ENV_OFFSET_REDUND, header); #endif #endif /* 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 #if CONFIG_SYS_NAND_U_BOOT_OFFS != CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND 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); #endif #endif diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c index 0cbd995d112..f4b4bc48339 100644 --- a/common/spl/spl_net.c +++ b/common/spl/spl_net.c @@ -15,7 +15,8 @@ DECLARE_GLOBAL_DATA_PTR; #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; @@ -35,29 +36,31 @@ static int spl_net_load_image(struct spl_boot_device *bootdev) printf("Problem booting with BOOTP\n"); return rv; } - return spl_parse_image_header(&spl_image, + return spl_parse_image_header(spl_image, (struct image_header *)load_addr); } #endif #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 bootdev->boot_device_name = CONFIG_SPL_ETH_DEVICE; #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); #endif #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"; - 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); #endif diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c index b55fcc5cdb7..6bfa399bace 100644 --- a/common/spl/spl_nor.c +++ b/common/spl/spl_nor.c @@ -7,14 +7,15 @@ #include <common.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; /* * Loading of the payload to SDRAM is done with skipping of * 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 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) { /* happy - was a Linux */ - ret = spl_parse_image_header(&spl_image, header); + ret = spl_parse_image_header(spl_image, header); if (ret) return ret; - memcpy((void *)spl_image.load_addr, + memcpy((void *)spl_image->load_addr, (void *)(CONFIG_SYS_OS_BASE + sizeof(struct image_header)), - spl_image.size); + spl_image->size); /* * 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 * 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); if (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)), - spl_image.size); + spl_image->size); return 0; } diff --git a/common/spl/spl_onenand.c b/common/spl/spl_onenand.c index 361a1b34dbe..f076e2c7c88 100644 --- a/common/spl/spl_onenand.c +++ b/common/spl/spl_onenand.c @@ -14,7 +14,8 @@ #include <asm/io.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; int ret; @@ -26,11 +27,11 @@ static int spl_onenand_load_image(struct spl_boot_device *bootdev) /* Load u-boot */ onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS, 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) return ret; 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; } diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c index 1a21c051a10..19b5ba51998 100644 --- a/common/spl/spl_sata.c +++ b/common/spl/spl_sata.c @@ -20,7 +20,8 @@ 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; struct blk_desc *stor_dev; diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c index b9294f201ee..4bf3d659675 100644 --- a/common/spl/spl_spi.c +++ b/common/spl/spl_spi.c @@ -20,7 +20,8 @@ * Load the kernel, check for a valid header we can parse, and if found load * 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) { int err; @@ -32,12 +33,12 @@ static int spi_load_image_os(struct spi_flash *flash, if (image_get_magic(header) != IH_MAGIC) return -1; - err = spl_parse_image_header(&spl_image, header); + err = spl_parse_image_header(spl_image, header); if (err) return err; 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. */ 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 * 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; 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); #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 { /* 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, header); } else { - err = spl_parse_image_header(&spl_image, header); + err = spl_parse_image_header(spl_image, header); if (err) return err; err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, - spl_image.size, - (void *)spl_image.load_addr); + spl_image->size, + (void *)spl_image->load_addr); } } diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c index 3ef00aa0b08..c03910bb408 100644 --- a/common/spl/spl_ubi.c +++ b/common/spl/spl_ubi.c @@ -12,7 +12,8 @@ #include <ubispl.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 ubispl_info info; @@ -54,7 +55,7 @@ int spl_ubi_load_image(struct spl_boot_device *bootdev) ret = ubispl_load_volumes(&info, volumes, 2); if (!ret) { 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"); goto out; } @@ -68,7 +69,7 @@ int spl_ubi_load_image(struct spl_boot_device *bootdev) ret = ubispl_load_volumes(&info, volumes, 1); if (!ret) - spl_parse_image_header(&spl_image, header); + spl_parse_image_header(spl_image, header); out: #ifdef CONFIG_SPL_NAND_SUPPORT if (bootdev->boot_device == BOOT_DEVICE_NAND) diff --git a/common/spl/spl_usb.c b/common/spl/spl_usb.c index 2bc321ac5bd..aaa4f8103fa 100644 --- a/common/spl/spl_usb.c +++ b/common/spl/spl_usb.c @@ -22,7 +22,8 @@ DECLARE_GLOBAL_DATA_PTR; static int usb_stor_curr_dev = -1; /* current device */ #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; struct blk_desc *stor_dev; diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c index 168b9511d9e..8fbf8958a13 100644 --- a/common/spl/spl_ymodem.c +++ b/common/spl/spl_ymodem.c @@ -68,7 +68,8 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset, 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 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) size += res; } else { - spl_parse_image_header(&spl_image, (struct image_header *)buf); - ret = spl_parse_image_header(&spl_image, + spl_parse_image_header(spl_image, (struct image_header *)buf); + ret = spl_parse_image_header(spl_image, (struct image_header *)buf); if (ret) return ret; - addr = spl_image.load_addr; + addr = spl_image->load_addr; memcpy((void *)addr, buf, res); size += res; addr += res; |