Subject: [PATCH] arch: arm: mach-imx: print HAB ROM code version
From: Denis Osterland-Heim <[email-masked]>
To: [email-masked]
Date: Thu, 11 Mar 2021 18:01:37 +0100

From: Denis Osterland-Heim <[email-masked]>

Add the two missing function pointers according to HAB4_API.pdf
from cst-3.1.0 and print the version of ROM code.

Signed-off-by: Denis Osterland-Heim <[email-masked]>
---
 drivers/hab/habv4.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/hab/habv4.c b/drivers/hab/habv4.c
index c2acb8136..f30e5d68c 100644
--- a/drivers/hab/habv4.c
+++ b/drivers/hab/habv4.c
@@ -161,6 +161,7 @@ struct hab_header {
 	uint8_t par;
 } __packed;
 
+typedef void (*hab_image_entry_fn)(void);
 typedef enum hab_status hab_loader_callback_fn(void **start, uint32_t *bytes, const void *boot_data);
 
 struct habv4_rvt {
@@ -175,6 +176,8 @@ struct habv4_rvt {
 	enum hab_status (*report_event)(enum hab_status status, uint32_t index, void *event, uint32_t *bytes);
 	enum hab_status (*report_status)(enum hab_config *config, enum hab_state *state);
 	void (*failsafe)(void);
+	hab_image_entry_fn (*authenticate_image_no_dcd)(uint8_t cid, ptrdiff_t ivt_offset, void **start, size_t *bytes, hab_loader_callback_fn loader);
+	uint32_t (*get_version)(void);
 } __packed;
 
 #define FSL_SIP_HAB             0xC2000007
@@ -528,6 +531,7 @@ static int habv4_get_status(const struct habv4_rvt *rvt)
 	uint8_t *data;
 	uint32_t len;
 	int i;
+	uint32_t version;
 	enum hab_status status;
 	enum hab_config config = 0x0;
 	enum hab_state state = 0x0;
@@ -537,6 +541,9 @@ static int habv4_get_status(const struct habv4_rvt *rvt)
 		return -EINVAL;
 	}
 
+	version = rvt->get_version();
+	pr_info("version: %u.%u.%u\n", (version >> 16), ((version >> 8) & 0xff), (version & 0xff));
+
 	status = rvt->report_status(&config, &state);
 	pr_info("Status: %s (0x%02x)\n", habv4_get_status_str(status), status);
 	pr_info("Config: %s (0x%02x)\n", habv4_get_config_str(config), config);
-- 
2.30.2