1*91f16700Schasinglulu /* 2*91f16700Schasinglulu * Copyright (c) 2016-2018, Arm Limited and Contributors. All rights reserved. 3*91f16700Schasinglulu * 4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause 5*91f16700Schasinglulu */ 6*91f16700Schasinglulu 7*91f16700Schasinglulu #include <assert.h> 8*91f16700Schasinglulu 9*91f16700Schasinglulu #include <common/debug.h> 10*91f16700Schasinglulu #include <lib/pmf/pmf.h> 11*91f16700Schasinglulu #include <plat/common/platform.h> 12*91f16700Schasinglulu #include <smccc_helpers.h> 13*91f16700Schasinglulu 14*91f16700Schasinglulu /* 15*91f16700Schasinglulu * This function is responsible for handling all PMF SMC calls. 16*91f16700Schasinglulu */ 17*91f16700Schasinglulu uintptr_t pmf_smc_handler(unsigned int smc_fid, 18*91f16700Schasinglulu u_register_t x1, 19*91f16700Schasinglulu u_register_t x2, 20*91f16700Schasinglulu u_register_t x3, 21*91f16700Schasinglulu u_register_t x4, 22*91f16700Schasinglulu void *cookie, 23*91f16700Schasinglulu void *handle, 24*91f16700Schasinglulu u_register_t flags) 25*91f16700Schasinglulu { 26*91f16700Schasinglulu int rc; 27*91f16700Schasinglulu unsigned long long ts_value; 28*91f16700Schasinglulu 29*91f16700Schasinglulu /* Determine if the cpu exists of not */ 30*91f16700Schasinglulu if (!is_valid_mpidr(x2)) 31*91f16700Schasinglulu return PSCI_E_INVALID_PARAMS; 32*91f16700Schasinglulu 33*91f16700Schasinglulu if (((smc_fid >> FUNCID_CC_SHIFT) & FUNCID_CC_MASK) == SMC_32) { 34*91f16700Schasinglulu 35*91f16700Schasinglulu x1 = (uint32_t)x1; 36*91f16700Schasinglulu x2 = (uint32_t)x2; 37*91f16700Schasinglulu x3 = (uint32_t)x3; 38*91f16700Schasinglulu 39*91f16700Schasinglulu if (smc_fid == PMF_SMC_GET_TIMESTAMP_32) { 40*91f16700Schasinglulu /* 41*91f16700Schasinglulu * Return error code and the captured 42*91f16700Schasinglulu * time-stamp to the caller. 43*91f16700Schasinglulu * x0 --> error code. 44*91f16700Schasinglulu * x1 - x2 --> time-stamp value. 45*91f16700Schasinglulu */ 46*91f16700Schasinglulu rc = pmf_get_timestamp_smc((unsigned int)x1, x2, 47*91f16700Schasinglulu (unsigned int)x3, &ts_value); 48*91f16700Schasinglulu SMC_RET3(handle, rc, (uint32_t)ts_value, 49*91f16700Schasinglulu (uint32_t)(ts_value >> 32)); 50*91f16700Schasinglulu } 51*91f16700Schasinglulu } else { 52*91f16700Schasinglulu if (smc_fid == PMF_SMC_GET_TIMESTAMP_64) { 53*91f16700Schasinglulu /* 54*91f16700Schasinglulu * Return error code and the captured 55*91f16700Schasinglulu * time-stamp to the caller. 56*91f16700Schasinglulu * x0 --> error code. 57*91f16700Schasinglulu * x1 --> time-stamp value. 58*91f16700Schasinglulu */ 59*91f16700Schasinglulu rc = pmf_get_timestamp_smc((unsigned int)x1, x2, 60*91f16700Schasinglulu (unsigned int)x3, &ts_value); 61*91f16700Schasinglulu SMC_RET2(handle, rc, ts_value); 62*91f16700Schasinglulu } 63*91f16700Schasinglulu } 64*91f16700Schasinglulu 65*91f16700Schasinglulu WARN("Unimplemented PMF Call: 0x%x \n", smc_fid); 66*91f16700Schasinglulu SMC_RET1(handle, SMC_UNK); 67*91f16700Schasinglulu } 68