plat_sip_calls.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2020-2022, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <common/debug.h>
  7. #include <common/runtime_svc.h>
  8. #include <mtk_apusys.h>
  9. #include <mtk_sip_svc.h>
  10. #include <mt_spm_vcorefs.h>
  11. #include <plat_dfd.h>
  12. #include "plat_sip_calls.h"
  13. uintptr_t mediatek_plat_sip_handler(uint32_t smc_fid,
  14. u_register_t x1,
  15. u_register_t x2,
  16. u_register_t x3,
  17. u_register_t x4,
  18. void *cookie,
  19. void *handle,
  20. u_register_t flags)
  21. {
  22. uint64_t ret;
  23. uint32_t rnd_val0 = 0U;
  24. switch (smc_fid) {
  25. case MTK_SIP_VCORE_CONTROL_AARCH32:
  26. case MTK_SIP_VCORE_CONTROL_AARCH64:
  27. ret = spm_vcorefs_args(x1, x2, x3, (uint64_t *)&x4);
  28. SMC_RET2(handle, ret, x4);
  29. break;
  30. case MTK_SIP_APUSYS_CONTROL_AARCH32:
  31. case MTK_SIP_APUSYS_CONTROL_AARCH64:
  32. ret = apusys_kernel_ctrl(x1, x2, x3, x4, &rnd_val0);
  33. SMC_RET2(handle, ret, rnd_val0);
  34. break;
  35. case MTK_SIP_KERNEL_DFD_AARCH32:
  36. case MTK_SIP_KERNEL_DFD_AARCH64:
  37. ret = dfd_smc_dispatcher(x1, x2, x3, x4);
  38. SMC_RET1(handle, ret);
  39. break;
  40. default:
  41. ERROR("%s: unhandled SMC (0x%x)\n", __func__, smc_fid);
  42. break;
  43. }
  44. SMC_RET1(handle, SMC_UNK);
  45. }