mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/4] efi-payload: use handoff data to pass data to barebox proper
Date: Tue, 21 May 2024 12:49:11 +0200	[thread overview]
Message-ID: <20240521104913.1983970-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20240521104913.1983970-1-s.hauer@pengutronix.de>

EFI payload uses custom fields in struct boarddata to pass data from PBL
to barebox proper. handoff data was created for exactly this purpose.
Now that we have it, switch EFI payload over to use it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 efi/payload/boarddata.c    | 12 +++++++-----
 efi/payload/entry-multi.c  | 16 +++++++---------
 include/boarddata.h        |  4 ----
 include/efi/efi-payload.h  |  5 +++++
 include/pbl/handoff-data.h |  1 +
 5 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/efi/payload/boarddata.c b/efi/payload/boarddata.c
index 3260e31c7b..d4e4b5ac1d 100644
--- a/efi/payload/boarddata.c
+++ b/efi/payload/boarddata.c
@@ -8,25 +8,27 @@
 
 #include <efi/efi-payload.h>
 #include <efi.h>
-#include <boarddata.h>
 #include <memory.h>
 #include <linux/kernel.h>
 #include <linux/printk.h>
 #include <debug_ll.h>
 #include <init.h>
+#include <pbl/handoff-data.h>
 
 static int handle_efi_boarddata(void)
 {
-	const struct barebox_boarddata *bd = barebox_get_boarddata();
+	size_t size;
+	struct barebox_efi_data *efidata;
 	efi_status_t efiret;
 
-	if (!barebox_boarddata_is_machine(bd, BAREBOX_MACH_TYPE_EFI))
+	efidata = handoff_data_get_entry(HANDOFF_DATA_EFI, &size);
+	if (!efidata)
 		return 0;
 
 	barebox_add_memory_bank("ram0", mem_malloc_start(), mem_malloc_size());
 
-	efi_parent_image = bd->image;
-	efi_sys_table = bd->sys_table;
+	efi_parent_image = efidata->image;
+	efi_sys_table = efidata->sys_table;
 	BS = efi_sys_table->boottime;
 	RT = efi_sys_table->runtime;
 
diff --git a/efi/payload/entry-multi.c b/efi/payload/entry-multi.c
index f929ab01ec..26cf2ebfa7 100644
--- a/efi/payload/entry-multi.c
+++ b/efi/payload/entry-multi.c
@@ -3,18 +3,13 @@
 #include <linux/kernel.h>
 #include <linux/linkage.h>
 #include <linux/sizes.h>
-#include <boarddata.h>
 #include <stdio.h>
 #include <efi.h>
 #include <asm/common.h>
 #include <efi/efi-util.h>
 #include <efi/efi-payload.h>
 #include <pbl.h>
-
-static struct barebox_boarddata boarddata = {
-	.magic = BAREBOX_BOARDDATA_MAGIC,
-	.machine = BAREBOX_MACH_TYPE_EFI,
-};
+#include <pbl/handoff-data.h>
 
 asmlinkage void __efistub_efi_pe_entry(void *image, struct efi_system_table *sys_table);
 
@@ -30,16 +25,19 @@ void __efistub_efi_pe_entry(void *image, struct efi_system_table *sys_table)
 {
 	size_t memsize;
 	efi_physical_addr_t mem;
+	static struct barebox_efi_data efidata;
 
 #ifdef DEBUG
 	sys_table->con_out->output_string(sys_table->con_out, L"\nbarebox\n");
 #endif
 	pbl_set_putc(efi_putc, sys_table);
 
-	boarddata.image = image;
-	boarddata.sys_table = sys_table;
+	efidata.image = image;
+	efidata.sys_table = sys_table;
+
+	handoff_data_add(HANDOFF_DATA_EFI, &efidata, sizeof(efidata));
 
 	mem = efi_earlymem_alloc(sys_table, &memsize);
 
-	barebox_pbl_entry(mem, memsize, &boarddata);
+	barebox_pbl_entry(mem, memsize, NULL);
 }
diff --git a/include/boarddata.h b/include/boarddata.h
index 8c048fd957..6092d5f304 100644
--- a/include/boarddata.h
+++ b/include/boarddata.h
@@ -15,10 +15,6 @@ struct barebox_boarddata {
 		      * that do not potientially clashes with registered machines,
 		      * i.e. use a number > 0x10000.
 		      */
-#ifdef CONFIG_EFI_STUB
-	void *image;
-	void *sys_table;
-#endif
 };
 
 /*
diff --git a/include/efi/efi-payload.h b/include/efi/efi-payload.h
index 774c069229..73b1b9bd8e 100644
--- a/include/efi/efi-payload.h
+++ b/include/efi/efi-payload.h
@@ -8,6 +8,11 @@
 struct efi_system_table;
 struct efi_loaded_image;
 
+struct barebox_efi_data {
+	void *image;
+	void *sys_table;
+};
+
 extern struct efi_system_table *efi_sys_table;
 extern efi_handle_t efi_parent_image;
 extern struct efi_device_path *efi_device_path;
diff --git a/include/pbl/handoff-data.h b/include/pbl/handoff-data.h
index 18ea9e508b..044b4bb884 100644
--- a/include/pbl/handoff-data.h
+++ b/include/pbl/handoff-data.h
@@ -12,6 +12,7 @@ struct handoff_data {
 #define HANDOFF_DATA_INTERNAL_DT_Z	HANDOFF_DATA_BAREBOX(1)
 #define HANDOFF_DATA_EXTERNAL_DT	HANDOFF_DATA_BAREBOX(2)
 #define HANDOFF_DATA_BOARDDATA		HANDOFF_DATA_BAREBOX(3)
+#define HANDOFF_DATA_EFI		HANDOFF_DATA_BAREBOX(4)
 
 #define HANDOFF_DATA_BOARD(n)		(0x951726fb + (n))
 
-- 
2.39.2




  parent reply	other threads:[~2024-05-21 10:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21 10:49 [PATCH 0/4] make more use of handoff data Sascha Hauer
2024-05-21 10:49 ` [PATCH 1/4] handoff-data: put handoff data into data section Sascha Hauer
2024-05-21 10:49 ` Sascha Hauer [this message]
2024-05-21 12:39   ` [PATCH 2/4] efi-payload: use handoff data to pass data to barebox proper Ahmad Fatoum
2024-05-21 10:49 ` [PATCH 3/4] ARM: beagle: setup C environment early Sascha Hauer
2024-05-21 10:49 ` [PATCH 4/4] ARM: replace boarddata with handoff data Sascha Hauer
2024-05-22  5:42 ` [PATCH 0/4] make more use of " 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=20240521104913.1983970-3-s.hauer@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