aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Franz <roy.franz@linaro.org>2013-09-22 15:45:31 -0700
committerMark Brown <broonie@linaro.org>2014-06-16 21:17:18 +0100
commit88d149977c231a35d58dccad3b8763b76afa97a9 (patch)
treeb97d420a34007a45b64937be4dbb3ef1b4b1c73f
parentf9eb094b899e81b23c617c513f2638f359155a5d (diff)
efi: Move relocate_kernel() to shared file.
The relocate_kernel() function will be generalized and used by all architectures, as they all have similar requirements. Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit c6866d7238d4f26055de8db9c1d5a700e554b2d4) Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--arch/x86/boot/compressed/eboot.c34
-rw-r--r--drivers/firmware/efi/efi-stub-helper.c35
2 files changed, 35 insertions, 34 deletions
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index 137a0b7a59cf..91a142b9574f 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -1103,40 +1103,6 @@ free_mem_map:
return status;
}
-static efi_status_t relocate_kernel(struct setup_header *hdr)
-{
- unsigned long start, nr_pages;
- efi_status_t status;
-
- /*
- * The EFI firmware loader could have placed the kernel image
- * anywhere in memory, but the kernel has various restrictions
- * on the max physical address it can run at. Attempt to move
- * the kernel to boot_params.pref_address, or as low as
- * possible.
- */
- start = hdr->pref_address;
- nr_pages = round_up(hdr->init_size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE;
-
- status = efi_call_phys4(sys_table->boottime->allocate_pages,
- EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA,
- nr_pages, &start);
- if (status != EFI_SUCCESS) {
- status = efi_low_alloc(sys_table, hdr->init_size,
- hdr->kernel_alignment, &start);
- if (status != EFI_SUCCESS)
- efi_printk(sys_table, "Failed to alloc mem for kernel\n");
- }
-
- if (status == EFI_SUCCESS)
- memcpy((void *)start, (void *)(unsigned long)hdr->code32_start,
- hdr->init_size);
-
- hdr->pref_address = hdr->code32_start;
- hdr->code32_start = (__u32)start;
-
- return status;
-}
/*
* On success we return a pointer to a boot_params structure, and NULL
diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c
index a25675833598..333ed9c37751 100644
--- a/drivers/firmware/efi/efi-stub-helper.c
+++ b/drivers/firmware/efi/efi-stub-helper.c
@@ -485,3 +485,38 @@ fail:
return status;
}
+
+static efi_status_t relocate_kernel(struct setup_header *hdr)
+{
+ unsigned long start, nr_pages;
+ efi_status_t status;
+
+ /*
+ * The EFI firmware loader could have placed the kernel image
+ * anywhere in memory, but the kernel has various restrictions
+ * on the max physical address it can run at. Attempt to move
+ * the kernel to boot_params.pref_address, or as low as
+ * possible.
+ */
+ start = hdr->pref_address;
+ nr_pages = round_up(hdr->init_size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE;
+
+ status = efi_call_phys4(sys_table->boottime->allocate_pages,
+ EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA,
+ nr_pages, &start);
+ if (status != EFI_SUCCESS) {
+ status = efi_low_alloc(sys_table, hdr->init_size,
+ hdr->kernel_alignment, &start);
+ if (status != EFI_SUCCESS)
+ efi_printk(sys_table, "Failed to alloc mem for kernel\n");
+ }
+
+ if (status == EFI_SUCCESS)
+ memcpy((void *)start, (void *)(unsigned long)hdr->code32_start,
+ hdr->init_size);
+
+ hdr->pref_address = hdr->code32_start;
+ hdr->code32_start = (__u32)start;
+
+ return status;
+}