#ifndef _ASM_EFI_H
#define _ASM_EFI_H
+#include <asm/boot.h>
#include <asm/io.h>
#include <asm/neon.h>
/* arch specific definitions used by the stub code */
-/*
- * AArch64 requires the DTB to be 8-byte aligned in the first 512MiB from
- * start of kernel and may not cross a 2MiB boundary. We set alignment to
- * 2MiB so we know it won't cross a 2MiB boundary.
- */
-#define EFI_FDT_ALIGN SZ_2M /* used by allocate_new_fdt_and_exit_boot() */
-#define MAX_FDT_OFFSET SZ_512M
+#define EFI_FDT_ALIGN MIN_FDT_ALIGN
+#define EFI_FDT_MAX_SIZE MAX_FDT_SIZE
#define efi_call_early(f, ...) sys_table_arg->boottime->f(__VA_ARGS__)
new_fdt_addr = fdt_addr;
status = allocate_new_fdt_and_exit_boot(sys_table, handle,
- &new_fdt_addr, dram_base + MAX_FDT_OFFSET,
- initrd_addr, initrd_size, cmdline_ptr,
- fdt_addr, fdt_size);
+ &new_fdt_addr, initrd_addr, initrd_size,
+ cmdline_ptr, fdt_addr, fdt_size);
/*
* If all went well, we need to return the FDT address to the
return EFI_LOAD_ERROR;
}
-#ifndef EFI_FDT_ALIGN
-#define EFI_FDT_ALIGN EFI_PAGE_SIZE
-#endif
-
/*
* Allocate memory for a new FDT, then add EFI, commandline, and
* initrd related fields to the FDT. This routine increases the
efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
void *handle,
unsigned long *new_fdt_addr,
- unsigned long max_addr,
u64 initrd_addr, u64 initrd_size,
char *cmdline_ptr,
unsigned long fdt_addr,
*/
new_fdt_size = fdt_size + EFI_PAGE_SIZE;
while (1) {
- status = efi_high_alloc(sys_table, new_fdt_size, EFI_FDT_ALIGN,
- new_fdt_addr, max_addr);
+ if (new_fdt_size > EFI_FDT_MAX_SIZE) {
+ pr_efi_err(sys_table, "FDT size exceeds EFI_FDT_MAX_SIZE.\n");
+ goto fail;
+ }
+ status = sys_table->boottime->allocate_pool(EFI_LOADER_DATA,
+ new_fdt_size,
+ (void **)new_fdt_addr);
if (status != EFI_SUCCESS) {
pr_efi_err(sys_table, "Unable to allocate memory for new device tree.\n");
goto fail;
* to get new one that reflects the free/alloc we do
* on the device tree buffer.
*/
- efi_free(sys_table, new_fdt_size, *new_fdt_addr);
+ sys_table->boottime->free_pool((void *)*new_fdt_addr);
sys_table->boottime->free_pool(memory_map);
new_fdt_size += EFI_PAGE_SIZE;
} else {
sys_table->boottime->free_pool(memory_map);
fail_free_new_fdt:
- efi_free(sys_table, new_fdt_size, *new_fdt_addr);
+ sys_table->boottime->free_pool((void *)*new_fdt_addr);
fail:
sys_table->boottime->free_pool(runtime_map);