smcall.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright (c) 2013-2014 Google Inc. All rights reserved
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining
  5. * a copy of this software and associated documentation files
  6. * (the "Software"), to deal in the Software without restriction,
  7. * including without limitation the rights to use, copy, modify, merge,
  8. * publish, distribute, sublicense, and/or sell copies of the Software,
  9. * and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be
  13. * included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  19. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  20. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  21. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #ifndef __LINUX_TRUSTY_SMCALL_H
  24. #define __LINUX_TRUSTY_SMCALL_H
  25. #define SMC_NUM_ENTITIES 64
  26. #define SMC_NUM_ARGS 4
  27. #define SMC_NUM_PARAMS (SMC_NUM_ARGS - 1)
  28. #define SMC_IS_FASTCALL(smc_nr) ((smc_nr) & 0x80000000)
  29. #define SMC_IS_SMC64(smc_nr) ((smc_nr) & 0x40000000)
  30. #define SMC_ENTITY(smc_nr) (((smc_nr) & 0x3F000000) >> 24)
  31. #define SMC_FUNCTION(smc_nr) ((smc_nr) & 0x0000FFFF)
  32. #define SMC_NR(entity, fn, fastcall, smc64) ((((fastcall)&0x1) << 31) | \
  33. (((smc64)&0x1) << 30) | \
  34. (((entity)&0x3F) << 24) | \
  35. ((fn)&0xFFFF) \
  36. )
  37. #define SMC_FASTCALL_NR(entity, fn) SMC_NR((entity), (fn), 1, 0)
  38. #define SMC_STDCALL_NR(entity, fn) SMC_NR((entity), (fn), 0, 0)
  39. #define SMC_FASTCALL64_NR(entity, fn) SMC_NR((entity), (fn), 1, 1)
  40. #define SMC_STDCALL64_NR(entity, fn) SMC_NR((entity), (fn), 0, 1)
  41. #define SMC_ENTITY_ARCH 0 /* ARM Architecture calls */
  42. #define SMC_ENTITY_CPU 1 /* CPU Service calls */
  43. #define SMC_ENTITY_SIP 2 /* SIP Service calls */
  44. #define SMC_ENTITY_OEM 3 /* OEM Service calls */
  45. #define SMC_ENTITY_STD 4 /* Standard Service calls */
  46. #define SMC_ENTITY_RESERVED 5 /* Reserved for future use */
  47. #define SMC_ENTITY_TRUSTED_APP 48 /* Trusted Application calls */
  48. #define SMC_ENTITY_TRUSTED_OS 50 /* Trusted OS calls */
  49. #define SMC_ENTITY_LOGGING 51 /* Used for secure -> nonsecure logging */
  50. #define SMC_ENTITY_MT_TRUSTED_OS 59 /* MTK Trusted OS calls */
  51. #define SMC_ENTITY_SECURE_MONITOR 60 /* Trusted OS calls internal to secure monitor */
  52. /* FC = Fast call, SC = Standard call */
  53. #define SMC_SC_RESTART_LAST SMC_STDCALL_NR(SMC_ENTITY_SECURE_MONITOR, 0)
  54. #define SMC_SC_LOCKED_NOP SMC_STDCALL_NR(SMC_ENTITY_SECURE_MONITOR, 1)
  55. /**
  56. * SMC_SC_RESTART_FIQ - Re-enter trusty after it was interrupted by an fiq
  57. *
  58. * No arguments, no return value.
  59. *
  60. * Re-enter trusty after returning to ns to process an fiq. Must be called iff
  61. * trusty returns SM_ERR_FIQ_INTERRUPTED.
  62. *
  63. * Enable by selecting api version TRUSTY_API_VERSION_RESTART_FIQ (1) or later.
  64. */
  65. #define SMC_SC_RESTART_FIQ SMC_STDCALL_NR(SMC_ENTITY_SECURE_MONITOR, 2)
  66. /**
  67. * SMC_SC_NOP - Enter trusty to run pending work.
  68. *
  69. * No arguments.
  70. *
  71. * Returns SM_ERR_NOP_INTERRUPTED or SM_ERR_NOP_DONE.
  72. * If SM_ERR_NOP_INTERRUPTED is returned, the call must be repeated.
  73. *
  74. * Enable by selecting api version TRUSTY_API_VERSION_SMP (2) or later.
  75. */
  76. #define SMC_SC_NOP SMC_STDCALL_NR(SMC_ENTITY_SECURE_MONITOR, 3)
  77. /*
  78. * Return from secure os to non-secure os with return value in r1
  79. */
  80. #define SMC_SC_NS_RETURN SMC_STDCALL_NR(SMC_ENTITY_SECURE_MONITOR, 0)
  81. #define SMC_FC_RESERVED SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 0)
  82. #define SMC_FC_FIQ_EXIT SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 1)
  83. #define SMC_FC_REQUEST_FIQ SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 2)
  84. #define SMC_FC_GET_NEXT_IRQ SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 3)
  85. #define SMC_FC_FIQ_ENTER SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 4)
  86. #define SMC_FC64_SET_FIQ_HANDLER SMC_FASTCALL64_NR(SMC_ENTITY_SECURE_MONITOR, 5)
  87. #define SMC_FC64_GET_FIQ_REGS SMC_FASTCALL64_NR(SMC_ENTITY_SECURE_MONITOR, 6)
  88. #define SMC_FC_CPU_SUSPEND SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 7)
  89. #define SMC_FC_CPU_RESUME SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 8)
  90. #define SMC_FC_AARCH_SWITCH SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 9)
  91. #define SMC_FC_GET_VERSION_STR SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 10)
  92. /**
  93. * SMC_FC_API_VERSION - Find and select supported API version.
  94. *
  95. * @r1: Version supported by client.
  96. *
  97. * Returns version supported by trusty.
  98. *
  99. * If multiple versions are supported, the client should start by calling
  100. * SMC_FC_API_VERSION with the largest version it supports. Trusty will then
  101. * return a version it supports. If the client does not support the version
  102. * returned by trusty and the version returned is less than the version
  103. * requested, repeat the call with the largest supported version less than the
  104. * last returned version.
  105. *
  106. * This call must be made before any calls that are affected by the api version.
  107. */
  108. #define TRUSTY_API_VERSION_RESTART_FIQ (1)
  109. #define TRUSTY_API_VERSION_SMP (2)
  110. #define TRUSTY_API_VERSION_CURRENT (2)
  111. #define SMC_FC_API_VERSION SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 11)
  112. /* TRUSTED_OS entity calls */
  113. #define SMC_SC_VIRTIO_GET_DESCR SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 20)
  114. #define SMC_SC_VIRTIO_START SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 21)
  115. #define SMC_SC_VIRTIO_STOP SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 22)
  116. #define SMC_SC_VDEV_RESET SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 23)
  117. #define SMC_SC_VDEV_KICK_VQ SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 24)
  118. /* Debugging only */
  119. #ifdef CONFIG_MT_TRUSTY_DEBUGFS
  120. #define MT_SMC_SC_ADD SMC_STDCALL_NR(SMC_ENTITY_MT_TRUSTED_OS, 0xFF00)
  121. #endif
  122. #define MT_SMC_FC_THREADS SMC_FASTCALL_NR(SMC_ENTITY_MT_TRUSTED_OS, 0xFF00)
  123. #define MT_SMC_FC_THREADSTATS SMC_FASTCALL_NR(SMC_ENTITY_MT_TRUSTED_OS, 0xFF01)
  124. #define MT_SMC_FC_THREADLOAD SMC_FASTCALL_NR(SMC_ENTITY_MT_TRUSTED_OS, 0xFF02)
  125. #define MT_SMC_FC_HEAP_DUMP SMC_FASTCALL_NR(SMC_ENTITY_MT_TRUSTED_OS, 0xFF03)
  126. #define MT_SMC_FC_APPS SMC_FASTCALL_NR(SMC_ENTITY_MT_TRUSTED_OS, 0xFF04)
  127. #endif /* __LINUX_TRUSTY_SMCALL_H */