fvp_el3_spmc_logical_sp.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2022, 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_spmc_logical_sp.h>
  8. #include <services/ffa_svc.h>
  9. #include <smccc_helpers.h>
  10. #define LP_PARTITION_ID 0xC001
  11. #define LP_UUID {0x47a3bf57, 0xe98e43ad, 0xb7db524f, 0x1588f4e3}
  12. /* Our Logical SP currently only supports receipt of direct messaging. */
  13. #define PARTITION_PROPERTIES FFA_PARTITION_DIRECT_REQ_RECV
  14. static int32_t sp_init(void)
  15. {
  16. INFO("LSP: Init function called.\n");
  17. return 0;
  18. }
  19. static uint64_t handle_ffa_direct_request(uint32_t smc_fid, bool secure_origin,
  20. uint64_t x1, uint64_t x2, uint64_t x3,
  21. uint64_t x4, void *cookie,
  22. void *handle, uint64_t flags)
  23. {
  24. uint64_t ret;
  25. uint32_t src_dst;
  26. /* Determine if we have a 64 or 32 direct request. */
  27. if (smc_fid == FFA_MSG_SEND_DIRECT_REQ_SMC32) {
  28. ret = FFA_MSG_SEND_DIRECT_RESP_SMC32;
  29. } else if (smc_fid == FFA_MSG_SEND_DIRECT_REQ_SMC64) {
  30. ret = FFA_MSG_SEND_DIRECT_RESP_SMC64;
  31. } else {
  32. panic(); /* Unknown SMC. */
  33. }
  34. /*
  35. * Handle the incoming request. For testing purposes we echo the
  36. * incoming message.
  37. */
  38. INFO("LSP: Received Direct Request from %s world (0x%x)\n",
  39. secure_origin ? "Secure" : "Normal", ffa_endpoint_source(x1));
  40. /* Populate the source and destination IDs. */
  41. src_dst = (uint32_t) LP_PARTITION_ID << FFA_DIRECT_MSG_SOURCE_SHIFT |
  42. ffa_endpoint_source(x1) << FFA_DIRECT_MSG_DESTINATION_SHIFT;
  43. /*
  44. * Logical SP's must always send a direct response so we can populate
  45. * our response directly.
  46. */
  47. SMC_RET8(handle, ret, src_dst, 0, x4, 0, 0, 0, 0);
  48. }
  49. /* Register logical partition */
  50. DECLARE_LOGICAL_PARTITION(
  51. my_logical_partition,
  52. sp_init, /* Init Function */
  53. LP_PARTITION_ID, /* FF-A Partition ID */
  54. LP_UUID, /* UUID */
  55. PARTITION_PROPERTIES, /* Partition Properties. */
  56. handle_ffa_direct_request /* Callback for direct requests. */
  57. );