pmf_smc.c 1.8 KB

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