ven_el3_svc.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stdint.h>
  7. #include <common/debug.h>
  8. #include <common/runtime_svc.h>
  9. #include <lib/debugfs.h>
  10. #include <lib/pmf/pmf.h>
  11. #include <services/ven_el3_svc.h>
  12. #include <tools_share/uuid.h>
  13. /* vendor-specific EL3 UUID */
  14. DEFINE_SVC_UUID2(ven_el3_svc_uid,
  15. 0xb6011dca, 0x57c4, 0x407e, 0x83, 0xf0,
  16. 0xa7, 0xed, 0xda, 0xf0, 0xdf, 0x6c);
  17. static int ven_el3_svc_setup(void)
  18. {
  19. #if USE_DEBUGFS
  20. if (debugfs_smc_setup() != 0) {
  21. return 1;
  22. }
  23. #endif /* USE_DEBUGFS */
  24. #if ENABLE_PMF
  25. if (pmf_setup() != 0) {
  26. return 1;
  27. }
  28. #endif /* ENABLE_PMF */
  29. return 0;
  30. }
  31. /*
  32. * This function handles Arm defined vendor-specific EL3 Service Calls.
  33. */
  34. static uintptr_t ven_el3_svc_handler(unsigned int smc_fid,
  35. u_register_t x1,
  36. u_register_t x2,
  37. u_register_t x3,
  38. u_register_t x4,
  39. void *cookie,
  40. void *handle,
  41. u_register_t flags)
  42. {
  43. #if USE_DEBUGFS
  44. /*
  45. * Dispatch debugfs calls to debugfs SMC handler and return its
  46. * return value.
  47. */
  48. if (is_debugfs_fid(smc_fid)) {
  49. return debugfs_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
  50. handle, flags);
  51. }
  52. #endif /* USE_DEBUGFS */
  53. #if ENABLE_PMF
  54. /*
  55. * Dispatch PMF calls to PMF SMC handler and return its return
  56. * value
  57. */
  58. if (is_pmf_fid(smc_fid)) {
  59. return pmf_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
  60. handle, flags);
  61. }
  62. #endif /* ENABLE_PMF */
  63. switch (smc_fid) {
  64. case VEN_EL3_SVC_UID:
  65. /* Return UID to the caller */
  66. SMC_UUID_RET(handle, ven_el3_svc_uid);
  67. break;
  68. case VEN_EL3_SVC_VERSION:
  69. SMC_RET2(handle, VEN_EL3_SVC_VERSION_MAJOR, VEN_EL3_SVC_VERSION_MINOR);
  70. break;
  71. default:
  72. WARN("Unimplemented vendor-specific EL3 Service call: 0x%x\n", smc_fid);
  73. SMC_RET1(handle, SMC_UNK);
  74. break;
  75. }
  76. }
  77. /* Define a runtime service descriptor for fast SMC calls */
  78. DECLARE_RT_SVC(
  79. ven_el3_svc,
  80. OEN_VEN_EL3_START,
  81. OEN_VEN_EL3_END,
  82. SMC_TYPE_FAST,
  83. ven_el3_svc_setup,
  84. ven_el3_svc_handler
  85. );