[PATCH 02/19] spl: Provide a way of indicating the phase to load

Simon Glass
2024-09-25T12:58:15Z

Provide a field in struct spl_load_info to indicate the phase of the
image which should be loaded. This is needed by VBE, which can load
images in various phases.

Set the phase to none by default.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

include/spl.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/include/spl.h b/include/spl.h
index 1cfaa08ed6a..113d50152a1 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -14,6 +14,7 @@
#include <asm/global_data.h>
#include <asm/spl.h>
#include <handoff.h>
+#include <image.h>
#include <mmc.h>

struct blk_desc;
@@ -304,6 +305,7 @@ typedef ulong (*spl_load_reader)(struct spl_load_info *load, ulong sector,
* @read: Function to call to read from the device
* @priv: Private data for the device
* @bl_len: Block length for reading in bytes
+ * @phase: Image phase to load
*/
struct spl_load_info {
spl_load_reader read;
@@ -311,6 +313,9 @@ struct spl_load_info {
#if IS_ENABLED(CONFIG_SPL_LOAD_BLOCK)
u16 bl_len;
#endif
+#if CONFIG_IS_ENABLED(BOOTMETH_VBE)
+ u8 phase;
+#endif
};

static inline int spl_get_bl_len(struct spl_load_info *info)
@@ -332,6 +337,23 @@ static inline void spl_set_bl_len(struct spl_load_info *info, int bl_len)
#endif
}

+static inline void spl_set_phase(struct spl_load_info *info,
+ enum image_phase_t phase)
+{
+#if CONFIG_IS_ENABLED(BOOTMETH_VBE)
+ info->phase = phase;
+#endif
+}
+
+static inline enum image_phase_t spl_get_phase(struct spl_load_info *info)
+{
+#if CONFIG_IS_ENABLED(BOOTMETH_VBE)
+ return info->phase;
+#else
+ return IH_PHASE_NONE;
+#endif
+}
+
/**
* spl_load_init() - Set up a new spl_load_info structure
*/
@@ -342,6 +364,7 @@ static inline void spl_load_init(struct spl_load_info *load,
load->read = h_read;
load->priv = priv;
spl_set_bl_len(load, bl_len);
+ spl_set_phase(load, IH_PHASE_NONE);
}

/*
--
2.43.0