Path: blob/master/drivers/firmware/efi/libstub/riscv-stub.c
26483 views
// SPDX-License-Identifier: GPL-2.01/*2* Copyright (C) 2020 Western Digital Corporation or its affiliates.3*/45#include <linux/efi.h>67#include <asm/efi.h>8#include <asm/sections.h>9#include <linux/unaligned.h>1011#include "efistub.h"1213unsigned long stext_offset(void)14{15/*16* When built as part of the kernel, the EFI stub cannot branch to the17* kernel proper via the image header, as the PE/COFF header is18* strictly not part of the in-memory presentation of the image, only19* of the file representation. So instead, we need to jump to the20* actual entrypoint in the .text region of the image.21*/22return _start_kernel - _start;23}2425efi_status_t handle_kernel_image(unsigned long *image_addr,26unsigned long *image_size,27unsigned long *reserve_addr,28unsigned long *reserve_size,29efi_loaded_image_t *image,30efi_handle_t image_handle)31{32unsigned long kernel_size, kernel_codesize, kernel_memsize;33efi_status_t status;3435kernel_size = _edata - _start;36kernel_codesize = __init_text_end - _start;37kernel_memsize = kernel_size + (_end - _edata);38*image_addr = (unsigned long)_start;39*image_size = kernel_memsize;40*reserve_size = *image_size;4142status = efi_kaslr_relocate_kernel(image_addr,43reserve_addr, reserve_size,44kernel_size, kernel_codesize, kernel_memsize,45efi_kaslr_get_phys_seed(image_handle));46if (status != EFI_SUCCESS) {47efi_err("Failed to relocate kernel\n");48*image_size = 0;49}5051return status;52}5354void efi_icache_sync(unsigned long start, unsigned long end)55{56asm volatile ("fence.i" ::: "memory");57}585960