summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2015-07-17 21:22:36 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-07-23 16:46:14 +0200
commit356aaef5a37d60f060082f400617f9dcf514a9d5 (patch)
tree4cafc5085aa6a5d37166f9801f4aa18715d17d93
parent17e60440747c3363157a08560eb725f91f08ce4a (diff)
downloadbarebox-356aaef5a37d60f060082f400617f9dcf514a9d5.tar.gz
barebox-356aaef5a37d60f060082f400617f9dcf514a9d5.tar.xz
efi: improve malloc pool allocation
Use allocate_pages() instead of allocate_pool(). With allocate_pages() we can specify the address. This way, any address passed to the kernel will never exceed the lower 32 bit. If possible, try to allocate a larger pool. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/efi/efi/efi.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/arch/efi/efi/efi.c b/arch/efi/efi/efi.c
index d351775a28..c05d183c02 100644
--- a/arch/efi/efi/efi.c
+++ b/arch/efi/efi/efi.c
@@ -310,7 +310,8 @@ device_initcall(efi_init);
*/
efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table)
{
- void *mem;
+ efi_physical_addr_t mem;
+ size_t memsize;
efi_status_t efiret;
#ifdef DEBUG
@@ -332,8 +333,21 @@ efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table)
fixup_tables();
- BS->allocate_pool(efi_loaded_image->image_data_type, SZ_16M, &mem);
- mem_malloc_init(mem, mem + SZ_16M);
+ mem = 0x3fffffff;
+ for (memsize = SZ_256M; memsize >= SZ_8M; memsize /= 2) {
+ efiret = BS->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
+ EFI_LOADER_DATA,
+ memsize/PAGE_SIZE, &mem);
+ if (!EFI_ERROR(efiret))
+ break;
+ if (efiret != EFI_OUT_OF_RESOURCES)
+ panic("failed to allocate malloc pool: %s\n",
+ efi_strerror(efiret));
+ }
+ if (EFI_ERROR(efiret))
+ panic("failed to allocate malloc pool: %s\n",
+ efi_strerror(efiret));
+ mem_malloc_init((void *)mem, (void *)mem + memsize);
efi_clocksource_init();