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@xxxxxxxxxxxxxx> Tested-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> 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 |