From: Simon Glass <sjg@chromium.org>
Date: Tue, 26 Sep 2023 14:14:55 +0000 (-0600)
Subject: spl: Add C-based runtime detection of SPL
X-Git-Tag: v2025.01-rc5-pxa1908~840^2~3
X-Git-Url: http://git.dujemihanovic.xyz/html/static/%7B%7B%20%28.OutputFormats.Get?a=commitdiff_plain;h=9031ba824209166444d5abea2064c23015883705;p=u-boot.git

spl: Add C-based runtime detection of SPL

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@chromium.org>
---

diff --git a/include/spl.h b/include/spl.h
index 59c508280b..a222db9c55 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
  *