coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
fsp_relocate.c File Reference
#include <console/console.h>
#include <commonlib/endian.h>
#include <commonlib/fsp.h>
#include <vendorcode/intel/edk2/uefi_2.4/uefi_types.h>
#include <vendorcode/intel/fsp/fsp1_1/IntelFspPkg/Include/FspInfoHeader.h>
#include <commonlib/helpers.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
Include dependency graph for fsp_relocate.c:

Go to the source code of this file.

Data Structures

struct  fsp_patch_table
 

Macros

#define FSP_DBG_LVL   BIOS_NEVER
 
#define FSPP_SIG   0x50505346
 

Functions

static int guid_compare (const EFI_GUID *le_guid, const EFI_GUID *native_guid)
 
static voidrelative_offset (void *base, ssize_t offset)
 
static uint32_tfspp_reloc (void *fsp, size_t fsp_size, uint32_t e)
 
static int reloc_type (uint16_t reloc_entry)
 
static size_t reloc_offset (uint16_t reloc_entry)
 
static int te_relocate (uintptr_t new_addr, void *te)
 
static size_t csh_size (const EFI_COMMON_SECTION_HEADER *csh)
 
static size_t section_data_offset (const EFI_COMMON_SECTION_HEADER *csh)
 
static size_t section_data_size (const EFI_COMMON_SECTION_HEADER *csh)
 
static size_t file_section_offset (const EFI_FFS_FILE_HEADER *ffsfh)
 
static size_t ffs_file_size (const EFI_FFS_FILE_HEADER *ffsfh)
 
static int relocate_patch_table (void *fsp, size_t size, size_t offset, ssize_t adjustment)
 
static ssize_t relocate_remaining_items (void *fsp, size_t size, uintptr_t new_addr, size_t fih_offset)
 
static ssize_t relocate_fvh (uintptr_t new_addr, void *fsp, size_t fsp_size, size_t fvh_offset, size_t *fih_offset)
 
ssize_t fsp_component_relocate (uintptr_t new_addr, void *fsp, size_t size)
 
ssize_t fsp1_1_relocate (uintptr_t new_addr, void *fsp, size_t size)
 

Variables

static const EFI_GUID ffs2_guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID
 
static const EFI_GUID fih_guid = FSP_INFO_HEADER_GUID
 
struct fsp_patch_table __packed
 

Macro Definition Documentation

◆ FSP_DBG_LVL

#define FSP_DBG_LVL   BIOS_NEVER

Definition at line 25 of file fsp_relocate.c.

◆ FSPP_SIG

#define FSPP_SIG   0x50505346

Definition at line 59 of file fsp_relocate.c.

Function Documentation

◆ csh_size()

static size_t csh_size ( const EFI_COMMON_SECTION_HEADER *  csh)
static

Definition at line 203 of file fsp_relocate.c.

References read_le8().

Referenced by section_data_offset(), and section_data_size().

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

◆ ffs_file_size()

static size_t ffs_file_size ( const EFI_FFS_FILE_HEADER *  ffsfh)
static

Definition at line 244 of file fsp_relocate.c.

References read_le32(), and read_le8().

Referenced by relocate_fvh().

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

◆ file_section_offset()

static size_t file_section_offset ( const EFI_FFS_FILE_HEADER *  ffsfh)
static

Definition at line 236 of file fsp_relocate.c.

Referenced by relocate_fvh(), and relocate_remaining_items().

Here is the caller graph for this function:

◆ fsp1_1_relocate()

ssize_t fsp1_1_relocate ( uintptr_t  new_addr,
void fsp,
size_t  size 
)

Definition at line 539 of file fsp_relocate.c.

References fsp_component_relocate().

Referenced by fsp_relocate().

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

◆ fsp_component_relocate()

ssize_t fsp_component_relocate ( uintptr_t  new_addr,
void fsp,
size_t  size 
)

Definition at line 507 of file fsp_relocate.c.

References BIOS_ERR, NULL, offset, printk, relocate_fvh(), and relocate_remaining_items().

Referenced by fsp1_1_relocate().

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

◆ fspp_reloc()

static uint32_t* fspp_reloc ( void fsp,
size_t  fsp_size,
uint32_t  e 
)
static

Definition at line 71 of file fsp_relocate.c.

References MiB, NULL, offset, and relative_offset().

Referenced by relocate_patch_table().

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

◆ guid_compare()

static int guid_compare ( const EFI_GUID *  le_guid,
const EFI_GUID *  native_guid 
)
static

Definition at line 35 of file fsp_relocate.c.

References ARRAY_SIZE, memcmp(), read_le16(), and read_le32().

Referenced by relocate_fvh(), and relocate_remaining_items().

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

◆ relative_offset()

static void* relative_offset ( void base,
ssize_t  offset 
)
static

Definition at line 61 of file fsp_relocate.c.

References base, and offset.

Referenced by fspp_reloc(), relocate_fvh(), relocate_patch_table(), relocate_remaining_items(), and te_relocate().

Here is the caller graph for this function:

◆ reloc_offset()

static size_t reloc_offset ( uint16_t  reloc_entry)
static

Definition at line 97 of file fsp_relocate.c.

Referenced by te_relocate().

Here is the caller graph for this function:

◆ reloc_type()

static int reloc_type ( uint16_t  reloc_entry)
static

Definition at line 91 of file fsp_relocate.c.

Referenced by te_relocate().

Here is the caller graph for this function:

◆ relocate_fvh()

static ssize_t relocate_fvh ( uintptr_t  new_addr,
void fsp,
size_t  fsp_size,
size_t  fvh_offset,
size_t fih_offset 
)
static

Definition at line 381 of file fsp_relocate.c.

References ALIGN_UP, BIOS_ERR, ffs2_guid, ffs_file_size(), file_section_offset(), FSP_DBG_LVL, guid_compare(), NULL, offset, printk, read_le16(), read_le32(), read_le64(), read_le8(), relative_offset(), section_data_offset(), section_data_size(), and te_relocate().

Referenced by fsp_component_relocate().

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

◆ relocate_patch_table()

static int relocate_patch_table ( void fsp,
size_t  size,
size_t  offset,
ssize_t  adjustment 
)
static

Definition at line 264 of file fsp_relocate.c.

References BIOS_ERR, FSP_DBG_LVL, fspp_reloc(), fsp_patch_table::header_length, NULL, offset, fsp_patch_table::patch_entries, fsp_patch_table::patch_entry_num, printk, read_le16(), read_le32(), relative_offset(), and write_le32().

Referenced by relocate_remaining_items().

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

◆ relocate_remaining_items()

static ssize_t relocate_remaining_items ( void fsp,
size_t  size,
uintptr_t  new_addr,
size_t  fih_offset 
)
static

Definition at line 306 of file fsp_relocate.c.

References BIOS_ERR, fih_guid, file_section_offset(), FSP_DBG_LVL, FSPP_SIG, guid_compare(), offset, printk, read_le32(), read_le8(), relative_offset(), relocate_patch_table(), section_data_offset(), and write_le32().

Referenced by fsp_component_relocate().

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

◆ section_data_offset()

static size_t section_data_offset ( const EFI_COMMON_SECTION_HEADER *  csh)
static

Definition at line 216 of file fsp_relocate.c.

References csh_size().

Referenced by relocate_fvh(), relocate_remaining_items(), and section_data_size().

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

◆ section_data_size()

static size_t section_data_size ( const EFI_COMMON_SECTION_HEADER *  csh)
static

Definition at line 224 of file fsp_relocate.c.

References csh_size(), read_le32(), and section_data_offset().

Referenced by relocate_fvh().

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

◆ te_relocate()

static int te_relocate ( uintptr_t  new_addr,
void te 
)
static

Definition at line 103 of file fsp_relocate.c.

References BIOS_ERR, FSP_DBG_LVL, offset, printk, read_le16(), read_le32(), read_le64(), relative_offset(), reloc_offset(), reloc_type(), type, val, write_le32(), and write_le64().

Referenced by relocate_fvh().

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

Variable Documentation

◆ __packed

◆ ffs2_guid

const EFI_GUID ffs2_guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID
static

Definition at line 47 of file fsp_relocate.c.

Referenced by relocate_fvh().

◆ fih_guid

const EFI_GUID fih_guid = FSP_INFO_HEADER_GUID
static

Definition at line 48 of file fsp_relocate.c.

Referenced by relocate_remaining_items().