blob: f3dd1127685f868f75dc0acb0a3bfca5bcb4e51d [file] [log] [blame]
Yatharth Kochar9518d022016-03-11 14:20:19 +00001/*
Govindraj Rajaeee28e72023-08-01 15:52:40 -05002 * 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 */
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00006
Yatharth Kochar9518d022016-03-11 14:20:19 +00007#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
9#include <common/debug.h>
10#include <lib/pmf/pmf.h>
11#include <plat/common/platform.h>
Antonio Nino Diaz3c817f42018-03-21 10:49:27 +000012#include <smccc_helpers.h>
Yatharth Kochar9518d022016-03-11 14:20:19 +000013
14/*
15 * This function is responsible for handling all PMF SMC calls.
16 */
17uintptr_t pmf_smc_handler(unsigned int smc_fid,
18 u_register_t x1,
19 u_register_t x2,
20 u_register_t x3,
21 u_register_t x4,
22 void *cookie,
23 void *handle,
24 u_register_t flags)
25{
26 int rc;
27 unsigned long long ts_value;
28
Manish Pandey0b1714f2023-10-27 11:45:44 +010029 /* Determine if the cpu exists of not */
30 if (!is_valid_mpidr(x2))
31 return PSCI_E_INVALID_PARAMS;
32
Yatharth Kochar9518d022016-03-11 14:20:19 +000033 if (((smc_fid >> FUNCID_CC_SHIFT) & FUNCID_CC_MASK) == SMC_32) {
34
35 x1 = (uint32_t)x1;
36 x2 = (uint32_t)x2;
37 x3 = (uint32_t)x3;
38
Jonathan Wrightde701832018-03-13 17:45:42 +000039 if (smc_fid == PMF_SMC_GET_TIMESTAMP_32) {
Yatharth Kochar9518d022016-03-11 14:20:19 +000040 /*
41 * Return error code and the captured
42 * time-stamp to the caller.
43 * x0 --> error code.
44 * x1 - x2 --> time-stamp value.
45 */
Antonio Nino Diazbf170be2018-10-25 17:38:23 +010046 rc = pmf_get_timestamp_smc((unsigned int)x1, x2,
47 (unsigned int)x3, &ts_value);
Yatharth Kochar9518d022016-03-11 14:20:19 +000048 SMC_RET3(handle, rc, (uint32_t)ts_value,
49 (uint32_t)(ts_value >> 32));
Yatharth Kochar9518d022016-03-11 14:20:19 +000050 }
51 } else {
Jonathan Wrightde701832018-03-13 17:45:42 +000052 if (smc_fid == PMF_SMC_GET_TIMESTAMP_64) {
Yatharth Kochar9518d022016-03-11 14:20:19 +000053 /*
54 * Return error code and the captured
55 * time-stamp to the caller.
56 * x0 --> error code.
57 * x1 --> time-stamp value.
58 */
Antonio Nino Diazbf170be2018-10-25 17:38:23 +010059 rc = pmf_get_timestamp_smc((unsigned int)x1, x2,
60 (unsigned int)x3, &ts_value);
Yatharth Kochar9518d022016-03-11 14:20:19 +000061 SMC_RET2(handle, rc, ts_value);
Yatharth Kochar9518d022016-03-11 14:20:19 +000062 }
63 }
64
65 WARN("Unimplemented PMF Call: 0x%x \n", smc_fid);
66 SMC_RET1(handle, SMC_UNK);
67}