summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2017-09-12 01:46:04 -0500
committerYe Li <ye.li@nxp.com>2017-09-12 01:46:04 -0500
commit0a9efa7fafe8d1cc6a36e813e53cced22ed7171e (patch)
tree68f2a74fea4af3fa79676e18534dffd26a2bcb70
parentb67922a4ab25a5d14f11d23aebb3a59819f5934d (diff)
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 <ye.li@nxp.com>
-rw-r--r--plat/freescale/common/include/fsl_sip.h3
-rw-r--r--plat/freescale/common/sip_svc.c49
2 files changed, 52 insertions, 0 deletions
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 <std_svc.h>
#include <stdint.h>
#include <uuid.h>
+#include <string.h>
+#include <bl_common.h>
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);