soc/qualcomm/common: Add support for loading ramdump image

Ramdump is a debug image loaded during a crash to capture memory
contents for post-crash analysis. This patch adds support for
loading this image during the qclib_rerun() sequence.

Key changes:
1) Introduce QC_RAMDUMP_ENABLE Kconfig option to control ramdump image
   loading.
2) Add qclib_check_dload_mode() as a weak function that works in
   conjunction with the Kconfig check to decide whether the ramdump
   image should be loaded.
3) Add new CBFS file entry and table entry definition for ramdump_meta.
4) Re-use "apdp_ramdump_meta" region for ramdump metadata storage.

TEST=Create an image.serial.bin and ensure it boots on X1P42100.

Change-Id: I42bcd74c3d236a6af49ec4b548bc9cda33bd0825
Signed-off-by: Venkateshwar S <vens@qualcomm.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90306
Reviewed-by: Subrata Banik <subratabanik@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Venkateshwar S 2025-12-01 04:07:16 -08:00 committed by Subrata Banik
commit 445961c604
3 changed files with 42 additions and 0 deletions

View file

@ -33,4 +33,12 @@ config QC_APDP_ENABLE
Application Processor Debug Policy (APDP) is a configuration image
to define and enforce debugging capabilities and restrictions for APPS.
config QC_RAMDUMP_ENABLE
bool
default n
prompt "Debug Build: enable Ramdump"
help
Ramdump is a debug image that is loaded during a system crash to capture
memory contents for post-crash analysis.
endif

View file

@ -3,6 +3,8 @@
#ifndef _SOC_QUALCOMM_QCLIB_COMMON_H__
#define _SOC_QUALCOMM_QCLIB_COMMON_H__
#include <stdbool.h>
/* coreboot & QCLib I/F definitions */
/* string field lengths */
@ -29,6 +31,7 @@
#define QCLIB_TE_AOP_META_SETTINGS "aop_metadata"
#define QCLIB_TE_AOP_DEVCFG_META_SETTINGS "aop_cfg_metadata"
#define QCLIB_TE_APDP_META_SETTINGS "apdp_metadata"
#define QCLIB_TE_RAMDUMP_META_SETTINGS "ramdump_metadata"
/* BA_BMASK_VALUES (blob_attributes bit mask values) */
#define QCLIB_BA_SAVE_TO_STORAGE 0x00000001
@ -44,6 +47,7 @@ enum qclib_cbfs_file {
QCLIB_CBFS_AOP_META,
QCLIB_CBFS_AOP_DEVCFG_META,
QCLIB_CBFS_APDP_META,
QCLIB_CBFS_RAMDUMP_META,
QCLIB_CBFS_MAX
};
@ -82,6 +86,7 @@ void qclib_add_if_table_entry(const char *name, void *base,
void qclib_load_and_run(void);
void qclib_rerun(void);
int qclib_soc_override(struct qclib_cb_if_table *table);
bool qclib_check_dload_mode(void);
const char *qclib_file_default(enum qclib_cbfs_file file);
const char *qclib_file(enum qclib_cbfs_file file);

View file

@ -96,6 +96,8 @@ const char *qclib_file_default(enum qclib_cbfs_file file)
return CONFIG_CBFS_PREFIX "/aop_devcfg_meta";
case QCLIB_CBFS_APDP_META:
return CONFIG_CBFS_PREFIX "/apdp_meta";
case QCLIB_CBFS_RAMDUMP_META:
return CONFIG_CBFS_PREFIX "/ramdump_meta";
default:
die("unknown QcLib file %d", file);
}
@ -186,6 +188,11 @@ static void dump_te_table(void)
__weak int qclib_soc_override(struct qclib_cb_if_table *table) { return 0; }
__weak bool qclib_check_dload_mode(void)
{
return false;
}
static bool qclib_debug_log_level(void)
{
return get_uint_option("qclib_debug_level", 1);
@ -398,6 +405,28 @@ void qclib_rerun(void)
qclib_add_if_table_entry(QCLIB_TE_AOP_DEVCFG_META_SETTINGS, _aop_blob_meta, data_size, 0);
if (CONFIG(QC_RAMDUMP_ENABLE) && qclib_check_dload_mode()) {
struct prog ramdump_prog =
PROG_INIT(PROG_REFCODE, CONFIG_CBFS_PREFIX "/ramdump");
if (cbfs_prog_stage_load(&ramdump_prog))
die("SOC image: ramdump load failed");
/* Attempt to load ramdump_meta Blob. */
data_size = cbfs_load(qclib_file(QCLIB_CBFS_RAMDUMP_META),
_apdp_ramdump_meta, REGION_SIZE(apdp_ramdump_meta));
if (!data_size) {
printk(BIOS_ERR,
"[%s] /ramdump_meta not loaded\n"
"Ramdump will not be captured for crash analysis\n",
__func__);
goto fail;
}
qclib_add_if_table_entry(QCLIB_TE_RAMDUMP_META_SETTINGS, _apdp_ramdump_meta, data_size, 0);
}
/* Set up the system and jump into QcLib */
printk(BIOS_DEBUG, "\n\n\nRe-enter QCLib to bring up AOP\n");
qclib_prepare_and_run();