[PATCH 1/3] RISC-V: asm: factor relocation related functions into asm/reloc.h
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Aug 5 00:42:35 PDT 2022
To allow use of global_variable_offset() from common PBL code,
move the definition into a new <asm/reloc.h> header.
At current time, it's expected that PBL enabled platforms define
at least get_runtime_offset() there.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
arch/riscv/include/asm/barebox-riscv.h | 7 +------
arch/riscv/include/asm/reloc.h | 15 +++++++++++++++
include/asm-generic/reloc.h | 10 ++++++++++
3 files changed, 26 insertions(+), 6 deletions(-)
create mode 100644 arch/riscv/include/asm/reloc.h
create mode 100644 include/asm-generic/reloc.h
diff --git a/arch/riscv/include/asm/barebox-riscv.h b/arch/riscv/include/asm/barebox-riscv.h
index 5c87d37c9eb8..db6ff0ea7131 100644
--- a/arch/riscv/include/asm/barebox-riscv.h
+++ b/arch/riscv/include/asm/barebox-riscv.h
@@ -21,12 +21,7 @@
#include <asm/barebox-riscv-head.h>
#include <asm/system.h>
#include <asm/cache.h>
-
-unsigned long get_runtime_offset(void);
-
-void setup_c(void);
-void relocate_to_current_adr(void);
-void relocate_to_adr(unsigned long target);
+#include <asm/reloc.h>
void __noreturn __naked barebox_riscv_entry(unsigned long membase, unsigned long memsize,
void *boarddata, unsigned int flags);
diff --git a/arch/riscv/include/asm/reloc.h b/arch/riscv/include/asm/reloc.h
new file mode 100644
index 000000000000..9a59326cad27
--- /dev/null
+++ b/arch/riscv/include/asm/reloc.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _ASM_RELOC_H_
+#define _ASM_RELOC_H_
+
+unsigned long get_runtime_offset(void);
+
+void relocate_to_current_adr(void);
+void relocate_to_adr(unsigned long target);
+
+void setup_c(void);
+
+#include <asm-generic/reloc.h>
+
+#endif /* _BAREBOX_RISCV_H_ */
diff --git a/include/asm-generic/reloc.h b/include/asm-generic/reloc.h
new file mode 100644
index 000000000000..90459371ebe8
--- /dev/null
+++ b/include/asm-generic/reloc.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _ASM_GENERIC_RELOC_H_
+#define _ASM_GENERIC_RELOC_H_
+
+#ifndef global_variable_offset
+#define global_variable_offset() get_runtime_offset()
+#endif
+
+#endif
--
2.30.2
More information about the barebox
mailing list