mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/4] make more use of handoff data
@ 2024-05-21 10:49 Sascha Hauer
  2024-05-21 10:49 ` [PATCH 1/4] handoff-data: put handoff data into data section Sascha Hauer
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Sascha Hauer @ 2024-05-21 10:49 UTC (permalink / raw)
  To: Barebox List

struct boarddata is a mechanism to pass a ARM machine number from PBL to
barebox proper. The EFI payload also uses it to pass some custom
pointers to barebox proper. handoff data was created for exactly this
purpose, so retire boarddata and use handoff data instead.

@afa, the efi patch is compile tested only. Could you give it a try?

Sascha

Sascha Hauer (4):
  handoff-data: put handoff data into data section
  efi-payload: use handoff data to pass data to barebox proper
  ARM: beagle: setup C environment early
  ARM: replace boarddata with handoff data

 arch/arm/boards/beagle/lowlevel.c             |  9 ++--
 arch/arm/boards/chumby_falconwing/lowlevel.c  |  7 +--
 .../boards/crystalfontz-cfa10036/lowlevel.c   |  7 +--
 arch/arm/boards/freescale-mx23-evk/lowlevel.c |  7 +--
 arch/arm/boards/imx233-olinuxino/lowlevel.c   |  7 +--
 arch/arm/boards/karo-tx28/lowlevel.c          |  7 +--
 arch/arm/cpu/start.c                          | 20 +++-----
 arch/arm/cpu/uncompress.c                     |  3 --
 arch/arm/include/asm/barebox-arm.h            | 24 ++++-----
 efi/payload/boarddata.c                       | 12 +++--
 efi/payload/entry-multi.c                     | 16 +++---
 include/boarddata.h                           | 49 -------------------
 include/efi/efi-payload.h                     |  5 ++
 include/pbl/handoff-data.h                    | 21 ++++----
 pbl/handoff-data.c                            |  6 +--
 15 files changed, 64 insertions(+), 136 deletions(-)
 delete mode 100644 include/boarddata.h

-- 
2.39.2




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] handoff-data: put handoff data into data section
  2024-05-21 10:49 [PATCH 0/4] make more use of handoff data Sascha Hauer
@ 2024-05-21 10:49 ` Sascha Hauer
  2024-05-21 10:49 ` [PATCH 2/4] efi-payload: use handoff data to pass data to barebox proper Sascha Hauer
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2024-05-21 10:49 UTC (permalink / raw)
  To: Barebox List

The intention was to put the handoff data into the data section and not
into the bss section so that it won't be cleared by another call to
setup_c(). This was not fully done, add a __section(.data) to the
missing places.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 include/pbl/handoff-data.h | 18 +++++++++---------
 pbl/handoff-data.c         |  2 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/pbl/handoff-data.h b/include/pbl/handoff-data.h
index 7f883421df..18ea9e508b 100644
--- a/include/pbl/handoff-data.h
+++ b/include/pbl/handoff-data.h
@@ -24,15 +24,15 @@ struct handoff_data_entry {
 	unsigned int flags;
 };
 
-#define handoff_data_add_flags(_cookie, _data, _size, _flags)	\
-	do {							\
-		static struct handoff_data_entry hde;		\
-		hde.cookie = _cookie;				\
-		hde.data = _data;				\
-		hde.size = _size;				\
-		hde.flags = _flags;				\
-								\
-		handoff_data_add_entry(&hde);			\
+#define handoff_data_add_flags(_cookie, _data, _size, _flags)		\
+	do {								\
+		static struct handoff_data_entry hde __section(.data);	\
+		hde.cookie = _cookie;					\
+		hde.data = _data;					\
+		hde.size = _size;					\
+		hde.flags = _flags;					\
+									\
+		handoff_data_add_entry(&hde);				\
 	} while (0);
 
 #define handoff_data_add(_cookie, _data, _size)			\
diff --git a/pbl/handoff-data.c b/pbl/handoff-data.c
index e6745797c0..85c3985995 100644
--- a/pbl/handoff-data.c
+++ b/pbl/handoff-data.c
@@ -9,7 +9,7 @@ static struct handoff_data *handoff_data = (void *)-1;
 
 static struct handoff_data *handoff_data_get(void)
 {
-	static struct handoff_data __handoff_data;
+	static struct handoff_data __handoff_data __section(.data);
 
 	/*
 	 * Sometimes the PBL copies itself to some other location and is
-- 
2.39.2




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/4] efi-payload: use handoff data to pass data to barebox proper
  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
  2024-05-21 12:39   ` Ahmad Fatoum
  2024-05-21 10:49 ` [PATCH 3/4] ARM: beagle: setup C environment early Sascha Hauer
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2024-05-21 10:49 UTC (permalink / raw)
  To: Barebox List

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




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/4] ARM: beagle: setup C environment early
  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 ` [PATCH 2/4] efi-payload: use handoff data to pass data to barebox proper Sascha Hauer
@ 2024-05-21 10:49 ` 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
  4 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2024-05-21 10:49 UTC (permalink / raw)
  To: Barebox List

Setup C environment in early board code. This will be needed in the next
step. Factored out to a separate patch to ease bisecting.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/beagle/lowlevel.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/boards/beagle/lowlevel.c b/arch/arm/boards/beagle/lowlevel.c
index e4610722f6..828c8c76b3 100644
--- a/arch/arm/boards/beagle/lowlevel.c
+++ b/arch/arm/boards/beagle/lowlevel.c
@@ -175,6 +175,9 @@ ENTRY_FUNCTION(start_omap3_beagleboard_sdram, bootinfo, r1, r2)
 {
 	omap3_save_bootinfo((void *)bootinfo);
 
+	relocate_to_current_adr();
+	setup_c();
+
 	beagle_board_init_sdram();
 }
 
-- 
2.39.2




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/4] ARM: replace boarddata with handoff data
  2024-05-21 10:49 [PATCH 0/4] make more use of handoff data Sascha Hauer
                   ` (2 preceding siblings ...)
  2024-05-21 10:49 ` [PATCH 3/4] ARM: beagle: setup C environment early Sascha Hauer
@ 2024-05-21 10:49 ` Sascha Hauer
  2024-05-22  5:42 ` [PATCH 0/4] make more use of " Sascha Hauer
  4 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2024-05-21 10:49 UTC (permalink / raw)
  To: Barebox List

struct boarddata can be used to pass a ARM machine number from PBL to
barebox proper. Now that we have handoff data for this purpose, retire
struct boarddata and use handoff data instead.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/beagle/lowlevel.c             |  6 +--
 arch/arm/boards/chumby_falconwing/lowlevel.c  |  7 +--
 .../boards/crystalfontz-cfa10036/lowlevel.c   |  7 +--
 arch/arm/boards/freescale-mx23-evk/lowlevel.c |  7 +--
 arch/arm/boards/imx233-olinuxino/lowlevel.c   |  7 +--
 arch/arm/boards/karo-tx28/lowlevel.c          |  7 +--
 arch/arm/cpu/start.c                          | 20 +++------
 arch/arm/cpu/uncompress.c                     |  3 --
 arch/arm/include/asm/barebox-arm.h            | 24 ++++------
 include/boarddata.h                           | 45 -------------------
 include/pbl/handoff-data.h                    |  2 +-
 pbl/handoff-data.c                            |  4 +-
 12 files changed, 31 insertions(+), 108 deletions(-)
 delete mode 100644 include/boarddata.h

diff --git a/arch/arm/boards/beagle/lowlevel.c b/arch/arm/boards/beagle/lowlevel.c
index 828c8c76b3..e7f76aca4e 100644
--- a/arch/arm/boards/beagle/lowlevel.c
+++ b/arch/arm/boards/beagle/lowlevel.c
@@ -164,11 +164,9 @@ static void sdrc_init(void)
 
 static noinline int beagle_board_init_sdram(void)
 {
-	struct barebox_arm_boarddata *bd = (void *)OMAP3_SRAM_SCRATCH_SPACE + 0x10;
+	handoff_add_arm_machine(MACH_TYPE_OMAP3_BEAGLE);
 
-	boarddata_create(bd, MACH_TYPE_OMAP3_BEAGLE);
-
-	barebox_arm_entry(0x80000000, SZ_128M, bd);
+	barebox_arm_entry(0x80000000, SZ_128M, NULL);
 }
 
 ENTRY_FUNCTION(start_omap3_beagleboard_sdram, bootinfo, r1, r2)
diff --git a/arch/arm/boards/chumby_falconwing/lowlevel.c b/arch/arm/boards/chumby_falconwing/lowlevel.c
index fdda6ba5f2..e823767739 100644
--- a/arch/arm/boards/chumby_falconwing/lowlevel.c
+++ b/arch/arm/boards/chumby_falconwing/lowlevel.c
@@ -9,12 +9,9 @@
 
 static noinline void continue_imx_entry(size_t size)
 {
-	static struct barebox_arm_boarddata boarddata = {
-		.magic = BAREBOX_ARM_BOARDDATA_MAGIC,
-		.machine = MACH_TYPE_CHUMBY,
-	};
+	handoff_add_arm_machine(MACH_TYPE_CHUMBY);
 
-	barebox_arm_entry(IMX_MEMORY_BASE, size, &boarddata);
+	barebox_arm_entry(IMX_MEMORY_BASE, size, NULL);
 }
 
 ENTRY_FUNCTION(start_chumby_falconwing, r0, r1, r2)
diff --git a/arch/arm/boards/crystalfontz-cfa10036/lowlevel.c b/arch/arm/boards/crystalfontz-cfa10036/lowlevel.c
index 447ef0dc66..2468f304e7 100644
--- a/arch/arm/boards/crystalfontz-cfa10036/lowlevel.c
+++ b/arch/arm/boards/crystalfontz-cfa10036/lowlevel.c
@@ -9,12 +9,9 @@
 
 static noinline void continue_imx_entry(size_t size)
 {
-	static struct barebox_arm_boarddata boarddata = {
-		.magic = BAREBOX_ARM_BOARDDATA_MAGIC,
-		.machine = MACH_TYPE_CFA10036,
-	};
+	handoff_add_arm_machine(MACH_TYPE_CFA10036);
 
-	barebox_arm_entry(IMX_MEMORY_BASE, size, &boarddata);
+	barebox_arm_entry(IMX_MEMORY_BASE, size, NULL);
 }
 
 ENTRY_FUNCTION(start_cfa10036, r0, r1, r2)
diff --git a/arch/arm/boards/freescale-mx23-evk/lowlevel.c b/arch/arm/boards/freescale-mx23-evk/lowlevel.c
index 195ade3a7f..2f31b4fd0c 100644
--- a/arch/arm/boards/freescale-mx23-evk/lowlevel.c
+++ b/arch/arm/boards/freescale-mx23-evk/lowlevel.c
@@ -9,12 +9,9 @@
 
 static noinline void continue_imx_entry(size_t size)
 {
-	static struct barebox_arm_boarddata boarddata = {
-		.magic = BAREBOX_ARM_BOARDDATA_MAGIC,
-		.machine = MACH_TYPE_MX23EVK,
-	};
+	handoff_add_arm_machine(MACH_TYPE_MX23EVK);
 
-	barebox_arm_entry(IMX_MEMORY_BASE, size, &boarddata);
+	barebox_arm_entry(IMX_MEMORY_BASE, size, NULL);
 }
 
 ENTRY_FUNCTION(start_imx23_evk, r0, r1, r2)
diff --git a/arch/arm/boards/imx233-olinuxino/lowlevel.c b/arch/arm/boards/imx233-olinuxino/lowlevel.c
index 91c1ba3dba..e4b6b1207f 100644
--- a/arch/arm/boards/imx233-olinuxino/lowlevel.c
+++ b/arch/arm/boards/imx233-olinuxino/lowlevel.c
@@ -13,12 +13,9 @@
 
 static noinline void continue_imx_entry(size_t size)
 {
-	static struct barebox_arm_boarddata boarddata = {
-		.magic = BAREBOX_ARM_BOARDDATA_MAGIC,
-		.machine = MACH_TYPE_IMX233_OLINUXINO,
-	};
+	handoff_add_arm_machine(MACH_TYPE_IMX233_OLINUXINO);
 
-	barebox_arm_entry(IMX_MEMORY_BASE, size, &boarddata);
+	barebox_arm_entry(IMX_MEMORY_BASE, size, NULL);
 }
 
 ENTRY_FUNCTION(start_barebox_olinuxino_imx23, r0, r1, r2)
diff --git a/arch/arm/boards/karo-tx28/lowlevel.c b/arch/arm/boards/karo-tx28/lowlevel.c
index 3be5f521e1..e423d5ecab 100644
--- a/arch/arm/boards/karo-tx28/lowlevel.c
+++ b/arch/arm/boards/karo-tx28/lowlevel.c
@@ -17,12 +17,9 @@
 
 static noinline void continue_imx_entry(size_t size)
 {
-	static struct barebox_arm_boarddata boarddata = {
-		.magic = BAREBOX_ARM_BOARDDATA_MAGIC,
-		.machine = MACH_TYPE_TX28,
-	};
+	handoff_add_arm_machine(MACH_TYPE_TX28);
 
-	barebox_arm_entry(IMX_MEMORY_BASE, size, &boarddata);
+	barebox_arm_entry(IMX_MEMORY_BASE, size, NULL);
 }
 
 ENTRY_FUNCTION(start_barebox_karo_tx28, r0, r1, r2)
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 4dbbbb56fa..3b38ad09fc 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -34,20 +34,18 @@ unsigned long arm_stack_top;
 static unsigned long arm_barebox_size;
 static unsigned long arm_endmem;
 static unsigned long arm_membase;
-static void *barebox_boarddata;
-static unsigned long barebox_boarddata_size;
 
-const struct barebox_boarddata *barebox_get_boarddata(void)
+u32 barebox_arm_machine(void)
 {
 	size_t size;
+	unsigned int *machine;
 
-	return handoff_data_get_entry(HANDOFF_DATA_BOARDDATA, &size);
-}
+	machine = handoff_data_get_entry(HANDOFF_DATA_ARM_MACHINE, &size);
 
-u32 barebox_arm_machine(void)
-{
-	const struct barebox_boarddata *bd = barebox_get_boarddata();
-	return bd ? bd->machine : 0;
+	if (machine)
+		return *machine;
+
+	return 0;
 }
 
 void *barebox_arm_boot_dtb(void)
@@ -119,10 +117,6 @@ EXPORT_SYMBOL_GPL(arm_mem_membase_get);
 
 static int barebox_memory_areas_init(void)
 {
-	if(barebox_boarddata)
-		request_barebox_region("board data", (unsigned long)barebox_boarddata,
-				     barebox_boarddata_size);
-
 	if (IS_ENABLED(CONFIG_KASAN))
 		request_sdram_region("kasan shadow", kasan_shadow_base,
 				     mem_malloc_start() - kasan_shadow_base);
diff --git a/arch/arm/cpu/uncompress.c b/arch/arm/cpu/uncompress.c
index af702d510e..daacd22866 100644
--- a/arch/arm/cpu/uncompress.c
+++ b/arch/arm/cpu/uncompress.c
@@ -43,9 +43,6 @@ static void add_handoff_data(void *boarddata)
 
 		handoff_data_add(HANDOFF_DATA_INTERNAL_DT_Z, boarddata,
 				 bd->datalen + sizeof(*bd));
-	} else if (blob_is_arm_boarddata(boarddata)) {
-		handoff_data_add(HANDOFF_DATA_BOARDDATA, boarddata,
-				 sizeof(struct barebox_arm_boarddata));
 	}
 }
 
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index e9afd8f453..566986e515 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -24,21 +24,19 @@
 #include <asm/sections.h>
 #include <asm/reloc.h>
 #include <linux/stringify.h>
-#include <boarddata.h>
+#include <pbl/handoff-data.h>
 
 #define ARM_EARLY_PAGETABLE_SIZE	SZ_64K
 
-void __noreturn barebox_arm_entry(unsigned long membase, unsigned long memsize, void *boarddata);
-
-#define barebox_arm_boarddata		barebox_boarddata
-#define BAREBOX_ARM_BOARDDATA_MAGIC	BAREBOX_BOARDDATA_MAGIC
-
-static inline bool blob_is_arm_boarddata(const void *blob)
-{
-	const struct barebox_arm_boarddata *bd = blob;
+#define handoff_add_arm_machine(machine)				\
+	do {								\
+		static unsigned int machine_number = machine;		\
+									\
+		handoff_data_add(HANDOFF_DATA_ARM_MACHINE,		\
+			&machine_number, sizeof(unsigned int));		\
+	} while (0);
 
-	return bd->magic == BAREBOX_ARM_BOARDDATA_MAGIC;
-}
+void __noreturn barebox_arm_entry(unsigned long membase, unsigned long memsize, void *boarddata);
 
 u32 barebox_arm_machine(void);
 
@@ -46,10 +44,6 @@ unsigned long arm_mem_ramoops_get(void);
 unsigned long arm_mem_membase_get(void);
 unsigned long arm_mem_endmem_get(void);
 
-struct barebox_arm_boarddata *barebox_arm_get_boarddata(void);
-
-#define barebox_arm_get_boarddata barebox_get_boarddata
-
 #ifdef CONFIG_ARM_EXCEPTIONS
 void arm_fixup_vectors(void);
 #else
diff --git a/include/boarddata.h b/include/boarddata.h
deleted file mode 100644
index 6092d5f304..0000000000
--- a/include/boarddata.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-
-#ifndef _BAREBOX_BOARDDATA_H_
-#define _BAREBOX_BOARDDATA_H_
-
-#include <linux/types.h>
-
-struct barebox_boarddata {
-#define BAREBOX_BOARDDATA_MAGIC		0xabe742c3
-	u32 magic;
-#define BAREBOX_MACH_TYPE_EFI		0xef1bbef1
-	u32 machine; /* machine number to pass to barebox. This may or may
-		      * not be a ARM machine number registered on arm.linux.org.uk.
-		      * It must only be unique across barebox. Please use a number
-		      * that do not potientially clashes with registered machines,
-		      * i.e. use a number > 0x10000.
-		      */
-};
-
-/*
- * Create a boarddata struct at given address. Suitable to be passed
- * as boarddata to barebox_$ARCH_entry(). The boarddata can be retrieved
- * later with barebox_get_boarddata().
- */
-static inline struct barebox_boarddata *boarddata_create(void *adr, u32 machine)
-{
-	struct barebox_boarddata *bd = adr;
-
-	bd->magic = BAREBOX_BOARDDATA_MAGIC;
-	bd->machine = machine;
-
-	return bd;
-}
-
-const struct barebox_boarddata *barebox_get_boarddata(void);
-
-static inline bool barebox_boarddata_is_machine(const struct barebox_boarddata *bd,
-						u32 machine)
-{
-	if (!bd || bd->magic != BAREBOX_BOARDDATA_MAGIC)
-		return false;
-	return bd->machine == machine;
-}
-
-#endif	/* _BAREBOX_BOARDDATA_H_ */
diff --git a/include/pbl/handoff-data.h b/include/pbl/handoff-data.h
index 044b4bb884..d475bdd694 100644
--- a/include/pbl/handoff-data.h
+++ b/include/pbl/handoff-data.h
@@ -11,7 +11,7 @@ struct handoff_data {
 #define HANDOFF_DATA_INTERNAL_DT	HANDOFF_DATA_BAREBOX(0)
 #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_ARM_MACHINE	HANDOFF_DATA_BAREBOX(3)
 #define HANDOFF_DATA_EFI		HANDOFF_DATA_BAREBOX(4)
 
 #define HANDOFF_DATA_BOARD(n)		(0x951726fb + (n))
diff --git a/pbl/handoff-data.c b/pbl/handoff-data.c
index 85c3985995..7453c9c82c 100644
--- a/pbl/handoff-data.c
+++ b/pbl/handoff-data.c
@@ -171,8 +171,8 @@ static const char *handoff_data_entry_name(struct handoff_data_entry *hde)
 		return "handoff FDT (internal, compressed)";
 	case HANDOFF_DATA_EXTERNAL_DT:
 		return "handoff FDT (external)";
-	case HANDOFF_DATA_BOARDDATA:
-		return "handoff boarddata";
+	case HANDOFF_DATA_ARM_MACHINE:
+		return "ARM machine number";
 	default:
 		sprintf(name, "handoff %08x", hde->cookie);
 		return name;
-- 
2.39.2




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/4] efi-payload: use handoff data to pass data to barebox proper
  2024-05-21 10:49 ` [PATCH 2/4] efi-payload: use handoff data to pass data to barebox proper Sascha Hauer
@ 2024-05-21 12:39   ` Ahmad Fatoum
  0 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2024-05-21 12:39 UTC (permalink / raw)
  To: Sascha Hauer, Barebox List

On 21.05.24 12:49, Sascha Hauer wrote:
> 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>

Tested-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

Tested with barebox as EFI payload compiled for arm64 with both
Tianocore and barebox as EFI loader.

> ---
>  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))
>  

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] make more use of handoff data
  2024-05-21 10:49 [PATCH 0/4] make more use of handoff data Sascha Hauer
                   ` (3 preceding siblings ...)
  2024-05-21 10:49 ` [PATCH 4/4] ARM: replace boarddata with handoff data Sascha Hauer
@ 2024-05-22  5:42 ` Sascha Hauer
  4 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2024-05-22  5:42 UTC (permalink / raw)
  To: Barebox List, Sascha Hauer


On Tue, 21 May 2024 12:49:09 +0200, Sascha Hauer wrote:
> struct boarddata is a mechanism to pass a ARM machine number from PBL to
> barebox proper. The EFI payload also uses it to pass some custom
> pointers to barebox proper. handoff data was created for exactly this
> purpose, so retire boarddata and use handoff data instead.
> 
> @afa, the efi patch is compile tested only. Could you give it a try?
> 
> [...]

Applied, thanks!

[1/4] handoff-data: put handoff data into data section
      https://git.pengutronix.de/cgit/barebox/commit/?id=bd7ecdd33ea7 (link may not be stable)
[2/4] efi-payload: use handoff data to pass data to barebox proper
      https://git.pengutronix.de/cgit/barebox/commit/?id=26b93791e9d3 (link may not be stable)
[3/4] ARM: beagle: setup C environment early
      https://git.pengutronix.de/cgit/barebox/commit/?id=439d2f864760 (link may not be stable)
[4/4] ARM: replace boarddata with handoff data
      https://git.pengutronix.de/cgit/barebox/commit/?id=602aaa68a66d (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-05-22  5:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/4] efi-payload: use handoff data to pass data to barebox proper Sascha Hauer
2024-05-21 12:39   ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox