mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH 2/3] store external device tree as file
Date: Mon, 09 Dec 2024 15:28:12 +0100	[thread overview]
Message-ID: <20241209-ext-dt-handoff-v1-2-e61052d5d437@pengutronix.de> (raw)
In-Reply-To: <20241209-ext-dt-handoff-v1-0-e61052d5d437@pengutronix.de>

When barebox is chainloaded from another bootloader it usually gets
passed a device tree from the previous bootloader. While this external
device tree is normally not used by barebox, its contents can still be
interesting, so store the device tree at /external-devicetree when
found. This needs board support to pass the external device tree in
handoff data, i.e. a board has to call
handoff_data_add(HANDOFF_DATA_EXTERNAL_DT, dtb, size);

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/startup.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/common/startup.c b/common/startup.c
index b311b77418..abdc0c2db0 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -40,6 +40,8 @@
 #include <net.h>
 #include <efi/efi-mode.h>
 #include <bselftest.h>
+#include <pbl/handoff-data.h>
+#include <libfile.h>
 
 extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[],
 		  __barebox_initcalls_end[];
@@ -246,6 +248,8 @@ static int run_init(void)
 	struct stat s;
 	glob_t g;
 	int i, ret;
+	size_t size;
+	void *ext_dtb;
 
 	setenv("PATH", "/env/bin");
 	export("PATH");
@@ -289,6 +293,10 @@ static int run_init(void)
 		globfree(&g);
 	}
 
+	ext_dtb = handoff_data_get_entry(HANDOFF_DATA_EXTERNAL_DT, &size);
+	if (ext_dtb)
+		write_file("/external-devicetree", ext_dtb, size);
+
 	/* source matching script in /env/bmode/ */
 	bmode = reboot_mode_get();
 	if (bmode) {

-- 
2.39.5




  parent reply	other threads:[~2024-12-09 14:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-09 14:28 [PATCH 0/3] make dtb from 1st stage loader available in barebox Sascha Hauer
2024-12-09 14:28 ` [PATCH 1/3] fdt: Add function to check if a pointer contains a fdt Sascha Hauer
2024-12-09 14:28 ` Sascha Hauer [this message]
2024-12-09 14:28 ` [PATCH 3/3] ARM: beagleplay: put external device tree into handoff data Sascha Hauer
2024-12-16  8:31 ` [PATCH 0/3] make dtb from 1st stage loader available in barebox 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=20241209-ext-dt-handoff-v1-2-e61052d5d437@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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