trp_helpers.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2022, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <plat/common/platform.h>
  7. #include <services/rmmd_svc.h>
  8. #include "trp_private.h"
  9. /*
  10. * Per cpu data structure to populate parameters for an SMC in C code and use
  11. * a pointer to this structure in assembler code to populate x0-x7
  12. */
  13. static trp_args_t trp_smc_args[PLATFORM_CORE_COUNT];
  14. /*
  15. * Set the arguments for SMC call
  16. */
  17. trp_args_t *set_smc_args(uint64_t arg0,
  18. uint64_t arg1,
  19. uint64_t arg2,
  20. uint64_t arg3,
  21. uint64_t arg4,
  22. uint64_t arg5,
  23. uint64_t arg6,
  24. uint64_t arg7)
  25. {
  26. uint32_t linear_id;
  27. trp_args_t *pcpu_smc_args;
  28. /*
  29. * Return to Secure Monitor by raising an SMC. The results of the
  30. * service are passed as an arguments to the SMC
  31. */
  32. linear_id = plat_my_core_pos();
  33. pcpu_smc_args = &trp_smc_args[linear_id];
  34. write_trp_arg(pcpu_smc_args, TRP_ARG0, arg0);
  35. write_trp_arg(pcpu_smc_args, TRP_ARG1, arg1);
  36. write_trp_arg(pcpu_smc_args, TRP_ARG2, arg2);
  37. write_trp_arg(pcpu_smc_args, TRP_ARG3, arg3);
  38. write_trp_arg(pcpu_smc_args, TRP_ARG4, arg4);
  39. write_trp_arg(pcpu_smc_args, TRP_ARG5, arg5);
  40. write_trp_arg(pcpu_smc_args, TRP_ARG6, arg6);
  41. write_trp_arg(pcpu_smc_args, TRP_ARG7, arg7);
  42. return pcpu_smc_args;
  43. }
  44. /*
  45. * Abort the boot process with the reason given in err.
  46. */
  47. __dead2 void trp_boot_abort(uint64_t err)
  48. {
  49. (void)trp_smc(set_smc_args(RMM_BOOT_COMPLETE, err, 0, 0, 0, 0, 0, 0));
  50. panic();
  51. }