mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Sam Ravnborg <sam@ravnborg.org>, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v4 03/14] ARM: replace ENTRY_FUNCTION_HEAD with ENTRY_FUNCTION_WITHSTACK_HEAD
Date: Tue, 20 Feb 2024 10:30:49 +0100	[thread overview]
Message-ID: <20240220093100.1539120-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240220093100.1539120-1-a.fatoum@pengutronix.de>

To allow SoC-specific entry functions that don't replicate the code in
ENTRY_FUNCTION, we provide a helper macro that support specifying
a custom HEAD, but only on arm32. Make this macro private by prefixing
with __ and implement the superset ENTRY_FUNCTION_WITHSTACK_HEAD for
both arm32 and arm64 that should be used instead.

Eventually, we will want to switch away from naked functions on arm32,
like we did on arm64 and then we could use the same implementation for
both platforms (and support clang on arm32!), but till then, this seems
the least ugly way to go about it.

Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/include/asm/barebox-arm.h    | 20 ++++++++++++++------
 include/mach/at91/barebox-arm.h       |  2 +-
 include/mach/mvebu/barebox-arm-head.h |  2 +-
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 382fa8505a66..361edcf37eef 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -165,7 +165,7 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
 
 void __barebox_arm64_head(ulong x0, ulong x1, ulong x2);
 
-#define ENTRY_FUNCTION_WITHSTACK(name, stack_top, arg0, arg1, arg2)	\
+#define ENTRY_FUNCTION_WITHSTACK_HEAD(name, stack_top, head, arg0, arg1, arg2)	\
 	void name(ulong r0, ulong r1, ulong r2);			\
 									\
 	static void __##name(ulong, ulong, ulong);			\
@@ -175,20 +175,24 @@ void __barebox_arm64_head(ulong x0, ulong x1, ulong x2);
 		{							\
 			static __section(.pbl_board_stack_top_##name)	\
 				const ulong __stack_top = (stack_top);	\
-			__keep_symbolref(__barebox_arm64_head);		\
+			__keep_symbolref(head);				\
 			__keep_symbolref(__stack_top);			\
 			__##name(r0, r1, r2);				\
 		}							\
 		static void noinline __##name				\
 			(ulong arg0, ulong arg1, ulong arg2)
 
+#define ENTRY_FUNCTION_WITHSTACK(name, stack_top, arg0, arg1, arg2)	\
+	ENTRY_FUNCTION_WITHSTACK_HEAD(name, stack_top,			\
+			      __barebox_arm64_head, arg0, arg1, arg2)
+
 #define ENTRY_FUNCTION(name, arg0, arg1, arg2)				\
 	ENTRY_FUNCTION_WITHSTACK(name, 0, arg0, arg1, arg2)
 
 #else
-#define ENTRY_FUNCTION_WITHSTACK(name, stack_top, arg0, arg1, arg2)	\
+#define ENTRY_FUNCTION_WITHSTACK_HEAD(name, stack_top, head, arg0, arg1, arg2)	\
 	static void ____##name(ulong, ulong, ulong);			\
-	ENTRY_FUNCTION(name, arg0, arg1, arg2)				\
+	__ENTRY_FUNCTION_HEAD(name, head, arg0, arg1, arg2)		\
 	{								\
 		if (stack_top)						\
 			arm_setup_stack(stack_top);			\
@@ -197,7 +201,7 @@ void __barebox_arm64_head(ulong x0, ulong x1, ulong x2);
 	static void noinline ____##name					\
 		(ulong arg0, ulong arg1, ulong arg2)
 
-#define ENTRY_FUNCTION_HEAD(name, head, arg0, arg1, arg2)		\
+#define __ENTRY_FUNCTION_HEAD(name, head, arg0, arg1, arg2)		\
 	void name(ulong r0, ulong r1, ulong r2);			\
 									\
 	static void __##name(ulong, ulong, ulong);			\
@@ -212,7 +216,11 @@ void __barebox_arm64_head(ulong x0, ulong x1, ulong x2);
 		(ulong arg0, ulong arg1, ulong arg2)
 
 #define ENTRY_FUNCTION(name, arg0, arg1, arg2)		\
-		ENTRY_FUNCTION_HEAD(name, __barebox_arm_head, arg0, arg1, arg2)
+	__ENTRY_FUNCTION_HEAD(name, __barebox_arm_head, arg0, arg1, arg2)
+
+#define ENTRY_FUNCTION_WITHSTACK(name, stack_top, arg0, arg1, arg2)	\
+	ENTRY_FUNCTION_WITHSTACK_HEAD(name, stack_top, \
+			      __barebox_arm_head, arg0, arg1, arg2)
 #endif
 
 /*
diff --git a/include/mach/at91/barebox-arm.h b/include/mach/at91/barebox-arm.h
index f1014542bee2..f82b82ebed8b 100644
--- a/include/mach/at91/barebox-arm.h
+++ b/include/mach/at91/barebox-arm.h
@@ -69,6 +69,6 @@ static __always_inline void __barebox_at91_head(void)
 	SAMA5_ENTRY_FUNCTION(name, SAMA5D4_SRAM_BASE + SAMA5D4_SRAM_SIZE, r4)
 
 #define AT91_ENTRY_FUNCTION(fn, r0, r1, r2)					\
-	ENTRY_FUNCTION_HEAD(fn, __barebox_at91_head, r0, r1, r2)
+	ENTRY_FUNCTION_WITHSTACK_HEAD(fn, 0, __barebox_at91_head, r0, r1, r2)
 
 #endif
diff --git a/include/mach/mvebu/barebox-arm-head.h b/include/mach/mvebu/barebox-arm-head.h
index 76e426e3b867..5afd900201c6 100644
--- a/include/mach/mvebu/barebox-arm-head.h
+++ b/include/mach/mvebu/barebox-arm-head.h
@@ -55,4 +55,4 @@ static inline void __barebox_mvebu_head(void)
 }
 
 #define ENTRY_FUNCTION_MVEBU(name, arg0, arg1, arg2) \
-	ENTRY_FUNCTION_HEAD(name, __barebox_mvebu_head, arg0, arg1, arg2)
+	ENTRY_FUNCTION_WITHSTACK_HEAD(name, 0, __barebox_mvebu_head, arg0, arg1, arg2)
-- 
2.39.2




  parent reply	other threads:[~2024-02-20  9:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20  9:30 [PATCH v4 00/14] ARM: at91: skov-arm9cpu (SAM9263) first stage support Ahmad Fatoum
2024-02-20  9:30 ` [PATCH v4 01/14] mci: atmel_mci: disable power save mode Ahmad Fatoum
2024-02-20  9:30 ` [PATCH v4 02/14] mci: atmel_mci: fix zeroing of block length on AT91SAM9263 Ahmad Fatoum
2024-02-20  9:30 ` Ahmad Fatoum [this message]
2024-02-20  9:30 ` [PATCH v4 04/14] ARM: at91: use AT91 header instead of generic barebox ARM's Ahmad Fatoum
2024-02-20  9:30 ` [PATCH v4 05/14] ARM: at91: implement SAM9_ENTRY_FUNCTION Ahmad Fatoum
2024-02-20  9:30 ` [PATCH v4 06/14] ARM: at91: sam9263_ll: drop PLL charge pump initialization Ahmad Fatoum
2024-02-20  9:30 ` [PATCH v4 07/14] ARM: at91: sam9263_ll: pass AT91_PMC_LL_AT91SAM9263 to PMC functions Ahmad Fatoum
2024-02-20  9:30 ` [PATCH v4 08/14] ARM: at91: sam9263_ll: refactor MCK switch to PLLA for clarity Ahmad Fatoum
2024-02-20  9:30 ` [PATCH v4 09/14] ARM: at91: sam9263_ll: support configuration of PLLB Ahmad Fatoum
2024-02-20  9:30 ` [PATCH v4 10/14] ARM: dts: AT91: skov-arm9cpu: remove barebox environment on NOR Ahmad Fatoum
2024-02-20  9:30 ` [PATCH v4 11/14] ARM: at91: skov-arm9cpu: Add SD-Card xload support Ahmad Fatoum
2024-02-20  9:30 ` [PATCH v4 12/14] ARM: at91: skov-arm9cpu: configure SMC for NOR flash use Ahmad Fatoum
2024-02-20  9:30 ` [PATCH v4 13/14] ARM: at91: skov-arm9cpu: configure more appropriate hostname Ahmad Fatoum
2024-02-20  9:31 ` [PATCH v4 14/14] ARM: AT91: skov-arm9cpu: support environment on SD-Card Ahmad Fatoum
2024-02-23  7:32 ` [PATCH v4 00/14] ARM: at91: skov-arm9cpu (SAM9263) first stage support Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240220093100.1539120-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox