hikey960_el3_spmc_logical_sp.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /* Determine if we have a 64 or 32 direct request. */
  26. if (smc_fid == FFA_MSG_SEND_DIRECT_REQ_SMC32) {
  27. ret = FFA_MSG_SEND_DIRECT_RESP_SMC32;
  28. } else if (smc_fid == FFA_MSG_SEND_DIRECT_REQ_SMC64) {
  29. ret = FFA_MSG_SEND_DIRECT_RESP_SMC64;
  30. } else {
  31. panic(); /* Unknown SMC. */
  32. }
  33. /*
  34. * Handle the incoming request. For testing purposes we echo the
  35. * incoming message.
  36. */
  37. INFO("Logical Partition: Received Direct Request from %s world!\n",
  38. secure_origin ? "Secure" : "Normal");
  39. /*
  40. * Logical SP's must always send a direct response so we can populate
  41. * our response directly.
  42. */
  43. SMC_RET8(handle, ret, 0, 0, x4, 0, 0, 0, 0);
  44. }
  45. /* Register logical partition */
  46. DECLARE_LOGICAL_PARTITION(
  47. my_logical_partition,
  48. sp_init, /* Init Function */
  49. LP_PARTITION_ID, /* FF-A Partition ID */
  50. LP_UUID, /* UUID */
  51. PARTITION_PROPERTIES, /* Partition Properties. */
  52. handle_ffa_direct_request /* Callback for direct requests. */
  53. );