From a0a8029058e11b8eda1a3d61fdf497bc687b30f8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 24 Sep 2016 18:19:58 -0600 Subject: spl: Add a way to declare an SPL image loader Add a linker list macro which can be used to declare an SPL image loader. Update spl_load_image() to search available loaders for the correct one. Signed-off-by: Simon Glass Reviewed-by: Tom Rini --- common/spl/spl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'common') diff --git a/common/spl/spl.c b/common/spl/spl.c index 167bff07f9..eb3b808e46 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -347,12 +347,32 @@ static void announce_boot_device(u32 boot_device) static inline void announce_boot_device(u32 boot_device) { } #endif +static struct spl_image_loader *spl_ll_find_loader(uint boot_device) +{ + struct spl_image_loader *drv = + ll_entry_start(struct spl_image_loader, spl_image_loader); + const int n_ents = + ll_entry_count(struct spl_image_loader, spl_image_loader); + struct spl_image_loader *entry; + + for (entry = drv; entry != drv + n_ents; entry++) { + if (boot_device == entry->boot_device) + return entry; + } + + /* Not found */ + return NULL; +} + static int spl_load_image(u32 boot_device) { struct spl_boot_device bootdev; + struct spl_image_loader *loader = spl_ll_find_loader(boot_device); bootdev.boot_device = boot_device; bootdev.boot_device_name = NULL; + if (loader) + return loader->load_image(&bootdev); switch (boot_device) { #ifdef CONFIG_SPL_RAM_DEVICE -- cgit v1.2.3