1 // SPDX-License-Identifier: GPL-2.0-only
8 static unsigned long screen_info_offset;
10 struct screen_info *alloc_screen_info(void)
12 if (IS_ENABLED(CONFIG_ARM))
13 return __alloc_screen_info();
14 return (void *)&screen_info + screen_info_offset;
18 * EFI entry point for the generic EFI stub used by ARM, arm64, RISC-V and
19 * LoongArch. This is the entrypoint that is described in the PE/COFF header
22 efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
23 efi_system_table_t *systab)
25 efi_loaded_image_t *image;
27 unsigned long image_addr;
28 unsigned long image_size = 0;
29 /* addr/point and size pairs for memory management*/
30 char *cmdline_ptr = NULL;
31 efi_guid_t loaded_image_proto = LOADED_IMAGE_PROTOCOL_GUID;
32 unsigned long reserve_addr = 0;
33 unsigned long reserve_size = 0;
35 WRITE_ONCE(efi_system_table, systab);
37 /* Check if we were booted by the EFI firmware */
38 if (efi_system_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE)
39 return EFI_INVALID_PARAMETER;
42 * Get a handle to the loaded image protocol. This is used to get
43 * information about the running image, such as size and the command
46 status = efi_bs_call(handle_protocol, handle, &loaded_image_proto,
48 if (status != EFI_SUCCESS) {
49 efi_err("Failed to get loaded image protocol\n");
53 status = efi_handle_cmdline(image, &cmdline_ptr);
54 if (status != EFI_SUCCESS)
57 efi_info("Booting Linux Kernel...\n");
59 status = handle_kernel_image(&image_addr, &image_size,
63 if (status != EFI_SUCCESS) {
64 efi_err("Failed to relocate kernel\n");
68 screen_info_offset = image_addr - (unsigned long)image->image_base;
70 status = efi_stub_common(handle, image, image_addr, cmdline_ptr);
72 efi_free(image_size, image_addr);
73 efi_free(reserve_size, reserve_addr);