blob: 4c5b14f93bd66fd4106eeb5775e4a8ba2a1eb600 [file] [log] [blame]
Yatharth Kochar9518d022016-03-11 14:20:19 +00001/*
Antonio Nino Diaz3c817f42018-03-21 10:49:27 +00002 * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
Yatharth Kochar9518d022016-03-11 14:20:19 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Yatharth Kochar9518d022016-03-11 14:20:19 +00005 */
6#include <assert.h>
7#include <debug.h>
8#include <platform.h>
9#include <pmf.h>
Antonio Nino Diaz3c817f42018-03-21 10:49:27 +000010#include <smccc_helpers.h>
Yatharth Kochar9518d022016-03-11 14:20:19 +000011
12/*
13 * This function is responsible for handling all PMF SMC calls.
14 */
15uintptr_t pmf_smc_handler(unsigned int smc_fid,
16 u_register_t x1,
17 u_register_t x2,
18 u_register_t x3,
19 u_register_t x4,
20 void *cookie,
21 void *handle,
22 u_register_t flags)
23{
24 int rc;
25 unsigned long long ts_value;
26
27 if (((smc_fid >> FUNCID_CC_SHIFT) & FUNCID_CC_MASK) == SMC_32) {
28
29 x1 = (uint32_t)x1;
30 x2 = (uint32_t)x2;
31 x3 = (uint32_t)x3;
32
Jonathan Wrightde701832018-03-13 17:45:42 +000033 if (smc_fid == PMF_SMC_GET_TIMESTAMP_32) {
Yatharth Kochar9518d022016-03-11 14:20:19 +000034 /*
35 * Return error code and the captured
36 * time-stamp to the caller.
37 * x0 --> error code.
38 * x1 - x2 --> time-stamp value.
39 */
Antonio Nino Diazbf170be2018-10-25 17:38:23 +010040 rc = pmf_get_timestamp_smc((unsigned int)x1, x2,
41 (unsigned int)x3, &ts_value);
Yatharth Kochar9518d022016-03-11 14:20:19 +000042 SMC_RET3(handle, rc, (uint32_t)ts_value,
43 (uint32_t)(ts_value >> 32));
Yatharth Kochar9518d022016-03-11 14:20:19 +000044 }
45 } else {
Jonathan Wrightde701832018-03-13 17:45:42 +000046 if (smc_fid == PMF_SMC_GET_TIMESTAMP_64) {
Yatharth Kochar9518d022016-03-11 14:20:19 +000047 /*
48 * Return error code and the captured
49 * time-stamp to the caller.
50 * x0 --> error code.
51 * x1 --> time-stamp value.
52 */
Antonio Nino Diazbf170be2018-10-25 17:38:23 +010053 rc = pmf_get_timestamp_smc((unsigned int)x1, x2,
54 (unsigned int)x3, &ts_value);
Yatharth Kochar9518d022016-03-11 14:20:19 +000055 SMC_RET2(handle, rc, ts_value);
Yatharth Kochar9518d022016-03-11 14:20:19 +000056 }
57 }
58
59 WARN("Unimplemented PMF Call: 0x%x \n", smc_fid);
60 SMC_RET1(handle, SMC_UNK);
61}