1 // SPDX-License-Identifier: GPL-2.0-only
4 #include <linux/screen_info.h>
10 static unsigned long screen_info_offset;
12 struct screen_info *alloc_screen_info(void)
14 if (IS_ENABLED(CONFIG_ARM))
15 return __alloc_screen_info();
16 return (void *)&screen_info + screen_info_offset;
20 * EFI entry point for the generic EFI stub used by ARM, arm64, RISC-V and
21 * LoongArch. This is the entrypoint that is described in the PE/COFF header
24 efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
25 efi_system_table_t *systab)
27 efi_loaded_image_t *image;
29 unsigned long image_addr;
30 unsigned long image_size = 0;
31 /* addr/point and size pairs for memory management*/
32 char *cmdline_ptr = NULL;
33 efi_guid_t loaded_image_proto = LOADED_IMAGE_PROTOCOL_GUID;
34 unsigned long reserve_addr = 0;
35 unsigned long reserve_size = 0;
37 WRITE_ONCE(efi_system_table, systab);
39 /* Check if we were booted by the EFI firmware */
40 if (efi_system_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE)
41 return EFI_INVALID_PARAMETER;
44 * Get a handle to the loaded image protocol. This is used to get
45 * information about the running image, such as size and the command
48 status = efi_bs_call(handle_protocol, handle, &loaded_image_proto,
50 if (status != EFI_SUCCESS) {
51 efi_err("Failed to get loaded image protocol\n");
55 status = efi_handle_cmdline(image, &cmdline_ptr);
56 if (status != EFI_SUCCESS)
59 efi_info("Booting Linux Kernel...\n");
61 status = handle_kernel_image(&image_addr, &image_size,
65 if (status != EFI_SUCCESS) {
66 efi_err("Failed to relocate kernel\n");
70 screen_info_offset = image_addr - (unsigned long)image->image_base;
72 status = efi_stub_common(handle, image, image_addr, cmdline_ptr);
74 efi_free(image_size, image_addr);
75 efi_free(reserve_size, reserve_addr);