hisi_sip_svc.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (c) 2016-2017, 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/pmf/pmf.h>
  10. #include <tools_share/uuid.h>
  11. #include <hisi_sip_svc.h>
  12. /* Hisi SiP Service UUID */
  13. DEFINE_SVC_UUID2(hisi_sip_svc_uid,
  14. 0x74df99e5, 0x8276, 0xaa40, 0x9f, 0xf8,
  15. 0xc0, 0x85, 0x52, 0xbc, 0x39, 0x3f);
  16. static int hisi_sip_setup(void)
  17. {
  18. if (pmf_setup() != 0)
  19. return 1;
  20. return 0;
  21. }
  22. /*
  23. * This function handles Hisi defined SiP Calls
  24. */
  25. static uintptr_t hisi_sip_handler(unsigned int smc_fid,
  26. u_register_t x1,
  27. u_register_t x2,
  28. u_register_t x3,
  29. u_register_t x4,
  30. void *cookie,
  31. void *handle,
  32. u_register_t flags)
  33. {
  34. int call_count = 0;
  35. /*
  36. * Dispatch PMF calls to PMF SMC handler and return its return
  37. * value
  38. */
  39. if (is_pmf_fid(smc_fid)) {
  40. return pmf_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
  41. handle, flags);
  42. }
  43. switch (smc_fid) {
  44. case HISI_SIP_SVC_CALL_COUNT:
  45. /* PMF calls */
  46. call_count += PMF_NUM_SMC_CALLS;
  47. /* State switch call */
  48. call_count += 1;
  49. SMC_RET1(handle, call_count);
  50. case HISI_SIP_SVC_UID:
  51. /* Return UID to the caller */
  52. SMC_UUID_RET(handle, hisi_sip_svc_uid);
  53. case HISI_SIP_SVC_VERSION:
  54. /* Return the version of current implementation */
  55. SMC_RET2(handle, HISI_SIP_SVC_VERSION_MAJOR, HISI_SIP_SVC_VERSION_MINOR);
  56. default:
  57. WARN("Unimplemented HISI SiP Service Call: 0x%x \n", smc_fid);
  58. SMC_RET1(handle, SMC_UNK);
  59. }
  60. }
  61. /* Define a runtime service descriptor for fast SMC calls */
  62. DECLARE_RT_SVC(
  63. hisi_sip_svc,
  64. OEN_SIP_START,
  65. OEN_SIP_END,
  66. SMC_TYPE_FAST,
  67. hisi_sip_setup,
  68. hisi_sip_handler
  69. );