Skip to content

Commit

Permalink
efi/arm: Move FDT specific definitions into fdtparams.c
Browse files Browse the repository at this point in the history
Push the FDT params specific types and definition into fdtparams.c,
and instead, pass a reference to the memory map data structure and
populate it directly, and return the system table address as the
return value.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
  • Loading branch information
Ard Biesheuvel committed Feb 23, 2020
1 parent ac5abc7 commit 3b2e4b4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
17 changes: 6 additions & 11 deletions drivers/firmware/efi/arm-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,13 @@ static __init void reserve_regions(void)
void __init efi_init(void)
{
struct efi_memory_map_data data;
struct efi_fdt_params params;
u64 efi_system_table;

/* Grab UEFI information placed in FDT by stub */
if (!efi_get_fdt_params(&params))
efi_system_table = efi_get_fdt_params(&data);
if (!efi_system_table)
return;

data.desc_version = params.desc_ver;
data.desc_size = params.desc_size;
data.size = params.mmap_size;
data.phys_map = params.mmap;

if (efi_memmap_init_early(&data) < 0) {
/*
* If we are booting via UEFI, the UEFI memory map is the only
Expand All @@ -229,17 +225,16 @@ void __init efi_init(void)
"Unexpected EFI_MEMORY_DESCRIPTOR version %ld",
efi.memmap.desc_version);

if (uefi_init(params.system_table) < 0) {
if (uefi_init(efi_system_table) < 0) {
efi_memmap_unmap();
return;
}

reserve_regions();
efi_esrt_init();

memblock_reserve(params.mmap & PAGE_MASK,
PAGE_ALIGN(params.mmap_size +
(params.mmap & ~PAGE_MASK)));
memblock_reserve(data.phys_map & PAGE_MASK,
PAGE_ALIGN(data.size + (data.phys_map & ~PAGE_MASK)));

init_screen_info();

Expand Down
30 changes: 23 additions & 7 deletions drivers/firmware/efi/fdtparams.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
sizeof_field(struct efi_fdt_params, field) \
}

struct efi_fdt_params {
u64 system_table;
u64 mmap;
u32 mmap_size;
u32 desc_size;
u32 desc_ver;
};

struct params {
const char name[32];
const char propname[32];
Expand Down Expand Up @@ -121,22 +129,30 @@ static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
return 0;
}

int __init efi_get_fdt_params(struct efi_fdt_params *params)
u64 __init efi_get_fdt_params(struct efi_memory_map_data *memmap)
{
struct efi_fdt_params params;
struct param_info info;
int ret;

pr_info("Getting EFI parameters from FDT:\n");

info.found = 0;
info.params = params;
info.params = &params;

ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
if (!info.found)
if (!info.found) {
pr_info("UEFI not found.\n");
else if (!ret)
pr_err("Can't find '%s' in device tree!\n",
info.missing);
return 0;
} else if (!ret) {
pr_err("Can't find '%s' in device tree!\n", info.missing);
return 0;
}

memmap->desc_version = params.desc_ver;
memmap->desc_size = params.desc_size;
memmap->size = params.mmap_size;
memmap->phys_map = params.mmap;

return ret;
return params.system_table;
}
10 changes: 1 addition & 9 deletions include/linux/efi.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,6 @@ struct efi_mem_range {
u64 attribute;
};

struct efi_fdt_params {
u64 system_table;
u64 mmap;
u32 mmap_size;
u32 desc_size;
u32 desc_ver;
};

typedef struct {
u32 version;
u32 length;
Expand Down Expand Up @@ -631,7 +623,7 @@ extern void efi_mem_reserve(phys_addr_t addr, u64 size);
extern int efi_mem_reserve_persistent(phys_addr_t addr, u64 size);
extern void efi_initialize_iomem_resources(struct resource *code_resource,
struct resource *data_resource, struct resource *bss_resource);
extern int efi_get_fdt_params(struct efi_fdt_params *params);
extern u64 efi_get_fdt_params(struct efi_memory_map_data *data);
extern struct kobject *efi_kobj;

extern int efi_reboot_quirk_mode;
Expand Down

0 comments on commit 3b2e4b4

Please sign in to comment.