coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
cse_lite.c File Reference
#include <arch/cpu.h>
#include <console/console.h>
#include <cbfs.h>
#include <commonlib/region.h>
#include <fmap.h>
#include <intelblocks/cse.h>
#include <intelblocks/cse_layout.h>
#include <intelbasecode/debug_feature.h>
#include <security/vboot/vboot_common.h>
#include <security/vboot/misc.h>
#include <soc/intel/common/reset.h>
Include dependency graph for cse_lite.c:

Go to the source code of this file.

Data Structures

struct  cse_bp_entry
 
struct  cse_bp_info
 
struct  get_bp_info_rsp
 

Macros

#define BPDT_HEADER_SZ   sizeof(struct bpdt_header)
 
#define BPDT_ENTRY_SZ   sizeof(struct bpdt_entry)
 
#define SUBPART_HEADER_SZ   sizeof(struct subpart_hdr)
 
#define SUBPART_ENTRY_SZ   sizeof(struct subpart_entry)
 
#define SUBPART_MANIFEST_HDR_SZ   sizeof(struct subpart_entry_manifest_header)
 
#define GET_BP_STR(bp_index)   (bp_index ? "RW" : "RO")
 
#define CSE_RW_SIGNATURE   0x000055aa
 
#define CSE_RW_SIGN_SIZE   sizeof(uint32_t)
 
#define CSE_MAX_BOOT_PARTITIONS   3
 

Enumerations

enum  boot_partition_id { RO = 0 , RW = 1 }
 
enum  bp_status { BP_STATUS_SUCCESS = 0 , BP_STATUS_GENERAL_FAILURE = 1 , BP_STATUS_PARTITION_NOT_PRESENT = 2 , BP_STATUS_DATA_FAILURE = 3 }
 
enum  bp_info_flags { BP_INFO_REDUNDANCY_EN = 1 << 0 , BP_INFO_MIN_RECOV_MODE_EN = 1 << 1 , BP_INFO_READ_ONLY_CFG = 1 << 2 }
 
enum  cse_update_status {
  CSE_UPDATE_NOT_REQUIRED , CSE_UPDATE_UPGRADE , CSE_UPDATE_DOWNGRADE , CSE_UPDATE_CORRUPTED ,
  CSE_UPDATE_METADATA_ERROR
}
 

Functions

bool cse_get_boot_performance_data (struct cse_boot_perf_rsp *boot_perf_rsp)
 
static uint8_t cse_get_current_bp (const struct cse_bp_info *cse_bp_info)
 
static const struct cse_bp_entrycse_get_bp_entry (enum boot_partition_id bp, const struct cse_bp_info *cse_bp_info)
 
static void cse_print_boot_partition_info (const struct cse_bp_info *cse_bp_info)
 
static bool cse_is_bp_cmd_info_possible (void)
 
static bool cse_get_bp_info (struct get_bp_info_rsp *bp_info_rsp)
 
static bool cse_set_next_boot_partition (enum boot_partition_id bp)
 
static bool cse_data_clear_request (const struct cse_bp_info *cse_bp_info)
 
__weak void cse_board_reset (void)
 
static bool cse_set_and_boot_from_next_bp (enum boot_partition_id bp)
 
static bool cse_boot_to_rw (const struct cse_bp_info *cse_bp_info)
 
static bool cse_is_rw_dp_valid (const struct cse_bp_info *cse_bp_info)
 
static bool cse_fix_data_failure_err (const struct cse_bp_info *cse_bp_info)
 
static const struct fw_versioncse_get_bp_entry_version (enum boot_partition_id bp, const struct cse_bp_info *bp_info)
 
static const struct fw_versioncse_get_rw_version (const struct cse_bp_info *cse_bp_info)
 
static void cse_get_bp_entry_range (const struct cse_bp_info *cse_bp_info, enum boot_partition_id bp, uint32_t *start_offset, uint32_t *end_offset)
 
static bool cse_is_rw_bp_status_valid (const struct cse_bp_info *cse_bp_info)
 
static bool cse_boot_to_ro (const struct cse_bp_info *cse_bp_info)
 
static bool cse_get_rw_rdev (struct region_device *rdev)
 
static bool cse_is_rw_bp_sign_valid (const struct region_device *target_rdev)
 
static bool cse_get_target_rdev (const struct cse_bp_info *cse_bp_info, struct region_device *target_rdev)
 
static const char * cse_get_source_rdev_fmap (void)
 
static int cse_compare_sub_part_version (const struct fw_version *a, const struct fw_version *b)
 
static bool cse_verify_cbfs_rw_sha256 (const uint8_t *expected_rw_blob_sha, const void *rw_blob, const size_t rw_blob_sz)
 
static bool cse_erase_rw_region (const struct region_device *target_rdev)
 
static bool cse_copy_rw (const struct region_device *target_rdev, const void *buf, size_t offset, size_t size)
 
static bool read_ver_field (const char *start, char **curr, size_t size, uint16_t *ver_field)
 
static enum cse_update_status cse_check_update_status (const struct cse_bp_info *cse_bp_info, struct region_device *target_rdev)
 
static bool cse_write_rw_region (const struct region_device *target_rdev, const void *cse_cbfs_rw, const size_t cse_cbfs_rw_sz)
 
static bool is_cse_fw_update_enabled (void)
 
static enum csme_failure_reason cse_update_rw (const struct cse_bp_info *cse_bp_info, const void *cse_cbfs_rw, const size_t cse_blob_sz, struct region_device *target_rdev)
 
static bool cse_prep_for_rw_update (const struct cse_bp_info *cse_bp_info, enum cse_update_status status)
 
static enum csme_failure_reason cse_trigger_fw_update (const struct cse_bp_info *cse_bp_info, enum cse_update_status status, struct region_device *target_rdev)
 
static uint8_t cse_fw_update (const struct cse_bp_info *cse_bp_info)
 
static const char * cse_sub_part_str (enum bpdt_entry_type type)
 
static bool cse_locate_area_as_rdev_rw (const struct cse_bp_info *cse_bp_info, size_t bp, struct region_device *cse_rdev)
 
static bool cse_sub_part_get_target_rdev (const struct cse_bp_info *cse_bp_info, struct region_device *target_rdev, size_t bp, enum bpdt_entry_type type)
 
static bool cse_get_sub_part_fw_version (enum bpdt_entry_type type, const struct region_device *rdev, struct fw_version *fw_ver)
 
static void cse_sub_part_get_source_fw_version (void *subpart_cbfs_rw, struct fw_version *fw_ver)
 
static bool cse_prep_for_component_update (const struct cse_bp_info *cse_bp_info)
 
static uint8_t cse_sub_part_trigger_update (enum bpdt_entry_type type, uint8_t bp, const void *subpart_cbfs_rw, const size_t blob_sz, struct region_device *target_rdev)
 
static uint8_t handle_cse_sub_part_fw_update_rv (uint8_t rv)
 
static enum csme_failure_reason cse_sub_part_fw_component_update (enum bpdt_entry_type type, const struct cse_bp_info *cse_bp_info, const char *name)
 
static uint8_t cse_sub_part_fw_update (const struct cse_bp_info *cse_bp_info)
 
void cse_fw_sync (void)
 

Variables

struct cse_bp_entry __packed
 
static const char *const cse_regions [] = {"RO", "RW"}
 

Macro Definition Documentation

◆ BPDT_ENTRY_SZ

#define BPDT_ENTRY_SZ   sizeof(struct bpdt_entry)

Definition at line 16 of file cse_lite.c.

◆ BPDT_HEADER_SZ

#define BPDT_HEADER_SZ   sizeof(struct bpdt_header)

Definition at line 15 of file cse_lite.c.

◆ CSE_MAX_BOOT_PARTITIONS

#define CSE_MAX_BOOT_PARTITIONS   3

Definition at line 38 of file cse_lite.c.

◆ CSE_RW_SIGN_SIZE

#define CSE_RW_SIGN_SIZE   sizeof(uint32_t)

Definition at line 28 of file cse_lite.c.

◆ CSE_RW_SIGNATURE

#define CSE_RW_SIGNATURE   0x000055aa

Definition at line 25 of file cse_lite.c.

◆ GET_BP_STR

#define GET_BP_STR (   bp_index)    (bp_index ? "RW" : "RO")

Definition at line 22 of file cse_lite.c.

◆ SUBPART_ENTRY_SZ

#define SUBPART_ENTRY_SZ   sizeof(struct subpart_entry)

Definition at line 18 of file cse_lite.c.

◆ SUBPART_HEADER_SZ

#define SUBPART_HEADER_SZ   sizeof(struct subpart_hdr)

Definition at line 17 of file cse_lite.c.

◆ SUBPART_MANIFEST_HDR_SZ

#define SUBPART_MANIFEST_HDR_SZ   sizeof(struct subpart_entry_manifest_header)

Definition at line 19 of file cse_lite.c.

Enumeration Type Documentation

◆ boot_partition_id

Enumerator
RO 
RW 

Definition at line 41 of file cse_lite.c.

◆ bp_info_flags

Enumerator
BP_INFO_REDUNDANCY_EN 
BP_INFO_MIN_RECOV_MODE_EN 
BP_INFO_READ_ONLY_CFG 

Definition at line 77 of file cse_lite.c.

◆ bp_status

enum bp_status
Enumerator
BP_STATUS_SUCCESS 
BP_STATUS_GENERAL_FAILURE 
BP_STATUS_PARTITION_NOT_PRESENT 
BP_STATUS_DATA_FAILURE 

Definition at line 53 of file cse_lite.c.

◆ cse_update_status

Enumerator
CSE_UPDATE_NOT_REQUIRED 
CSE_UPDATE_UPGRADE 
CSE_UPDATE_DOWNGRADE 
CSE_UPDATE_CORRUPTED 
CSE_UPDATE_METADATA_ERROR 

Definition at line 582 of file cse_lite.c.

Function Documentation

◆ cse_board_reset()

__weak void cse_board_reset ( void  )

Definition at line 350 of file cse_lite.c.

Referenced by cse_set_and_boot_from_next_bp().

Here is the caller graph for this function:

◆ cse_boot_to_ro()

static bool cse_boot_to_ro ( const struct cse_bp_info cse_bp_info)
static

Definition at line 454 of file cse_lite.c.

References cse_get_current_bp(), cse_set_and_boot_from_next_bp(), and RO.

Referenced by cse_prep_for_component_update(), and cse_prep_for_rw_update().

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

◆ cse_boot_to_rw()

static bool cse_boot_to_rw ( const struct cse_bp_info cse_bp_info)
static

Definition at line 373 of file cse_lite.c.

References cse_get_current_bp(), cse_set_and_boot_from_next_bp(), and RW.

Referenced by cse_fix_data_failure_err().

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

◆ cse_check_update_status()

static enum cse_update_status cse_check_update_status ( const struct cse_bp_info cse_bp_info,
struct region_device target_rdev 
)
static

Definition at line 590 of file cse_lite.c.

References BIOS_ERR, printk, and skip_atoi().

Referenced by cse_fw_update().

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

◆ cse_compare_sub_part_version()

static int cse_compare_sub_part_version ( const struct fw_version a,
const struct fw_version b 
)
static

◆ cse_copy_rw()

static bool cse_copy_rw ( const struct region_device target_rdev,
const void buf,
size_t  offset,
size_t  size 
)
static

Definition at line 571 of file cse_lite.c.

References BIOS_ERR, buf, offset, printk, and rdev_writeat().

Referenced by cse_sub_part_trigger_update(), and cse_write_rw_region().

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

◆ cse_data_clear_request()

static bool cse_data_clear_request ( const struct cse_bp_info cse_bp_info)
static

◆ cse_erase_rw_region()

static bool cse_erase_rw_region ( const struct region_device target_rdev)
static

Definition at line 562 of file cse_lite.c.

References BIOS_ERR, printk, rdev_eraseat(), and region_device_sz().

Referenced by cse_sub_part_trigger_update().

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

◆ cse_fix_data_failure_err()

static bool cse_fix_data_failure_err ( const struct cse_bp_info cse_bp_info)
static

Definition at line 394 of file cse_lite.c.

References cse_boot_to_rw(), cse_data_clear_request(), and cse_is_rw_dp_valid().

Here is the call graph for this function:

◆ cse_fw_sync()

void cse_fw_sync ( void  )

Definition at line 1042 of file cse_lite.c.

Referenced by mainboard_romstage_entry().

Here is the caller graph for this function:

◆ cse_fw_update()

static uint8_t cse_fw_update ( const struct cse_bp_info cse_bp_info)
static

◆ cse_get_boot_performance_data()

bool cse_get_boot_performance_data ( struct cse_boot_perf_rsp boot_perf_rsp)

Definition at line 133 of file cse_lite.c.

References __packed, BIOS_ERR, cse_boot_perf_rsp::hdr, HECI_MKHI_ADDR, heci_send_receive(), MKHI_BUP_COMMON_GET_BOOT_PERF_DATA, MKHI_GROUP_ID_BUP_COMMON, printk, and mkhi_hdr::result.

Referenced by cbmem_inject_telemetry_data().

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

◆ cse_get_bp_entry()

static const struct cse_bp_entry* cse_get_bp_entry ( enum boot_partition_id  bp,
const struct cse_bp_info cse_bp_info 
)
static

Definition at line 169 of file cse_lite.c.

References cse_bp_info::bp_entries.

Referenced by cse_get_bp_entry_range(), cse_get_bp_entry_version(), cse_is_rw_bp_status_valid(), cse_is_rw_dp_valid(), and cse_print_boot_partition_info().

Here is the caller graph for this function:

◆ cse_get_bp_entry_range()

static void cse_get_bp_entry_range ( const struct cse_bp_info cse_bp_info,
enum boot_partition_id  bp,
uint32_t start_offset,
uint32_t end_offset 
)
static

Definition at line 425 of file cse_lite.c.

References cse_get_bp_entry(), cse_bp_entry::end_offset, and cse_bp_entry::start_offset.

Referenced by cse_get_target_rdev(), and cse_locate_area_as_rdev_rw().

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

◆ cse_get_bp_entry_version()

static const struct fw_version* cse_get_bp_entry_version ( enum boot_partition_id  bp,
const struct cse_bp_info bp_info 
)
static

Definition at line 411 of file cse_lite.c.

References cse_get_bp_entry(), and cse_bp_entry::fw_ver.

Referenced by cse_get_rw_version().

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

◆ cse_get_bp_info()

◆ cse_get_current_bp()

static uint8_t cse_get_current_bp ( const struct cse_bp_info cse_bp_info)
static

Definition at line 164 of file cse_lite.c.

References cse_bp_info::current_bp.

Referenced by cse_boot_to_ro(), cse_boot_to_rw(), and cse_data_clear_request().

Here is the caller graph for this function:

◆ cse_get_rw_rdev()

static bool cse_get_rw_rdev ( struct region_device rdev)
static

Definition at line 462 of file cse_lite.c.

References BIOS_ERR, fmap_locate_area_as_rdev_rw(), printk, and rdev.

Referenced by cse_get_target_rdev(), and cse_locate_area_as_rdev_rw().

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

◆ cse_get_rw_version()

static const struct fw_version* cse_get_rw_version ( const struct cse_bp_info cse_bp_info)
static

Definition at line 420 of file cse_lite.c.

References cse_get_bp_entry_version(), and RW.

Here is the call graph for this function:

◆ cse_get_source_rdev_fmap()

static const char* cse_get_source_rdev_fmap ( void  )
static

Definition at line 508 of file cse_lite.c.

References NULL, vboot_get_context(), and vboot_is_firmware_slot_a().

Here is the call graph for this function:

◆ cse_get_sub_part_fw_version()

◆ cse_get_target_rdev()

static bool cse_get_target_rdev ( const struct cse_bp_info cse_bp_info,
struct region_device target_rdev 
)
static

Definition at line 485 of file cse_lite.c.

References BIOS_DEBUG, cse_get_bp_entry_range(), cse_get_rw_rdev(), printk, rdev_chain(), and RW.

Referenced by cse_fw_update().

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

◆ cse_is_bp_cmd_info_possible()

static bool cse_is_bp_cmd_info_possible ( void  )
static

Definition at line 213 of file cse_lite.c.

References cse_is_hfs1_com_normal(), cse_is_hfs1_com_secover_mei_msg(), cse_is_hfs1_com_soft_temp_disable(), and cse_is_hfs1_cws_normal().

Referenced by cse_get_bp_info(), and cse_set_next_boot_partition().

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

◆ cse_is_rw_bp_sign_valid()

static bool cse_is_rw_bp_sign_valid ( const struct region_device target_rdev)
static

Definition at line 473 of file cse_lite.c.

References BIOS_ERR, CSE_RW_SIGN_SIZE, CSE_RW_SIGNATURE, printk, and rdev_readat().

Here is the call graph for this function:

◆ cse_is_rw_bp_status_valid()

static bool cse_is_rw_bp_status_valid ( const struct cse_bp_info cse_bp_info)
static

Definition at line 440 of file cse_lite.c.

References BIOS_ERR, BP_STATUS_GENERAL_FAILURE, BP_STATUS_PARTITION_NOT_PRESENT, cse_get_bp_entry(), printk, RW, and cse_bp_entry::status.

Here is the call graph for this function:

◆ cse_is_rw_dp_valid()

static bool cse_is_rw_dp_valid ( const struct cse_bp_info cse_bp_info)
static

Definition at line 382 of file cse_lite.c.

References BP_STATUS_DATA_FAILURE, cse_get_bp_entry(), RW, and cse_bp_entry::status.

Referenced by cse_fix_data_failure_err().

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

◆ cse_locate_area_as_rdev_rw()

static bool cse_locate_area_as_rdev_rw ( const struct cse_bp_info cse_bp_info,
size_t  bp,
struct region_device cse_rdev 
)
static

Definition at line 795 of file cse_lite.c.

References BIOS_DEBUG, cse_get_bp_entry_range(), cse_get_rw_rdev(), cse_regions, printk, rdev_chain(), RO, RW, and strcmp().

Referenced by cse_sub_part_get_target_rdev().

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

◆ cse_prep_for_component_update()

static bool cse_prep_for_component_update ( const struct cse_bp_info cse_bp_info)
static

Definition at line 910 of file cse_lite.c.

References cse_boot_to_ro(), and cse_hmrfpo_enable().

Here is the call graph for this function:

◆ cse_prep_for_rw_update()

static bool cse_prep_for_rw_update ( const struct cse_bp_info cse_bp_info,
enum cse_update_status  status 
)
static

Definition at line 697 of file cse_lite.c.

References BIOS_ERR, cse_boot_to_ro(), cse_data_clear_request(), cse_hmrfpo_enable(), CSE_UPDATE_CORRUPTED, CSE_UPDATE_DOWNGRADE, and printk.

Here is the call graph for this function:

◆ cse_print_boot_partition_info()

static void cse_print_boot_partition_info ( const struct cse_bp_info cse_bp_info)
static

◆ cse_set_and_boot_from_next_bp()

static bool cse_set_and_boot_from_next_bp ( enum boot_partition_id  bp)
static

Definition at line 356 of file cse_lite.c.

References cse_board_reset(), cse_set_next_boot_partition(), die(), and do_global_reset().

Referenced by cse_boot_to_ro(), and cse_boot_to_rw().

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

◆ cse_set_next_boot_partition()

static bool cse_set_next_boot_partition ( enum boot_partition_id  bp)
static

Definition at line 269 of file cse_lite.c.

References __packed, BIOS_ERR, BIOS_INFO, cse_is_bp_cmd_info_possible(), GET_BP_STR, HECI_MKHI_ADDR, heci_send_receive(), MKHI_BUP_COMMON_SET_BOOT_PARTITION_INFO, MKHI_GROUP_ID_BUP_COMMON, printk, mkhi_hdr::result, RO, and RW.

Referenced by cse_set_and_boot_from_next_bp().

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

◆ cse_sub_part_fw_component_update()

static enum csme_failure_reason cse_sub_part_fw_component_update ( enum bpdt_entry_type  type,
const struct cse_bp_info cse_bp_info,
const char *  name 
)
static

Definition at line 948 of file cse_lite.c.

References CSE_LITE_SKU_PART_UPDATE_SUCCESS, CSE_LITE_SKU_SUB_PART_UPDATE_NOT_REQ, and cse_trigger_vboot_recovery().

Referenced by cse_sub_part_fw_update().

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

◆ cse_sub_part_fw_update()

static uint8_t cse_sub_part_fw_update ( const struct cse_bp_info cse_bp_info)
static

◆ cse_sub_part_get_source_fw_version()

◆ cse_sub_part_get_target_rdev()

static bool cse_sub_part_get_target_rdev ( const struct cse_bp_info cse_bp_info,
struct region_device target_rdev,
size_t  bp,
enum bpdt_entry_type  type 
)
static

◆ cse_sub_part_str()

static const char* cse_sub_part_str ( enum bpdt_entry_type  type)
static

Definition at line 783 of file cse_lite.c.

References IOM_FW, NPHY_FW, and type.

Referenced by cse_get_sub_part_fw_version(), cse_sub_part_get_target_rdev(), and cse_sub_part_trigger_update().

Here is the caller graph for this function:

◆ cse_sub_part_trigger_update()

static uint8_t cse_sub_part_trigger_update ( enum bpdt_entry_type  type,
uint8_t  bp,
const void subpart_cbfs_rw,
const size_t  blob_sz,
struct region_device target_rdev 
)
static

◆ cse_trigger_fw_update()

static enum csme_failure_reason cse_trigger_fw_update ( const struct cse_bp_info cse_bp_info,
enum cse_update_status  status,
struct region_device target_rdev 
)
static

Definition at line 697 of file cse_lite.c.

Referenced by cse_fw_update().

Here is the caller graph for this function:

◆ cse_update_rw()

static enum csme_failure_reason cse_update_rw ( const struct cse_bp_info cse_bp_info,
const void cse_cbfs_rw,
const size_t  cse_blob_sz,
struct region_device target_rdev 
)
static

Definition at line 667 of file cse_lite.c.

References CONFIG, and is_debug_cse_fw_update_disable().

Here is the call graph for this function:

◆ cse_verify_cbfs_rw_sha256()

static bool cse_verify_cbfs_rw_sha256 ( const uint8_t expected_rw_blob_sha,
const void rw_blob,
const size_t  rw_blob_sz 
)
static

Definition at line 540 of file cse_lite.c.

References BIOS_ERR, BIOS_SPEW, memcmp(), and printk.

Here is the call graph for this function:

◆ cse_write_rw_region()

static bool cse_write_rw_region ( const struct region_device target_rdev,
const void cse_cbfs_rw,
const size_t  cse_cbfs_rw_sz 
)
static

Definition at line 645 of file cse_lite.c.

References BIOS_INFO, cse_copy_rw(), CSE_RW_SIGN_SIZE, and printk.

Here is the call graph for this function:

◆ handle_cse_sub_part_fw_update_rv()

static uint8_t handle_cse_sub_part_fw_update_rv ( uint8_t  rv)
static

Definition at line 948 of file cse_lite.c.

Referenced by cse_sub_part_fw_update().

Here is the caller graph for this function:

◆ is_cse_fw_update_enabled()

static bool is_cse_fw_update_enabled ( void  )
static

Definition at line 667 of file cse_lite.c.

◆ read_ver_field()

static bool read_ver_field ( const char *  start,
char **  curr,
size_t  size,
uint16_t ver_field 
)
static

Definition at line 590 of file cse_lite.c.

Variable Documentation

◆ __packed

◆ cse_regions

const char* const cse_regions[] = {"RO", "RW"}
static

Definition at line 131 of file cse_lite.c.

Referenced by cse_locate_area_as_rdev_rw(), and cse_sub_part_get_target_rdev().