Make UUID buffer optional for is_trusted_os_present()
The caller might simply want to know whether there is a Trusted OS,
without the need to identify it.
Change-Id: I97eef8b6e6c4cb948d48735cd7170fced98aee9a
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
diff --git a/include/runtime_services/trusted_os.h b/include/runtime_services/trusted_os.h
index f480c6b..2947882 100644
--- a/include/runtime_services/trusted_os.h
+++ b/include/runtime_services/trusted_os.h
@@ -24,10 +24,8 @@
* Detect whether a Trusted OS is present in the software stack.
* This is implemented using the Trusted OS UID SMC call.
*
- * If a Trusted OS is detected then this function returns 1
- * and populates 'tos_uuid' with the UUID of the detected Trusted OS.
- * Otherwise, this function returns 0 and the value pointed by 'tos_uuid'
- * should be ignored.
+ * Return 1 if a Trusted OS is detected, else 0. Additionally, the caller may
+ * get the UUID of the Trusted OS if he passes a non-null 'tos_uuid' pointer.
*/
unsigned int is_trusted_os_present(uuid_t *tos_uuid);
diff --git a/lib/trusted_os/trusted_os.c b/lib/trusted_os/trusted_os.c
index b24c3d3..ac6a681 100644
--- a/lib/trusted_os/trusted_os.c
+++ b/lib/trusted_os/trusted_os.c
@@ -14,7 +14,6 @@
{
smc_args tos_uid_args = { SMC_TOS_UID };
smc_ret_values ret;
- uint32_t *tos_uuid32;
ret = tftf_smc(&tos_uid_args);
@@ -23,11 +22,13 @@
(ret.ret3 == 0)))
return 0;
- tos_uuid32 = (uint32_t *) tos_uuid;
- tos_uuid32[0] = ret.ret0;
- tos_uuid32[1] = ret.ret1;
- tos_uuid32[2] = ret.ret2;
- tos_uuid32[3] = ret.ret3;
+ if (tos_uuid != NULL) {
+ uint32_t *tos_uuid32 = (uint32_t *) tos_uuid;
+ tos_uuid32[0] = ret.ret0;
+ tos_uuid32[1] = ret.ret1;
+ tos_uuid32[2] = ret.ret2;
+ tos_uuid32[3] = ret.ret3;
+ }
return 1;
}