rockchip_sip_svc.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2016, 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 <common/runtime_svc.h>
  9. #include <lib/mmio.h>
  10. #include <tools_share/uuid.h>
  11. #include <plat_sip_calls.h>
  12. #include <rockchip_sip_svc.h>
  13. /* Rockchip SiP Service UUID */
  14. DEFINE_SVC_UUID2(rk_sip_svc_uid,
  15. 0xe2c76fe8, 0x3e31, 0xe611, 0xb7, 0x0d,
  16. 0x8f, 0x88, 0xee, 0x74, 0x7b, 0x72);
  17. #pragma weak rockchip_plat_sip_handler
  18. uintptr_t rockchip_plat_sip_handler(uint32_t smc_fid,
  19. u_register_t x1,
  20. u_register_t x2,
  21. u_register_t x3,
  22. u_register_t x4,
  23. void *cookie,
  24. void *handle,
  25. u_register_t flags)
  26. {
  27. ERROR("%s: unhandled SMC (0x%x)\n", __func__, smc_fid);
  28. SMC_RET1(handle, SMC_UNK);
  29. }
  30. /*
  31. * This function is responsible for handling all SiP calls from the NS world
  32. */
  33. uintptr_t sip_smc_handler(uint32_t smc_fid,
  34. u_register_t x1,
  35. u_register_t x2,
  36. u_register_t x3,
  37. u_register_t x4,
  38. void *cookie,
  39. void *handle,
  40. u_register_t flags)
  41. {
  42. uint32_t ns;
  43. /* Determine which security state this SMC originated from */
  44. ns = is_caller_non_secure(flags);
  45. if (!ns)
  46. SMC_RET1(handle, SMC_UNK);
  47. switch (smc_fid) {
  48. case SIP_SVC_CALL_COUNT:
  49. /* Return the number of Rockchip SiP Service Calls. */
  50. SMC_RET1(handle,
  51. RK_COMMON_SIP_NUM_CALLS + RK_PLAT_SIP_NUM_CALLS);
  52. case SIP_SVC_UID:
  53. /* Return UID to the caller */
  54. SMC_UUID_RET(handle, rk_sip_svc_uid);
  55. case SIP_SVC_VERSION:
  56. /* Return the version of current implementation */
  57. SMC_RET2(handle, RK_SIP_SVC_VERSION_MAJOR,
  58. RK_SIP_SVC_VERSION_MINOR);
  59. default:
  60. return rockchip_plat_sip_handler(smc_fid, x1, x2, x3, x4,
  61. cookie, handle, flags);
  62. }
  63. }
  64. /* Define a runtime service descriptor for fast SMC calls */
  65. DECLARE_RT_SVC(
  66. rockchip_sip_svc,
  67. OEN_SIP_START,
  68. OEN_SIP_END,
  69. SMC_TYPE_FAST,
  70. NULL,
  71. sip_smc_handler
  72. );