summaryrefslogtreecommitdiff
path: root/common/spl
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-09-24 18:19:58 -0600
committerTom Rini <trini@konsulko.com>2016-10-06 14:53:36 -0400
commita0a8029058e11b8eda1a3d61fdf497bc687b30f8 (patch)
tree9b661c0f08cbaea1a70780a2290a09a7ed18037a /common/spl
parentecdfd69a4be55363589e8185ff151b02e6c36cfa (diff)
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 <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'common/spl')
-rw-r--r--common/spl/spl.c20
1 files changed, 20 insertions, 0 deletions
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