[PATCH 08/15] efi: return pointer from efi_earlymem_alloc
Ahmad Fatoum
a.fatoum at barebox.org
Tue May 27 14:22:53 PDT 2025
Returning a pointer for a memory allocation function makes more sense.
Signed-off-by: Ahmad Fatoum <ahmad at a3f.at>
---
efi/payload/early-mem.c | 6 +++---
efi/payload/entry-multi.c | 4 ++--
efi/payload/entry-single.c | 4 ++--
include/efi/efi-payload.h | 3 +--
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/efi/payload/early-mem.c b/efi/payload/early-mem.c
index 52052f7ed128..6229fd43a587 100644
--- a/efi/payload/early-mem.c
+++ b/efi/payload/early-mem.c
@@ -5,8 +5,8 @@
#include <efi.h>
#include <efi/efi-payload.h>
-efi_physical_addr_t efi_earlymem_alloc(const struct efi_system_table *sys_table,
- size_t *memsize)
+void *efi_earlymem_alloc(const struct efi_system_table *sys_table,
+ size_t *memsize)
{
struct efi_boot_services *bs = sys_table->boottime;
enum efi_allocate_type alloc_type = EFI_ALLOCATE_ANY_PAGES;
@@ -29,5 +29,5 @@ efi_physical_addr_t efi_earlymem_alloc(const struct efi_system_table *sys_table,
panic("failed to allocate %zu byte memory pool: 0x%lx\n",
*memsize, efiret);
- return mem;
+ return efi_phys_to_virt(mem);
}
diff --git a/efi/payload/entry-multi.c b/efi/payload/entry-multi.c
index 26cf2ebfa764..2eb9dccc08a0 100644
--- a/efi/payload/entry-multi.c
+++ b/efi/payload/entry-multi.c
@@ -24,7 +24,7 @@ static void efi_putc(void *ctx, int ch)
void __efistub_efi_pe_entry(void *image, struct efi_system_table *sys_table)
{
size_t memsize;
- efi_physical_addr_t mem;
+ void *mem;
static struct barebox_efi_data efidata;
#ifdef DEBUG
@@ -39,5 +39,5 @@ void __efistub_efi_pe_entry(void *image, struct efi_system_table *sys_table)
mem = efi_earlymem_alloc(sys_table, &memsize);
- barebox_pbl_entry(mem, memsize, NULL);
+ barebox_pbl_entry((uintptr_t)mem, memsize, NULL);
}
diff --git a/efi/payload/entry-single.c b/efi/payload/entry-single.c
index cb7981e03060..c95672b9fe66 100644
--- a/efi/payload/entry-single.c
+++ b/efi/payload/entry-single.c
@@ -18,7 +18,7 @@ void efi_main(efi_handle_t image, struct efi_system_table *sys_table)
{
efi_status_t efiret;
size_t memsize;
- efi_physical_addr_t mem;
+ void *mem;
#ifdef DEBUG
sys_table->con_out->output_string(sys_table->con_out, L"barebox\n");
@@ -39,7 +39,7 @@ void efi_main(efi_handle_t image, struct efi_system_table *sys_table)
mem = efi_earlymem_alloc(sys_table, &memsize);
- mem_malloc_init((void *)mem, (void *)mem + memsize - 1);
+ mem_malloc_init(mem, mem + memsize - 1);
start_barebox();
}
diff --git a/include/efi/efi-payload.h b/include/efi/efi-payload.h
index 73b1b9bd8e74..313ba7f4abc2 100644
--- a/include/efi/efi-payload.h
+++ b/include/efi/efi-payload.h
@@ -30,7 +30,6 @@ int efi_set_variable(char *name, efi_guid_t *vendor, uint32_t attributes,
void *buf, unsigned long size);
int efi_set_variable_usec(char *name, efi_guid_t *vendor, uint64_t usec);
-efi_physical_addr_t efi_earlymem_alloc(const struct efi_system_table *sys_table,
- size_t *memsize);
+void *efi_earlymem_alloc(const struct efi_system_table *sys_table, size_t *memsize);
#endif
--
2.39.5
More information about the barebox
mailing list