Commit 204b0a1a authored by Matt Fleming's avatar Matt Fleming Committed by H. Peter Anvin

x86, efi: Abstract x86 efi_early calls

The ARM EFI boot stub doesn't need to care about the efi_early
infrastructure that x86 requires in order to do mixed mode thunking. So
wrap everything up in an efi_call_early() macro.

This allows x86 to do the necessary indirection jumps to call whatever
firmware interface is necessary (native or mixed mode), but also allows
the ARM folks to mask the fact that they don't support relocation in the
boot stub and need to pass 'sys_table_arg' to every function.

[ hpa: there are no object code changes from this patch ]
Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
Link: http://lkml.kernel.org/r/20140326091011.GB2958@console-pimps.org
Cc: Roy Franz <roy.franz@linaro.org>
Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 9a11040f
This diff is collapsed.
...@@ -53,22 +53,22 @@ static efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, ...@@ -53,22 +53,22 @@ static efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
* allocation which may be in a new descriptor region. * allocation which may be in a new descriptor region.
*/ */
*map_size += sizeof(*m); *map_size += sizeof(*m);
status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA, status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
*map_size, (void **)&m); *map_size, (void **)&m);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto fail; goto fail;
*desc_size = 0; *desc_size = 0;
key = 0; key = 0;
status = efi_early->call(efi_early->get_memory_map, map_size, m, status = efi_call_early(get_memory_map, map_size, m,
&key, desc_size, &desc_version); &key, desc_size, &desc_version);
if (status == EFI_BUFFER_TOO_SMALL) { if (status == EFI_BUFFER_TOO_SMALL) {
efi_early->call(efi_early->free_pool, m); efi_call_early(free_pool, m);
goto again; goto again;
} }
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
efi_early->call(efi_early->free_pool, m); efi_call_early(free_pool, m);
if (key_ptr && status == EFI_SUCCESS) if (key_ptr && status == EFI_SUCCESS)
*key_ptr = key; *key_ptr = key;
...@@ -149,7 +149,7 @@ static efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg, ...@@ -149,7 +149,7 @@ static efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg,
if (!max_addr) if (!max_addr)
status = EFI_NOT_FOUND; status = EFI_NOT_FOUND;
else { else {
status = efi_early->call(efi_early->allocate_pages, status = efi_call_early(allocate_pages,
EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA,
nr_pages, &max_addr); nr_pages, &max_addr);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
...@@ -161,7 +161,7 @@ static efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg, ...@@ -161,7 +161,7 @@ static efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg,
*addr = max_addr; *addr = max_addr;
} }
efi_early->call(efi_early->free_pool, map); efi_call_early(free_pool, map);
fail: fail:
return status; return status;
} }
...@@ -221,7 +221,7 @@ static efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, ...@@ -221,7 +221,7 @@ static efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg,
if ((start + size) > end) if ((start + size) > end)
continue; continue;
status = efi_early->call(efi_early->allocate_pages, status = efi_call_early(allocate_pages,
EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA,
nr_pages, &start); nr_pages, &start);
if (status == EFI_SUCCESS) { if (status == EFI_SUCCESS) {
...@@ -233,7 +233,7 @@ static efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, ...@@ -233,7 +233,7 @@ static efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg,
if (i == map_size / desc_size) if (i == map_size / desc_size)
status = EFI_NOT_FOUND; status = EFI_NOT_FOUND;
efi_early->call(efi_early->free_pool, map); efi_call_early(free_pool, map);
fail: fail:
return status; return status;
} }
...@@ -247,7 +247,7 @@ static void efi_free(efi_system_table_t *sys_table_arg, unsigned long size, ...@@ -247,7 +247,7 @@ static void efi_free(efi_system_table_t *sys_table_arg, unsigned long size,
return; return;
nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE;
efi_early->call(efi_early->free_pages, addr, nr_pages); efi_call_early(free_pages, addr, nr_pages);
} }
...@@ -307,7 +307,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, ...@@ -307,7 +307,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
if (!nr_files) if (!nr_files)
return EFI_SUCCESS; return EFI_SUCCESS;
status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA, status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
nr_files * sizeof(*files), (void **)&files); nr_files * sizeof(*files), (void **)&files);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_printk(sys_table_arg, "Failed to alloc mem for file handle list\n"); efi_printk(sys_table_arg, "Failed to alloc mem for file handle list\n");
...@@ -413,7 +413,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, ...@@ -413,7 +413,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
} }
efi_early->call(efi_early->free_pool, files); efi_call_early(free_pool, files);
*load_addr = file_addr; *load_addr = file_addr;
*load_size = file_size_total; *load_size = file_size_total;
...@@ -427,7 +427,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, ...@@ -427,7 +427,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
for (k = j; k < i; k++) for (k = j; k < i; k++)
efi_file_close(fh, files[k].handle); efi_file_close(fh, files[k].handle);
free_files: free_files:
efi_early->call(efi_early->free_pool, files); efi_call_early(free_pool, files);
fail: fail:
*load_addr = 0; *load_addr = 0;
*load_size = 0; *load_size = 0;
...@@ -473,7 +473,7 @@ static efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg, ...@@ -473,7 +473,7 @@ static efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg,
* as possible while respecting the required alignment. * as possible while respecting the required alignment.
*/ */
nr_pages = round_up(alloc_size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; nr_pages = round_up(alloc_size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE;
status = efi_early->call(efi_early->allocate_pages, status = efi_call_early(allocate_pages,
EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA,
nr_pages, &efi_addr); nr_pages, &efi_addr);
new_addr = efi_addr; new_addr = efi_addr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment