fvp_spmd_logical_sp.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) 2023, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <common/debug.h>
  7. #include <services/el3_spmd_logical_sp.h>
  8. #include <services/ffa_svc.h>
  9. #include <smccc_helpers.h>
  10. #define SPMD_LP_PARTITION_ID SPMD_LP_ID_START
  11. #define SPMD_LP_UUID {0xe98e43ad, 0xb7db524f, 0x47a3bf57, 0x1588f4e3}
  12. /* SPMD Logical SP currently only supports sending direct message. */
  13. #define SPMD_PARTITION_PROPERTIES FFA_PARTITION_DIRECT_REQ_SEND
  14. #define SPMD_LP_MAX_SUPPORTED_SP 10
  15. static void fvp_get_partition_info(void)
  16. {
  17. struct ffa_value ret = { 0 };
  18. uint32_t target_uuid[4] = { 0 };
  19. static struct ffa_partition_info_v1_1
  20. part_info[SPMD_LP_MAX_SUPPORTED_SP] = { 0 };
  21. uint16_t num_partitions = 0;
  22. if (!spmd_el3_invoke_partition_info_get(target_uuid, 0, 0, &ret)) {
  23. panic();
  24. }
  25. if (is_ffa_error(&ret)) {
  26. panic();
  27. }
  28. num_partitions = ffa_partition_info_regs_get_last_idx(&ret) + 1;
  29. if (num_partitions > SPMD_LP_MAX_SUPPORTED_SP) {
  30. panic();
  31. }
  32. INFO("Number of secure partitions = %d\n", num_partitions);
  33. for (uint16_t i = 0; i < num_partitions; i++) {
  34. INFO("***Start Partition***\n");
  35. if (!ffa_partition_info_regs_get_part_info(&ret, i, &part_info[i]))
  36. panic();
  37. INFO("\tPartition ID: 0x%x\n", part_info[i].ep_id);
  38. INFO("\tvCPU count:0x%x\n", part_info[i].execution_ctx_count);
  39. INFO("\tProperties: 0x%x\n", part_info[i].properties);
  40. INFO("\tUUID: 0x%x 0x%x 0x%x 0x%x\n", part_info[i].uuid[0],
  41. part_info[i].uuid[1], part_info[i].uuid[2],
  42. part_info[i].uuid[3]);
  43. INFO("***End Partition***\n");
  44. }
  45. }
  46. static int32_t fvp_spmd_logical_partition_init(void)
  47. {
  48. INFO("FVP SPMD LSP: Init function called.\n");
  49. fvp_get_partition_info();
  50. return 0;
  51. }
  52. /*
  53. * Platform specific SMC handler used to translate SIP SMCs or other platform
  54. * specific SMCs into FF-A direct messages.
  55. */
  56. uintptr_t plat_spmd_logical_sp_smc_handler(unsigned int smc_fid,
  57. u_register_t x1,
  58. u_register_t x2,
  59. u_register_t x3,
  60. u_register_t x4,
  61. void *cookie,
  62. void *handle,
  63. u_register_t flags)
  64. {
  65. struct ffa_value retval = { 0 };
  66. uint64_t send_recv_id = SPMD_LP_PARTITION_ID << 16 | 0x8001;
  67. /*
  68. * Forward the SMC as direct request.
  69. */
  70. if (!spmd_el3_ffa_msg_direct_req(send_recv_id, x2, x3, x4, handle, &retval)) {
  71. panic();
  72. }
  73. SMC_RET8(handle, retval.func, retval.arg1, retval.arg2, retval.arg3,
  74. retval.arg4, retval.arg5, retval.arg6, retval.arg7);
  75. }
  76. /* Register SPMD logical partition */
  77. DECLARE_SPMD_LOGICAL_PARTITION(
  78. fvp_spmd_logical_partition,
  79. fvp_spmd_logical_partition_init,/* Init Function */
  80. SPMD_LP_PARTITION_ID, /* FF-A Partition ID */
  81. SPMD_LP_UUID, /* UUID */
  82. SPMD_PARTITION_PROPERTIES /* Partition Properties. */
  83. );