// SPDX-License-Identifier: GPL-2.0 /* * Helper functions used by the EFI stub on multiple * architectures. This should be #included by the EFI stub * implementation files. * * Copyright 2011 Intel Corporation; author Matt Fleming */ #include <linux/efi.h> #include <asm/efi.h> #include "efistub.h" #define MAX_FILENAME_SIZE … /* * Some firmware implementations have problems reading files in one go. * A read chunk size of 1MB seems to work for most platforms. * * Unfortunately, reading files in chunks triggers *other* bugs on some * platforms, so we provide a way to disable this workaround, which can * be done by passing "efi=nochunk" on the EFI boot stub command line. * * If you experience issues with initrd images being corrupt it's worth * trying efi=nochunk, but chunking is enabled by default on x86 because * there are far more machines that require the workaround than those that * break with it enabled. */ #define EFI_READ_CHUNK_SIZE … struct finfo { … }; static efi_status_t efi_open_file(efi_file_protocol_t *volume, struct finfo *fi, efi_file_protocol_t **handle, unsigned long *file_size) { … } static efi_status_t efi_open_volume(efi_loaded_image_t *image, efi_file_protocol_t **fh) { … } static int find_file_option(const efi_char16_t *cmdline, int cmdline_len, const efi_char16_t *prefix, int prefix_size, efi_char16_t *result, int result_len) { … } static efi_status_t efi_open_device_path(efi_file_protocol_t **volume, struct finfo *fi) { … } /* * Check the cmdline for a LILO-style file= arguments. * * We only support loading a file from the same filesystem as * the kernel image. */ efi_status_t handle_cmdline_files(efi_loaded_image_t *image, const efi_char16_t *optstr, int optstr_size, unsigned long soft_limit, unsigned long hard_limit, unsigned long *load_addr, unsigned long *load_size) { … }