From 0a9efa7fafe8d1cc6a36e813e53cced22ed7171e Mon Sep 17 00:00:00 2001 From: Ye Li Date: Tue, 12 Sep 2017 01:46:04 -0500 Subject: imx8qm/qxp: Add a new SIP to get commit id of arm trusted firmware Add a new SIP call FSL_SIP_BUILDINFO to return the current commit id in 7 hexadecimal digits which are parsed from the version_string. Signed-off-by: Ye Li --- plat/freescale/common/include/fsl_sip.h | 3 ++ plat/freescale/common/sip_svc.c | 49 +++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/plat/freescale/common/include/fsl_sip.h b/plat/freescale/common/include/fsl_sip.h index 3449944d..b8807381 100644 --- a/plat/freescale/common/include/fsl_sip.h +++ b/plat/freescale/common/include/fsl_sip.h @@ -27,4 +27,7 @@ #define FSL_SIP_SRTC 0xC2000002 #define FSL_SIP_SRTC_SET_TIME 0x00 +#define FSL_SIP_BUILDINFO 0xC2000003 +#define FSL_SIP_BUILDINFO_GET_COMMITHASH 0x00 + #endif diff --git a/plat/freescale/common/sip_svc.c b/plat/freescale/common/sip_svc.c index 960245da..84a8e976 100644 --- a/plat/freescale/common/sip_svc.c +++ b/plat/freescale/common/sip_svc.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include extern int imx_gpc_handler(uint32_t smc_fid, u_register_t x1, u_register_t x2, u_register_t x3); extern int imx_cpufreq_handler(uint32_t smc_fid, u_register_t x1, u_register_t x2, u_register_t x3); @@ -50,6 +52,50 @@ static int32_t plat_svc_setup(void) return 0; } +uint64_t imx_get_commit_hash(u_register_t x2, + u_register_t x3, + u_register_t x4) +{ + /* Parse the version_string */ + char* parse = (char*)version_string; + uint64_t hash = 0; + + do { + parse = strchr(parse, '-'); + if (parse) { + parse += 1; + if (*(parse) == 'g') { + /* Default is 7 hexadecimal digits */ + memcpy((void *)&hash, (void *)(parse + 1), 7); + break; + } + } + + } while (parse != NULL); + + return hash; +} + +uint64_t imx_buildinfo_handler(uint32_t smc_fid, + u_register_t x1, + u_register_t x2, + u_register_t x3, + u_register_t x4) +{ + uint64_t ret; + + switch(x1) { + case FSL_SIP_BUILDINFO_GET_COMMITHASH: + ret = imx_get_commit_hash(x2, x3, x4); + break; + default: + return SMC_UNK; + } + + return ret; +} + + /* i.MX platform specific service SMC handler */ uintptr_t imx_svc_smc_handler(uint32_t smc_fid, u_register_t x1, @@ -74,6 +120,9 @@ uintptr_t imx_svc_smc_handler(uint32_t smc_fid, case FSL_SIP_SRTC: SMC_RET1(handle, imx_srtc_handler(smc_fid, x1, x2, x3, x4)); break; + case FSL_SIP_BUILDINFO: + SMC_RET1(handle, imx_buildinfo_handler(smc_fid, x1, x2, x3, x4)); + break; #endif default: WARN("Unimplemented SIP Service Call: 0x%x \n", smc_fid); -- cgit v1.2.3