diff mbox series

[02/12] x86: spl: Add a function to find the text base

Message ID 20210116145343.2.Ida9f8cf3e7473c0f9493dd616e7481a022f3a85a@changeid
State Superseded
Delegated to: Bin Meng
Headers show
Series x86: Minor improvements mostly for image loading | expand

Commit Message

Simon Glass Jan. 16, 2021, 9:53 p.m. UTC
It is useful to know the TEXT_BASE value for the image being loaded in
TPL/SPL. Add a new spl_get_image_text_base() function to handle this.

Make use of this in the x86 SPL handler, instead of having the logic
there.

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

 common/spl/spl.c |  6 ++++++
 include/spl.h    | 10 ++++++++++
 2 files changed, 16 insertions(+)

Comments

Bin Meng Jan. 21, 2021, 3:21 a.m. UTC | #1
On Sun, Jan 17, 2021 at 5:54 AM Simon Glass <sjg@chromium.org> wrote:
>
> It is useful to know the TEXT_BASE value for the image being loaded in
> TPL/SPL. Add a new spl_get_image_text_base() function to handle this.
>
> Make use of this in the x86 SPL handler, instead of having the logic
> there.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  common/spl/spl.c |  6 ++++++
>  include/spl.h    | 10 ++++++++++
>  2 files changed, 16 insertions(+)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
diff mbox series

Patch

diff --git a/common/spl/spl.c b/common/spl/spl.c
index d375dcbb2ed..12b00e2a407 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -144,6 +144,12 @@  ulong spl_get_image_size(void)
 		binman_sym(ulong, u_boot_any, size);
 }
 
+ulong spl_get_image_text_base(void)
+{
+	return spl_phase() == PHASE_TPL ? CONFIG_SPL_TEXT_BASE :
+		CONFIG_SYS_TEXT_BASE;
+}
+
 /*
  * Weak default function for board specific cleanup/preparation before
  * Linux boot. Some boards/platforms might not need it, so just provide
diff --git a/include/spl.h b/include/spl.h
index faffeb519ac..e172500b5f8 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -254,6 +254,16 @@  ulong spl_get_image_pos(void);
  */
 ulong spl_get_image_size(void);
 
+/**
+ * spl_get_image_text_base() - get the text base of the next phase
+ *
+ * This returns the address that the next stage is linked to run at, i.e.
+ * CONFIG_SPL_TEXT_BASE or CONFIG_SYS_TEXT_BASE
+ *
+ * @return text-base address
+ */
+ulong spl_get_image_text_base(void);
+
 /**
  * spl_load_simple_fit_skip_processing() - Hook to allow skipping the FIT
  *	image processing during spl_load_simple_fit().