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 v2 01/11] ARM: at91: sama5: switch to nonnaked entry functions
Date: Mon, 9 Jan 2023 14:08:12 +0100 [thread overview]
Message-ID: <20230109130822.1657470-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230109130822.1657470-1-a.fatoum@pengutronix.de>
Functions were kept naked because they modify the stack pointer.
We can hoist that up and change the board-provided entry point
to be non-naked to be more robust in face of unexpected compiler
optimizations.
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
.../boards/microchip-ksz9477-evb/lowlevel.c | 6 ++----
.../arm/boards/sama5d27-giantboard/lowlevel.c | 4 ++--
arch/arm/boards/sama5d27-som1/lowlevel.c | 4 ++--
arch/arm/boards/sama5d3_xplained/lowlevel.c | 6 ++----
arch/arm/mach-at91/include/mach/barebox-arm.h | 19 +++++++++++++++----
5 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/arch/arm/boards/microchip-ksz9477-evb/lowlevel.c b/arch/arm/boards/microchip-ksz9477-evb/lowlevel.c
index 93ae4819750c..6290766caa78 100644
--- a/arch/arm/boards/microchip-ksz9477-evb/lowlevel.c
+++ b/arch/arm/boards/microchip-ksz9477-evb/lowlevel.c
@@ -32,7 +32,7 @@ static void dbgu_init(void)
putc_ll('>');
}
-SAMA5_ENTRY_FUNCTION(start_sama5d3_xplained_ung8071_xload_mmc, r4)
+SAMA5D3_ENTRY_FUNCTION(start_sama5d3_xplained_ung8071_xload_mmc, r4)
{
sama5d3_lowlevel_init();
@@ -49,12 +49,10 @@ SAMA5_ENTRY_FUNCTION(start_sama5d3_xplained_ung8071_xload_mmc, r4)
extern char __dtb_z_at91_microchip_ksz9477_evb_start[];
-SAMA5_ENTRY_FUNCTION(start_sama5d3_xplained_ung8071, r4)
+SAMA5D3_ENTRY_FUNCTION(start_sama5d3_xplained_ung8071, r4)
{
void *fdt;
- arm_setup_stack(SAMA5D3_SRAM_BASE + SAMA5D3_SRAM_SIZE);
-
if (IS_ENABLED(CONFIG_DEBUG_LL))
dbgu_init();
diff --git a/arch/arm/boards/sama5d27-giantboard/lowlevel.c b/arch/arm/boards/sama5d27-giantboard/lowlevel.c
index ee8297fa4562..fac39dd066a2 100644
--- a/arch/arm/boards/sama5d27-giantboard/lowlevel.c
+++ b/arch/arm/boards/sama5d27-giantboard/lowlevel.c
@@ -15,7 +15,7 @@
/* PCK = 492MHz, MCK = 164MHz */
#define MASTER_CLOCK 164000000
-SAMA5_ENTRY_FUNCTION(start_sama5d27_giantboard_xload_mmc, r4)
+SAMA5D2_ENTRY_FUNCTION(start_sama5d27_giantboard_xload_mmc, r4)
{
void __iomem *dbgu_base;
@@ -36,7 +36,7 @@ SAMA5_ENTRY_FUNCTION(start_sama5d27_giantboard_xload_mmc, r4)
extern char __dtb_z_at91_sama5d27_giantboard_start[];
-SAMA5_ENTRY_FUNCTION(start_sama5d27_giantboard, r4)
+SAMA5D2_ENTRY_FUNCTION(start_sama5d27_giantboard, r4)
{
void *fdt;
diff --git a/arch/arm/boards/sama5d27-som1/lowlevel.c b/arch/arm/boards/sama5d27-som1/lowlevel.c
index b0937119184b..24c08d9722b3 100644
--- a/arch/arm/boards/sama5d27-som1/lowlevel.c
+++ b/arch/arm/boards/sama5d27-som1/lowlevel.c
@@ -39,7 +39,7 @@ static void ek_turn_led(unsigned color)
}
}
-SAMA5_ENTRY_FUNCTION(start_sama5d27_som1_ek_xload_mmc, r4)
+SAMA5D2_ENTRY_FUNCTION(start_sama5d27_som1_ek_xload_mmc, r4)
{
void __iomem *dbgu_base;
sama5d2_lowlevel_init();
@@ -60,7 +60,7 @@ SAMA5_ENTRY_FUNCTION(start_sama5d27_som1_ek_xload_mmc, r4)
extern char __dtb_z_at91_sama5d27_som1_ek_start[];
-SAMA5_ENTRY_FUNCTION(start_sama5d27_som1_ek, r4)
+SAMA5D2_ENTRY_FUNCTION(start_sama5d27_som1_ek, r4)
{
void *fdt;
diff --git a/arch/arm/boards/sama5d3_xplained/lowlevel.c b/arch/arm/boards/sama5d3_xplained/lowlevel.c
index df561af36d5e..be6b2960d40d 100644
--- a/arch/arm/boards/sama5d3_xplained/lowlevel.c
+++ b/arch/arm/boards/sama5d3_xplained/lowlevel.c
@@ -33,7 +33,7 @@ static void dbgu_init(void)
pbl_set_putc(at91_dbgu_putc, IOMEM(AT91_BASE_DBGU1));
}
-SAMA5_ENTRY_FUNCTION(start_sama5d3_xplained_xload_mmc, r4)
+SAMA5D3_ENTRY_FUNCTION(start_sama5d3_xplained_xload_mmc, r4)
{
sama5d3_lowlevel_init();
@@ -50,12 +50,10 @@ SAMA5_ENTRY_FUNCTION(start_sama5d3_xplained_xload_mmc, r4)
extern char __dtb_z_at91_sama5d3_xplained_start[];
-SAMA5_ENTRY_FUNCTION(start_sama5d3_xplained, r4)
+SAMA5D3_ENTRY_FUNCTION(start_sama5d3_xplained, r4)
{
void *fdt;
- arm_setup_stack(SAMA5D3_SRAM_BASE + SAMA5D3_SRAM_SIZE);
-
if (IS_ENABLED(CONFIG_DEBUG_LL))
dbgu_init();
diff --git a/arch/arm/mach-at91/include/mach/barebox-arm.h b/arch/arm/mach-at91/include/mach/barebox-arm.h
index 4a65c6f8fa55..f6bdd5ab2375 100644
--- a/arch/arm/mach-at91/include/mach/barebox-arm.h
+++ b/arch/arm/mach-at91/include/mach/barebox-arm.h
@@ -3,19 +3,30 @@
#define AT91_BAREBOX_ARM_H_
#include <asm/barebox-arm.h>
+#include <asm/common.h>
+#include <mach/sama5d3.h>
-#define SAMA5_ENTRY_FUNCTION(name, r4) \
+#define SAMA5_ENTRY_FUNCTION(name, stack_top, r4) \
void name (u32 r0, u32 r1, u32 r2, u32 r3); \
\
static void __##name(u32); \
\
- void NAKED __section(.text_head_entry_##name) name \
+ void __naked __section(.text_head_entry_##name) name \
(u32 r0, u32 r1, u32 r2, u32 r3) \
{ \
register u32 r4 asm("r4"); \
__barebox_arm_head(); \
+ if (stack_top) \
+ arm_setup_stack(stack_top); \
__##name(r4); \
} \
- static void NAKED noinline __##name \
- (u32 r4)
+ static void noinline __##name(u32 r4)
+
+/* BootROM already initialized usable stack top */
+#define SAMA5D2_ENTRY_FUNCTION(name, r4) \
+ SAMA5_ENTRY_FUNCTION(name, 0, r4)
+
+#define SAMA5D3_ENTRY_FUNCTION(name, r4) \
+ SAMA5_ENTRY_FUNCTION(name, SAMA5D3_SRAM_BASE + SAMA5D3_SRAM_SIZE, r4)
+
#endif
--
2.30.2
next prev parent reply other threads:[~2023-01-09 13:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 13:08 [PATCH v2 00/11] ARM: at91: sama5d4: add basic Wifx L1 support Ahmad Fatoum
2023-01-09 13:08 ` Ahmad Fatoum [this message]
2023-01-09 13:08 ` [PATCH v2 02/11] ARM: at91: sama5d4: add entry point helpers Ahmad Fatoum
2023-01-09 13:08 ` [PATCH v2 03/11] ARM: at91: sama5d4: enable for DT use Ahmad Fatoum
2023-01-11 10:37 ` Sascha Hauer
2023-01-09 13:08 ` [PATCH v2 04/11] net: macb: match atmel,sama5d4-gem compatible Ahmad Fatoum
2023-01-09 13:08 ` [PATCH v2 05/11] i2c: at91: extend for SAMA5D4 support Ahmad Fatoum
2023-01-09 13:08 ` [PATCH v2 06/11] eeprom: at24: add 24mac402/602 support Ahmad Fatoum
2023-01-09 13:08 ` [PATCH v2 07/11] driver: always ensure probe of RAM registered with mem_platform_driver Ahmad Fatoum
2023-01-09 13:08 ` [PATCH v2 08/11] common: deep-probe: don't build without CONFIG_OFDEVICE Ahmad Fatoum
2023-01-09 13:08 ` [PATCH v2 09/11] pinctrl: at91: make deep-probe compatible Ahmad Fatoum
2023-01-09 13:08 ` [PATCH v2 10/11] ARM: at91: make bootsource code generic to all SAMA5 Ahmad Fatoum
2023-01-09 13:08 ` [PATCH v2 11/11] ARM: at91: SAMA5D4: add Wifx L1 support Ahmad Fatoum
2023-01-10 15:05 ` [PATCH v2 00/11] ARM: at91: sama5d4: add basic " 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=20230109130822.1657470-2-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