From 4f96dd41ec7c25ac0e49c40c598257f865fc63ea Mon Sep 17 00:00:00 2001 From: Sonal Aggarwal Date: Mon, 21 Feb 2022 15:45:54 +0530 Subject: [PATCH] securemsm-kernel : Add new functionality in HLOS for TZ to sleep for certain amount of time. Change-Id: I6352bbe201ffcf81fde6ac7fc65e6f8eaeb0c64e --- smcinvoke/smcinvoke.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/smcinvoke/smcinvoke.c b/smcinvoke/smcinvoke.c index 95798de9a9..6bf13bf1fb 100644 --- a/smcinvoke/smcinvoke.c +++ b/smcinvoke/smcinvoke.c @@ -990,6 +990,23 @@ out: return ret; } +static int32_t smcinvoke_sleep(void *buf, size_t buf_len) +{ + struct smcinvoke_tzcb_req *msg = buf; + uint32_t sleepTimeMs_val = 0; + + if (msg->hdr.counts != OBJECT_COUNTS_PACK(1, 0, 0, 0) || + (buf_len - msg->args[0].b.offset < msg->args[0].b.size)) { + pr_err("Invalid counts received for sleeping in hlos\n"); + return OBJECT_ERROR_INVALID; + } + + /* Time in miliseconds is expected from tz */ + sleepTimeMs_val = *((uint32_t *)(buf + msg->args[0].b.offset)); + msleep(sleepTimeMs_val); + return OBJECT_OK; +} + static void process_kernel_obj(void *buf, size_t buf_len) { struct smcinvoke_tzcb_req *cb_req = buf; @@ -1001,6 +1018,9 @@ static void process_kernel_obj(void *buf, size_t buf_len) case OBJECT_OP_YIELD: cb_req->result = OBJECT_OK; break; + case OBJECT_OP_SLEEP: + cb_req->result = smcinvoke_sleep(buf, buf_len); + break; default: pr_err(" invalid operation for tz kernel object\n"); cb_req->result = OBJECT_ERROR_INVALID;