coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
fit_payload.c File Reference
#include <commonlib/bsd/compression.h>
#include <console/console.h>
#include <bootmem.h>
#include <program_loading.h>
#include <string.h>
#include <lib.h>
#include <fit.h>
#include <endian.h>
Include dependency graph for fit_payload.c:

Go to the source code of this file.

Data Structures

struct  arm64_kernel_header
 

Macros

#define MAX_KERNEL_SIZE   (64*MiB)
 
#define KERNEL_HEADER_MAGIC   0x644d5241
 
#define SCRATCH_CANARY_VALUE   0xdeadbeef
 

Functions

static bool decompress_kernel_header (const struct fit_image_node *node)
 
static size_t get_kernel_size (const struct fit_image_node *node)
 
static bool fit_place_kernel (const struct range_entry *r, void *arg)
 
static bool fit_place_mem (const struct range_entry *r, void *arg)
 Place the region in free memory range. More...
 
bool fit_payload_arch (struct prog *payload, struct fit_config_node *config, struct region *kernel, struct region *fdt, struct region *initrd)
 

Variables

struct {
   union {
      struct arm64_kernel_header   header
 
      u8   raw [sizeof(struct
         arm64_kernel_header)+0x100]
 
   } 
 
   u32   canary
 
scratch
 

Macro Definition Documentation

◆ KERNEL_HEADER_MAGIC

#define KERNEL_HEADER_MAGIC   0x644d5241

Definition at line 24 of file fit_payload.c.

◆ MAX_KERNEL_SIZE

#define MAX_KERNEL_SIZE   (64*MiB)

Definition at line 12 of file fit_payload.c.

◆ SCRATCH_CANARY_VALUE

#define SCRATCH_CANARY_VALUE   0xdeadbeef

Definition at line 33 of file fit_payload.c.

Function Documentation

◆ decompress_kernel_header()

static bool decompress_kernel_header ( const struct fit_image_node node)
static

Prior to v3.17, the endianness of text_offset was not specified. In these cases image_size is zero and text_offset is 0x80000 in the endianness of the kernel. Where image_size is non-zero image_size is little-endian and must be respected. Where image_size is zero, text_offset can be assumed to be 0x80000.

Definition at line 38 of file fit_payload.c.

References BIOS_ERR, CBFS_COMPRESS_LZ4, CBFS_COMPRESS_LZMA, CBFS_COMPRESS_NONE, fit_image_node::compression, fit_image_node::data, die(), KERNEL_HEADER_MAGIC, memcpy(), printk, scratch, SCRATCH_CANARY_VALUE, fit_image_node::size, ulz4fn(), and ulzman().

Referenced by fit_payload_arch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fit_payload_arch()

bool fit_payload_arch ( struct prog payload,
struct fit_config_node config,
struct region kernel,
struct region fdt,
struct region initrd 
)

The code assumes that bootmem_walk provides a sorted list of memory regions, starting from the lowest address. The order of the calls here doesn't matter, as the placement is enforced in the called functions. For details check code on top.

NOTE: versions prior to v4.6 cannot make use of memory below the physical offset of the Image so it is recommended that the Image be placed as close as possible to the start of system RAM.

For kernel <v4.6 the INITRD and FDT can't be placed below the kernel. In that case set region offset to an address on top of kernel.

Definition at line 163 of file fit_payload.c.

References arg, BIOS_CRIT, BIOS_DEBUG, BM_MEM_PAYLOAD, bootmem_add_range(), bootmem_dump_ranges(), bootmem_walk(), config, decompress_kernel_header(), fit_place_kernel(), fit_place_mem(), get_kernel_size(), NULL, region::offset, printk, prog_set_entry(), scratch, and region::size.

Here is the call graph for this function:

◆ fit_place_kernel()

static bool fit_place_kernel ( const struct range_entry r,
void arg 
)
static

The Image must be placed text_offset bytes from a 2MB aligned base address anywhere in usable system RAM and called there. The region between the 2 MB aligned base address and the start of the image has no special significance to the kernel, and may be used for other purposes.

If the reserved memory (BL31 for example) is smaller than text_offset we can use the 2 MiB base address, otherwise use the next 2 MiB page. It's not mandatory, but wastes less memory below the kernel.

At least image_size bytes from the start of the image must be free for use by the kernel.

Definition at line 101 of file fit_payload.c.

References ALIGN_DOWN, arg, BM_MEM_RAM, MiB, region::offset, range_entry_base(), range_entry_end(), range_entry_tag(), scratch, and region::size.

Referenced by fit_payload_arch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fit_place_mem()

static bool fit_place_mem ( const struct range_entry r,
void arg 
)
static

Place the region in free memory range.

The caller has to set region->offset to the minimum allowed address. The region->offset is usually 0 on kernel >v4.6 and kernel_base + kernel_size on kernel <v4.6.

Definition at line 144 of file fit_payload.c.

References ALIGN_UP, arg, BM_MEM_RAM, MAX, MiB, region::offset, range_entry_base(), range_entry_end(), range_entry_tag(), and region::size.

Referenced by fit_payload_arch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_kernel_size()

static size_t get_kernel_size ( const struct fit_image_node node)
static

When image_size is zero, a bootloader should attempt to keep as much memory as possible free for use by the kernel immediately after the end of the kernel image. The amount of space required will vary depending on selected features, and is effectively unbound.

Definition at line 82 of file fit_payload.c.

References BIOS_WARNING, MAX_KERNEL_SIZE, printk, scratch, and fit_image_node::size.

Referenced by fit_payload_arch().

Here is the caller graph for this function:

Variable Documentation

◆ canary

u32 canary

Definition at line 34 of file fit_payload.c.

◆ header

struct arm64_kernel_header header

Definition at line 34 of file fit_payload.c.

Referenced by acpi_create_crat(), acpi_create_dbg2(), acpi_create_dmar(), acpi_create_ecdt(), acpi_create_einj(), acpi_create_fadt(), acpi_create_hest_error_source(), acpi_create_hmat(), acpi_create_hpet(), acpi_create_ipmi(), acpi_create_ivrs(), acpi_create_lpit(), acpi_create_madt(), acpi_create_mcfg(), acpi_create_slit(), acpi_create_srat(), acpi_create_tcpa(), acpi_create_tpm2(), acpi_create_vfct(), acpi_fill_hest(), acpi_write_bert(), acpi_write_hest(), acpi_write_rsdt(), acpi_write_xsdt(), add_cb_fdt_data(), add_cbmem_pointers(), cbmem_add_records_to_cbtable(), dt_flatten(), dump_param_header(), elog_is_header_valid(), elog_verify_header(), elog_write_header_in_mirror(), fdt_next_property(), fdt_unflatten(), fw_cfg_smbios_tables(), intel_gma_init_igd_opregion(), lb_add_console(), lb_add_serial(), lb_arch_add_records(), lb_board(), lb_board_config(), lb_boot_media_params(), lb_first_record(), lb_forward(), lb_framebuffer(), lb_gpios(), lb_last_record(), lb_mainboard(), lb_memory(), lb_mmc_info(), lb_new_record(), lb_record_version_timestamp(), lb_smmstorev2(), lb_spi_flash(), lb_string_platform_blob_version(), lb_strings(), lb_table_add_vbnv_cmos(), lb_table_init(), lb_tpm_ppi(), mei_recv_msg(), mei_send_data(), mei_send_header(), nhlt_serialize_oem_overrides(), probe_edid(), psp_print_cmd_status(), rd_resp_sts(), smbios_full_table_len(), smbios_next(), smbios_write_intel_wifi(), soc_add_mtc(), tis_sendrecv(), and uses_relative_vbt_addr().

◆ raw

u8 raw[sizeof(struct arm64_kernel_header)+0x100]

Definition at line 31 of file fit_payload.c.

Referenced by ast_select_mode(), get_panel_from_cbfs(), LzmaDecode(), and wait_heci_cb_avail().

◆