[PATCH v4 41/44] spl: Add C-based runtime detection of SPL

Simon Glass sjg at chromium.org
Tue Sep 26 16:14:55 CEST 2023


The spl_phase() function indicates whether U-Boot is in SPL and before
or after relocation. But sometimes it is useful to check for SPL with
zero code-size impact. Since spl_phase() checks the global_data flags,
it does add a few bytes.

Add a new spl_in_proper() function to check if U-Boot proper is
running, regardless of the relocation status.

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

Changes in v4:
- Add new patch with C-based runtime detection of SPL

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

diff --git a/include/spl.h b/include/spl.h
index e958ace2cc62..a3510edecf24 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -132,6 +132,16 @@ static inline enum u_boot_phase spl_phase(void)
 #endif
 }
 
+/* returns true if in U-Boot proper, false if in SPL */
+static inline bool spl_in_proper(void)
+{
+#ifdef CONFIG_SPL_BUILD
+	return false;
+#endif
+
+	return true;
+}
+
 /**
  * spl_prev_phase() - Figure out the previous U-Boot phase
  *
-- 
2.42.0.515.g380fc7ccd1-goog



More information about the U-Boot mailing list