1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2013, 2014 Linaro Ltd; <roy.franz@linaro.org>
5 * This file implements the EFI boot stub for the arm64 kernel.
6 * Adapted from ARM version by Mark Salter <msalter@redhat.com>
10 #include <linux/efi.h>
12 #include <asm/memory.h>
13 #include <asm/sections.h>
17 efi_status_t handle_kernel_image(unsigned long *image_addr,
18 unsigned long *image_size,
19 unsigned long *reserve_addr,
20 unsigned long *reserve_size,
21 efi_loaded_image_t *image,
22 efi_handle_t image_handle)
25 unsigned long kernel_size, kernel_codesize, kernel_memsize;
27 if (image->image_base != _text) {
28 efi_err("FIRMWARE BUG: efi_loaded_image_t::image_base has bogus value\n");
29 image->image_base = _text;
32 if (!IS_ALIGNED((u64)_text, SEGMENT_ALIGN))
33 efi_err("FIRMWARE BUG: kernel image not aligned on %dk boundary\n",
36 kernel_size = _edata - _text;
37 kernel_codesize = __inittext_end - _text;
38 kernel_memsize = kernel_size + (_end - _edata);
39 *reserve_size = kernel_memsize;
40 *image_addr = (unsigned long)_text;
42 status = efi_kaslr_relocate_kernel(image_addr,
43 reserve_addr, reserve_size,
44 kernel_size, kernel_codesize,
46 efi_kaslr_get_phys_seed(image_handle));
47 if (status != EFI_SUCCESS)
53 asmlinkage void primary_entry(void);
55 unsigned long primary_entry_offset(void)
58 * When built as part of the kernel, the EFI stub cannot branch to the
59 * kernel proper via the image header, as the PE/COFF header is
60 * strictly not part of the in-memory presentation of the image, only
61 * of the file representation. So instead, we need to jump to the
62 * actual entrypoint in the .text region of the image.
64 return (char *)primary_entry - _text;
67 void efi_icache_sync(unsigned long start, unsigned long end)
69 caches_clean_inval_pou(start, end);