From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: mfe@pengutronix.de, mtr@pengutronix.de,
Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [RFC PATCH 10/17] RISC-V: hifive: migrate to board info entry point
Date: Tue, 27 Oct 2026 08:24:43 +0100 [thread overview]
Message-ID: <20261027074014.3280396-11-a.fatoum@barebox.org> (raw)
In-Reply-To: <20261027074014.3280396-1-a.fatoum@barebox.org>
OpenSBI starts the HiFive images like a kernel, so they use the
supervisor mode head. Both boards hand the first 128M of DRAM to barebox
proper, so that goes into the new SiFive SoC defaults and the boards
only add their built-in device tree.
The '>' is now printed by the stage dispatch.
Assisted-by: Claude:fable-5.1
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
arch/riscv/boards/hifive/lowlevel.c | 30 ++++++++-------------------
include/mach/sifive/entry.h | 32 +++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 21 deletions(-)
create mode 100644 include/mach/sifive/entry.h
diff --git a/arch/riscv/boards/hifive/lowlevel.c b/arch/riscv/boards/hifive/lowlevel.c
index 5e8969bef1da..ab60c7e96a78 100644
--- a/arch/riscv/boards/hifive/lowlevel.c
+++ b/arch/riscv/boards/hifive/lowlevel.c
@@ -1,26 +1,14 @@
// SPDX-License-Identifier: GPL-2.0-only
-#include <common.h>
-#include <asm/barebox-riscv.h>
-#include <debug_ll.h>
+#include <mach/sifive/entry.h>
-static __always_inline void start_hifive(unsigned long hartid, void *fdt)
-{
- putc_ll('>');
+extern char __dtb_z_hifive_unmatched_a00_start[];
+extern char __dtb_z_hifive_unleashed_a00_start[];
- barebox_riscv_supervisor_entry(0x80000000, SZ_128M, hartid, fdt);
-}
+ENTRY_POINT(FU740, start_hifive_unmatched)
+ .second_stage.board_data = __dtb_z_hifive_unmatched_a00_start,
+ENTRY_POINT_END
-ENTRY_FUNCTION(start_hifive_unmatched, a0, a1, a2)
-{
- extern char __dtb_z_hifive_unmatched_a00_start[];
-
- start_hifive(a0, __dtb_z_hifive_unmatched_a00_start + get_runtime_offset());
-}
-
-ENTRY_FUNCTION(start_hifive_unleashed, a0, a1, a2)
-{
- extern char __dtb_z_hifive_unleashed_a00_start[];
-
- start_hifive(a0, __dtb_z_hifive_unleashed_a00_start + get_runtime_offset());
-}
+ENTRY_POINT(FU540, start_hifive_unleashed)
+ .second_stage.board_data = __dtb_z_hifive_unleashed_a00_start,
+ENTRY_POINT_END
diff --git a/include/mach/sifive/entry.h b/include/mach/sifive/entry.h
new file mode 100644
index 000000000000..04529099dcf4
--- /dev/null
+++ b/include/mach/sifive/entry.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __MACH_SIFIVE_ENTRY_H
+#define __MACH_SIFIVE_ENTRY_H
+
+#include <linux/sizes.h>
+#include <pbl/entry.h>
+#include <asm/barebox-riscv.h>
+
+#define SIFIVE_DRAM_BASE 0x80000000
+
+/*
+ * OpenSBI starts the image in supervisor mode in DRAM. Every board has
+ * at least 128M, boards with more can raise mem_minsz. OpenSBI leaves
+ * the UART set up, so there's no console and the PBL uses DEBUG_LL.
+ */
+#define PBL_SOC_SIFIVE_DEFAULTS(soc) \
+ .soc_type = SOC_TYPE_##soc, \
+ .second_stage = { \
+ .stacktop = SIFIVE_DRAM_BASE + SZ_128M, \
+ .mem_start = SIFIVE_DRAM_BASE, \
+ .mem_minsz = SZ_128M, \
+ .soc_chainload = pbl_stage_barebox_entry, \
+ }
+
+#define PBL_SOC_FU540_HEAD __barebox_pbl_head_v1_supervisor
+#define PBL_SOC_FU540_DEFAULTS PBL_SOC_SIFIVE_DEFAULTS(FU540)
+
+#define PBL_SOC_FU740_HEAD __barebox_pbl_head_v1_supervisor
+#define PBL_SOC_FU740_DEFAULTS PBL_SOC_SIFIVE_DEFAULTS(FU740)
+
+#endif
--
2.47.3
next prev parent reply other threads:[~2026-10-27 7:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 7:24 [RFC PATCH 00/17] Switch RISC-V to declarative entry points Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 01/17] asm-generic: add registers.h with a pc_inside() helper Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 02/17] RISC-V: add call_with_stack() helper Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 03/17] RISC-V: implement relocate_to_adr_full() Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 04/17] PBL: add SoC type declaration and handoff support Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 05/17] PBL: introduce board info based entry point framework Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 06/17] PBL: describe the console in the board info and report the stage Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 07/17] RISC-V: make barebox_riscv_entry() non-naked Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 08/17] RISC-V: add PBL heads for the board info stage dispatch Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 09/17] RISC-V: board-dt-2nd: migrate to board info entry point Ahmad Fatoum
2026-10-27 7:24 ` Ahmad Fatoum [this message]
2026-10-27 7:24 ` [RFC PATCH 11/17] RISC-V: allow relocating the PBL more than once Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 12/17] RISC-V: nmon: preserve s1-s3 for the caller Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 13/17] RISC-V: beaglev: migrate to board info entry point Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 14/17] RISC-V: allwinner-d1: " Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 15/17] RISC-V: erizo: " Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 16/17] RISC-V: litex-linux: " Ahmad Fatoum
2026-10-27 7:24 ` [RFC PATCH 17/17] Documentation: porting: describe the " Ahmad Fatoum
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=20261027074014.3280396-11-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
--cc=mfe@pengutronix.de \
--cc=mtr@pengutronix.de \
/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