Path: blob/master/drivers/firmware/efi/libstub/efi-stub-entry.c
26483 views
// SPDX-License-Identifier: GPL-2.0-only12#include <linux/efi.h>3#include <linux/screen_info.h>45#include <asm/efi.h>67#include "efistub.h"89static unsigned long screen_info_offset;1011struct screen_info *alloc_screen_info(void)12{13if (IS_ENABLED(CONFIG_ARM))14return __alloc_screen_info();1516if (IS_ENABLED(CONFIG_X86) ||17IS_ENABLED(CONFIG_EFI_EARLYCON) ||18IS_ENABLED(CONFIG_SYSFB))19return (void *)&screen_info + screen_info_offset;2021return NULL;22}2324/*25* EFI entry point for the generic EFI stub used by ARM, arm64, RISC-V and26* LoongArch. This is the entrypoint that is described in the PE/COFF header27* of the core kernel.28*/29efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,30efi_system_table_t *systab)31{32efi_loaded_image_t *image;33efi_status_t status;34unsigned long image_addr;35unsigned long image_size = 0;36/* addr/point and size pairs for memory management*/37char *cmdline_ptr = NULL;38efi_guid_t loaded_image_proto = LOADED_IMAGE_PROTOCOL_GUID;39unsigned long reserve_addr = 0;40unsigned long reserve_size = 0;4142WRITE_ONCE(efi_system_table, systab);4344/* Check if we were booted by the EFI firmware */45if (efi_system_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE)46return EFI_INVALID_PARAMETER;4748/*49* Get a handle to the loaded image protocol. This is used to get50* information about the running image, such as size and the command51* line.52*/53status = efi_bs_call(handle_protocol, handle, &loaded_image_proto,54(void *)&image);55if (status != EFI_SUCCESS) {56efi_err("Failed to get loaded image protocol\n");57return status;58}5960status = efi_handle_cmdline(image, &cmdline_ptr);61if (status != EFI_SUCCESS)62return status;6364efi_info("Booting Linux Kernel...\n");6566status = handle_kernel_image(&image_addr, &image_size,67&reserve_addr,68&reserve_size,69image, handle);70if (status != EFI_SUCCESS) {71efi_err("Failed to relocate kernel\n");72return status;73}7475screen_info_offset = image_addr - (unsigned long)image->image_base;7677status = efi_stub_common(handle, image, image_addr, cmdline_ptr);7879efi_free(image_size, image_addr);80efi_free(reserve_size, reserve_addr);8182return status;83}848586