Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 3c817f4 | 2018-03-21 10:49:27 +0000 | [diff] [blame] | 2 | * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 5 | */ |
| 6 | #include <assert.h> |
| 7 | #include <debug.h> |
| 8 | #include <platform.h> |
| 9 | #include <pmf.h> |
Antonio Nino Diaz | 3c817f4 | 2018-03-21 10:49:27 +0000 | [diff] [blame] | 10 | #include <smccc_helpers.h> |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 11 | |
| 12 | /* |
| 13 | * This function is responsible for handling all PMF SMC calls. |
| 14 | */ |
| 15 | uintptr_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 Wright | de70183 | 2018-03-13 17:45:42 +0000 | [diff] [blame] | 33 | if (smc_fid == PMF_SMC_GET_TIMESTAMP_32) { |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 34 | /* |
| 35 | * Return error code and the captured |
| 36 | * time-stamp to the caller. |
| 37 | * x0 --> error code. |
| 38 | * x1 - x2 --> time-stamp value. |
| 39 | */ |
| 40 | rc = pmf_get_timestamp_smc(x1, x2, x3, &ts_value); |
| 41 | SMC_RET3(handle, rc, (uint32_t)ts_value, |
| 42 | (uint32_t)(ts_value >> 32)); |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 43 | } |
| 44 | } else { |
Jonathan Wright | de70183 | 2018-03-13 17:45:42 +0000 | [diff] [blame] | 45 | if (smc_fid == PMF_SMC_GET_TIMESTAMP_64) { |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 46 | /* |
| 47 | * Return error code and the captured |
| 48 | * time-stamp to the caller. |
| 49 | * x0 --> error code. |
| 50 | * x1 --> time-stamp value. |
| 51 | */ |
| 52 | rc = pmf_get_timestamp_smc(x1, x2, x3, &ts_value); |
| 53 | SMC_RET2(handle, rc, ts_value); |
Yatharth Kochar | 9518d02 | 2016-03-11 14:20:19 +0000 | [diff] [blame] | 54 | } |
| 55 | } |
| 56 | |
| 57 | WARN("Unimplemented PMF Call: 0x%x \n", smc_fid); |
| 58 | SMC_RET1(handle, SMC_UNK); |
| 59 | } |