IQSEEComCompatAppLoader.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0-only
  2. *
  3. * Copyright (c) 2021 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #include "smcinvoke_object.h"
  7. #define IQSEEComCompatAppLoader_MAX_FILENAME_LEN UINT32_C(64)
  8. #define IQSEEComCompatAppLoader_ELFCLASS32 UINT32_C(1)
  9. #define IQSEEComCompatAppLoader_ELFCLASS64 UINT32_C(2)
  10. #define IQSEEComCompatAppLoader_ERROR_INVALID_BUFFER INT32_C(10)
  11. #define IQSEEComCompatAppLoader_ERROR_PIL_ROLLBACK_FAILURE INT32_C(11)
  12. #define IQSEEComCompatAppLoader_ERROR_ELF_SIGNATURE_ERROR INT32_C(12)
  13. #define IQSEEComCompatAppLoader_ERROR_METADATA_INVALID INT32_C(13)
  14. #define IQSEEComCompatAppLoader_ERROR_MAX_NUM_APPS INT32_C(14)
  15. #define IQSEEComCompatAppLoader_ERROR_NO_NAME_IN_METADATA INT32_C(15)
  16. #define IQSEEComCompatAppLoader_ERROR_ALREADY_LOADED INT32_C(16)
  17. #define IQSEEComCompatAppLoader_ERROR_EMBEDDED_IMAGE_NOT_FOUND INT32_C(17)
  18. #define IQSEEComCompatAppLoader_ERROR_TZ_HEAP_MALLOC_FAILURE INT32_C(18)
  19. #define IQSEEComCompatAppLoader_ERROR_TA_APP_REGION_MALLOC_FAILURE INT32_C(19)
  20. #define IQSEEComCompatAppLoader_ERROR_CLIENT_CRED_PARSING_FAILURE INT32_C(20)
  21. #define IQSEEComCompatAppLoader_ERROR_APP_UNTRUSTED_CLIENT INT32_C(21)
  22. #define IQSEEComCompatAppLoader_ERROR_APP_BLACKLISTED INT32_C(22)
  23. #define IQSEEComCompatAppLoader_ERROR_APP_NOT_LOADED INT32_C(23)
  24. #define IQSEEComCompatAppLoader_ERROR_NOT_QSEECOM_COMPAT_APP INT32_C(24)
  25. #define IQSEEComCompatAppLoader_ERROR_FILENAME_TOO_LONG INT32_C(25)
  26. #define IQSEEComCompatAppLoader_ERROR_APP_ARCH_NOT_SUPPORTED INT32_C(26)
  27. #define IQSEEComCompatAppLoader_OP_loadFromRegion 0
  28. #define IQSEEComCompatAppLoader_OP_loadFromBuffer 1
  29. #define IQSEEComCompatAppLoader_OP_lookupTA 2
  30. static inline int32_t
  31. IQSEEComCompatAppLoader_release(struct Object self)
  32. {
  33. return Object_invoke(self, Object_OP_release, 0, 0);
  34. }
  35. static inline int32_t
  36. IQSEEComCompatAppLoader_retain(struct Object self)
  37. {
  38. return Object_invoke(self, Object_OP_retain, 0, 0);
  39. }
  40. static inline int32_t
  41. IQSEEComCompatAppLoader_loadFromRegion(struct Object self,
  42. struct Object appElf_val, const void *filename_ptr,
  43. size_t filename_len, struct Object *appCompat_ptr)
  44. {
  45. union ObjectArg a[3];
  46. int32_t result;
  47. a[1].o = appElf_val;
  48. a[0].bi = (struct ObjectBufIn) { filename_ptr, filename_len * 1 };
  49. result = Object_invoke(self, IQSEEComCompatAppLoader_OP_loadFromRegion, a,
  50. ObjectCounts_pack(1, 0, 1, 1));
  51. *appCompat_ptr = a[2].o;
  52. return result;
  53. }
  54. static inline int32_t
  55. IQSEEComCompatAppLoader_loadFromBuffer(struct Object self,
  56. const void *appElf_ptr, size_t appElf_len,
  57. const void *filename_ptr, size_t filename_len,
  58. void *distName_ptr, size_t distName_len,
  59. size_t *distName_lenout, struct Object *appCompat_ptr)
  60. {
  61. union ObjectArg a[4];
  62. int32_t result;
  63. a[0].bi = (struct ObjectBufIn) { appElf_ptr, appElf_len * 1 };
  64. a[1].bi = (struct ObjectBufIn) { filename_ptr, filename_len * 1 };
  65. a[2].b = (struct ObjectBuf) { distName_ptr, distName_len * 1 };
  66. result = Object_invoke(self, IQSEEComCompatAppLoader_OP_loadFromBuffer,
  67. a, ObjectCounts_pack(2, 1, 0, 1));
  68. *distName_lenout = a[2].b.size / 1;
  69. *appCompat_ptr = a[3].o;
  70. return result;
  71. }
  72. static inline int32_t
  73. IQSEEComCompatAppLoader_lookupTA(struct Object self, const void *appName_ptr,
  74. size_t appName_len, struct Object *appCompat_ptr)
  75. {
  76. union ObjectArg a[2];
  77. int32_t result;
  78. a[0].bi = (struct ObjectBufIn) { appName_ptr, appName_len * 1 };
  79. result = Object_invoke(self, IQSEEComCompatAppLoader_OP_lookupTA,
  80. a, ObjectCounts_pack(1, 0, 0, 1));
  81. *appCompat_ptr = a[1].o;
  82. return result;
  83. }