#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
image_header_t *hdr;
#endif
- block_dev_desc_t *dev_desc;
+ struct blk_desc *dev_desc;
-#if defined(CONFIG_FIT)
+#if CONFIG_IS_ENABLED(FIT)
const void *fit_hdr = NULL;
#endif
bootstage_mark(BOOTSTAGE_ID_IDE_BOOT_DEVICE);
- part = get_device_and_partition(intf, (argc == 3) ? argv[2] : NULL,
+ part = blk_get_device_part_str(intf, (argc == 3) ? argv[2] : NULL,
&dev_desc, &info, 1);
if (part < 0) {
bootstage_error(BOOTSTAGE_ID_IDE_TYPE);
return 1;
}
- dev = dev_desc->dev;
+ dev = dev_desc->devnum;
bootstage_mark(BOOTSTAGE_ID_IDE_TYPE);
printf("\nLoading from %s device %d, partition %d: "
", Block Size: %ld\n",
info.start, info.size, info.blksz);
- if (dev_desc->block_read(dev_desc, info.start, 1, (ulong *)addr) != 1) {
+ if (blk_dread(dev_desc, info.start, 1, (ulong *)addr) != 1) {
printf("** Read error on %d:%d\n", dev, part);
bootstage_error(BOOTSTAGE_ID_IDE_PART_READ);
return 1;
cnt = image_get_image_size(hdr);
break;
#endif
-#if defined(CONFIG_FIT)
+#if CONFIG_IS_ENABLED(FIT)
case IMAGE_FORMAT_FIT:
fit_hdr = (const void *) addr;
puts("Fit image detected...\n");
cnt /= info.blksz;
cnt -= 1;
- if (dev_desc->block_read(dev_desc, info.start + 1, cnt,
- (ulong *)(addr + info.blksz)) != cnt) {
+ if (blk_dread(dev_desc, info.start + 1, cnt,
+ (ulong *)(addr + info.blksz)) != cnt) {
printf("** Read error on %d:%d\n", dev, part);
bootstage_error(BOOTSTAGE_ID_IDE_READ);
return 1;
}
bootstage_mark(BOOTSTAGE_ID_IDE_READ);
-#if defined(CONFIG_FIT)
+#if CONFIG_IS_ENABLED(FIT)
/* This cannot be done earlier,
* we need complete FIT image in RAM first */
if (genimg_get_format((void *) addr) == IMAGE_FORMAT_FIT) {
DECLARE_GLOBAL_DATA_PTR;
+static int mmc_load_legacy(struct mmc *mmc, ulong sector,
+ struct image_header *header)
+{
+ u32 image_size_sectors;
+ unsigned long count;
+
+ spl_parse_image_header(header);
+ /* convert size to sectors - round up */
+ image_size_sectors = (spl_image.size + mmc->read_bl_len - 1) /
+ mmc->read_bl_len;
+
+ /* Read the header too to avoid extra memcpy */
+ count = mmc->block_dev.block_read(&mmc->block_dev, sector,
+ image_size_sectors,
+ (void *)(ulong)spl_image.load_addr);
+ debug("read %x sectors to %x\n", image_size_sectors,
+ spl_image.load_addr);
+ if (count != image_size_sectors)
+ return -EIO;
+
+ return 0;
+}
+
+#ifdef CONFIG_SPL_LOAD_FIT
+static ulong h_spl_load_read(struct spl_load_info *load, ulong sector,
+ ulong count, void *buf)
+{
+ struct mmc *mmc = load->dev;
+
+ return mmc->block_dev.block_read(&mmc->block_dev, sector, count, buf);
+}
+#endif
+
static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector)
{
unsigned long count;
- u32 image_size_sectors;
struct image_header *header;
+ int ret = 0;
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
sizeof(struct image_header));
/* read image header to find the image size & load address */
count = mmc->block_dev.block_read(&mmc->block_dev, sector, 1, header);
- debug("read sector %lx, count=%lu\n", sector, count);
- if (count == 0)
+ debug("hdr read sector %lx, count=%lu\n", sector, count);
+ if (count == 0) {
+ ret = -EIO;
goto end;
+ }
- if (image_get_magic(header) != IH_MAGIC) {
+ switch (image_get_magic(header)) {
+ case IH_MAGIC:
+ ret = mmc_load_legacy(mmc, sector, header);
+ break;
+#ifdef CONFIG_SPL_LOAD_FIT
+ case FDT_MAGIC: {
+ struct spl_load_info load;
+
+ debug("Found FIT\n");
+ load.dev = mmc;
+ load.priv = NULL;
+ load.bl_len = mmc->read_bl_len;
+ load.read = h_spl_load_read;
+ ret = spl_load_simple_fit(&load, sector, header);
+ break;
+ }
+#endif
+ default:
puts("bad magic\n");
return -1;
}
- spl_parse_image_header(header);
-
- /* convert size to sectors - round up */
- image_size_sectors = (spl_image.size + mmc->read_bl_len - 1) /
- mmc->read_bl_len;
-
- /* Read the header too to avoid extra memcpy */
- count = mmc->block_dev.block_read(&mmc->block_dev, sector,
- image_size_sectors,
- (void *)(ulong)spl_image.load_addr);
- debug("read %x sectors to %x\n", image_size_sectors,
- spl_image.load_addr);
-
end:
- if (count == 0) {
+ if (ret) {
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
puts("spl: mmc block read error\n");
#endif
disk_partition_t info;
int err;
- err = get_partition_info(&mmc->block_dev, partition, &info);
+ err = part_get_info(&mmc->block_dev, partition, &info);
if (err) {
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
puts("spl: partition error\n");
ulong get_tbclk (void);
void reset_misc (void);
void reset_cpu (ulong addr);
-#if defined (CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP)
void ft_cpu_setup(void *blob, bd_t *bd);
-#ifdef CONFIG_PCI
void ft_pci_setup(void *blob, bd_t *bd);
-#endif
-#endif
void smp_set_core_boot_addr(unsigned long addr, int corenr);
void smp_kick_all_cpus(void);
#if defined(CONFIG_MPC85xx)
typedef MPC85xx_SYS_INFO sys_info_t;
void get_sys_info ( sys_info_t * );
-# if defined(CONFIG_OF_LIBFDT)
- void ft_fixup_cpu(void *, u64);
- void ft_fixup_num_cores(void *);
-# endif
+void ft_fixup_cpu(void *, u64);
+void ft_fixup_num_cores(void *);
#endif
#if defined(CONFIG_MPC86xx)
typedef MPC86xx_SYS_INFO sys_info_t;
* for files under 4GiB
*/
int gzwrite(unsigned char *src, int len,
- struct block_dev_desc *dev,
+ struct blk_desc *dev,
unsigned long szwritebuf,
u64 startoffs,
u64 szexpected);
/* Use the HUSH parser */
#define CONFIG_SYS_HUSH_PARSER
-/*
- * Pass open firmware flat tree
- */
-#define CONFIG_OF_LIBFDT
-#define CONFIG_OF_BOARD_SETUP
-#define CONFIG_OF_STDOUT_VIA_ALIAS
-
-/* new uImage format support */
-#define CONFIG_FIT
-#define CONFIG_FIT_VERBOSE /* enable fit_format_{error,warning}() */
-
/* I2C */
#define CONFIG_SYS_I2C
#define CONFIG_SYS_I2C_FSL
#define CONFIG_CMD_REGINFO
#define CONFIG_CMD_ERRATA
#define CONFIG_CMD_CRAMFS
- #define CONFIG_CRAMFS_CMDLINE
/*
* USB
/* Number of bits in a C 'long' on this architecture */
#define CONFIG_SANDBOX_BITS_PER_LONG 64
-#define CONFIG_OF_LIBFDT
#define CONFIG_LMB
#define CONFIG_CMD_FDT
#define CONFIG_ANDROID_BOOT_IMAGE
#define CONFIG_CMD_FAT
#define CONFIG_CMD_EXT4
#define CONFIG_CMD_EXT4_WRITE
+ #define CONFIG_CMD_CBFS
+ #define CONFIG_CMD_CRAMFS
#define CONFIG_CMD_PART
#define CONFIG_DOS_PARTITION
#define CONFIG_HOST_MAX_DEVICES 4
#define CONFIG_CMD_GPT
#define CONFIG_PARTITION_UUIDS
- #define CONFIG_EFI_PARTITION
+ #define CONFIG_AMIGA_PARTITION
#define CONFIG_DOS_PARTITION
+ #define CONFIG_EFI_PARTITION
+ #define CONFIG_ISO_PARTITION
+ #define CONFIG_MAC_PARTITION
/*
* Size of malloc() pool, before and after relocation
u32 flags;
};
+/*
+ * Information required to load data from a device
+ *
+ * @dev: Pointer to the device, e.g. struct mmc *
+ * @priv: Private data for the device
+ * @bl_len: Block length for reading in bytes
+ * @read: Function to call to read from the device
+ */
+struct spl_load_info {
+ void *dev;
+ void *priv;
+ int bl_len;
+ ulong (*read)(struct spl_load_info *load, ulong sector, ulong count,
+ void *buf);
+};
+
+int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fdt);
+
#define SPL_COPY_PAYLOAD_ONLY 1
extern struct spl_image_info spl_image;
int spl_sata_load_image(void);
/* SPL FAT image functions */
- int spl_load_image_fat(block_dev_desc_t *block_dev, int partition, const char *filename);
- int spl_load_image_fat_os(block_dev_desc_t *block_dev, int partition);
+ int spl_load_image_fat(struct blk_desc *block_dev, int partition,
+ const char *filename);
+ int spl_load_image_fat_os(struct blk_desc *block_dev, int partition);
void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image);
/* SPL EXT image functions */
- int spl_load_image_ext(block_dev_desc_t *block_dev, int partition, const char *filename);
- int spl_load_image_ext_os(block_dev_desc_t *block_dev, int partition);
+ int spl_load_image_ext(struct blk_desc *block_dev, int partition,
+ const char *filename);
+ int spl_load_image_ext_os(struct blk_desc *block_dev, int partition);
/**
* spl_init() - Set up device tree and driver model in SPL if enabled