pmf.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef PMF_H
  7. #define PMF_H
  8. #include <lib/cassert.h>
  9. #include <lib/pmf/pmf_helpers.h>
  10. #include <lib/utils_def.h>
  11. /*
  12. * Constants used for/by PMF services.
  13. */
  14. #define PMF_ARM_TIF_IMPL_ID UL(0x41)
  15. #define PMF_TID_SHIFT 0
  16. #define PMF_TID_MASK (UL(0xFF) << PMF_TID_SHIFT)
  17. #define PMF_SVC_ID_SHIFT 10
  18. #define PMF_SVC_ID_MASK (UL(0x3F) << PMF_SVC_ID_SHIFT)
  19. #define PMF_IMPL_ID_SHIFT 24
  20. #define PMF_IMPL_ID_MASK (UL(0xFF) << PMF_IMPL_ID_SHIFT)
  21. /*
  22. * Flags passed to PMF_REGISTER_SERVICE
  23. */
  24. #define PMF_STORE_ENABLE (1 << 0)
  25. #define PMF_DUMP_ENABLE (1 << 1)
  26. /*
  27. * Flags passed to PMF_GET_TIMESTAMP_XXX
  28. * and PMF_CAPTURE_TIMESTAMP
  29. */
  30. #define PMF_CACHE_MAINT (U(1) << 0)
  31. #define PMF_NO_CACHE_MAINT U(0)
  32. /*
  33. * Defines for PMF SMC function ids used with arm-sip
  34. * range, this is now deprecated and will be removed.
  35. */
  36. #define PMF_SMC_GET_TIMESTAMP_32_DEP U(0x82000010)
  37. #define PMF_SMC_GET_TIMESTAMP_64_DEP U(0xC2000010)
  38. #define PMF_FID_VALUE_DEPRECATED U(0x10)
  39. #define is_pmf_fid_deprecated(_fid) \
  40. (GET_SMC_NUM(_fid) == PMF_FID_VALUE_DEPRECATED)
  41. /*
  42. * Defines for PMF SMC function ids used with Vendor-Specific
  43. * EL3 range.
  44. */
  45. #define PMF_SMC_GET_TIMESTAMP_32 U(0x87000020)
  46. #define PMF_SMC_GET_TIMESTAMP_64 U(0xC7000020)
  47. #define PMF_NUM_SMC_CALLS 2
  48. #define PMF_SMC_GET_VERSION_32 U(0x87000021)
  49. #define PMF_SMC_GET_VERSION_64 U(0xC7000021)
  50. #define PMF_SMC_VERSION U(0x00000001)
  51. /*
  52. * The macros below are used to identify
  53. * PMF calls from the SMC function ID.
  54. */
  55. #define PMF_FID_VALUE U(0x20)
  56. #define PMF_ID_MASK (FUNCID_NUM_MASK & ~(0xf))
  57. #define is_pmf_fid(_fid) ((GET_SMC_NUM(_fid) & PMF_ID_MASK) == PMF_FID_VALUE)
  58. /* Following are the supported PMF service IDs */
  59. #define PMF_PSCI_STAT_SVC_ID 0
  60. #define PMF_RT_INSTR_SVC_ID 1
  61. /*******************************************************************************
  62. * Function & variable prototypes
  63. ******************************************************************************/
  64. /* PMF common functions */
  65. int pmf_get_timestamp_smc(unsigned int tid,
  66. u_register_t mpidr,
  67. unsigned int flags,
  68. unsigned long long *ts_value);
  69. int pmf_setup(void);
  70. uintptr_t pmf_smc_handler(unsigned int smc_fid,
  71. u_register_t x1,
  72. u_register_t x2,
  73. u_register_t x3,
  74. u_register_t x4,
  75. void *cookie,
  76. void *handle,
  77. u_register_t flags);
  78. #endif /* PMF_H */