arm-sip-service.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. Arm SiP Services
  2. ================
  3. This document enumerates and describes the Arm SiP (Silicon Provider) services.
  4. SiP services are non-standard, platform-specific services offered by the silicon
  5. implementer or platform provider. They are accessed via ``SMC`` ("SMC calls")
  6. instruction executed from Exception Levels below EL3. SMC calls for SiP
  7. services:
  8. - Follow `SMC Calling Convention`_;
  9. - Use SMC function IDs that fall in the SiP range, which are ``0xc2000000`` -
  10. ``0xc200ffff`` for 64-bit calls, and ``0x82000000`` - ``0x8200ffff`` for 32-bit
  11. calls.
  12. The Arm SiP implementation offers the following services:
  13. - Performance Measurement Framework (PMF)
  14. - Execution State Switching service
  15. - DebugFS interface
  16. Source definitions for Arm SiP service are located in the ``arm_sip_svc.h`` header
  17. file.
  18. Performance Measurement Framework (PMF)
  19. ---------------------------------------
  20. The :ref:`Performance Measurement Framework <firmware_design_pmf>`
  21. allows callers to retrieve timestamps captured at various paths in TF-A
  22. execution.
  23. Execution State Switching service
  24. ---------------------------------
  25. Execution State Switching service provides a mechanism for a non-secure lower
  26. Exception Level (either EL2, or NS EL1 if EL2 isn't implemented) to request to
  27. switch its execution state (a.k.a. Register Width), either from AArch64 to
  28. AArch32, or from AArch32 to AArch64, for the calling CPU. This service is only
  29. available when Trusted Firmware-A (TF-A) is built for AArch64 (i.e. when build
  30. option ``ARCH`` is set to ``aarch64``).
  31. ``ARM_SIP_SVC_EXE_STATE_SWITCH``
  32. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33. ::
  34. Arguments:
  35. uint32_t Function ID
  36. uint32_t PC hi
  37. uint32_t PC lo
  38. uint32_t Cookie hi
  39. uint32_t Cookie lo
  40. Return:
  41. uint32_t
  42. The function ID parameter must be ``0x82000020``. It uniquely identifies the
  43. Execution State Switching service being requested.
  44. The parameters *PC hi* and *PC lo* defines upper and lower words, respectively,
  45. of the entry point (physical address) at which execution should start, after
  46. Execution State has been switched. When calling from AArch64, *PC hi* must be 0.
  47. When execution starts at the supplied entry point after Execution State has been
  48. switched, the parameters *Cookie hi* and *Cookie lo* are passed in CPU registers
  49. 0 and 1, respectively. When calling from AArch64, *Cookie hi* must be 0.
  50. This call can only be made on the primary CPU, before any secondaries were
  51. brought up with ``CPU_ON`` PSCI call. Otherwise, the call will always fail.
  52. The effect of switching execution state is as if the Exception Level were
  53. entered for the first time, following power on. This means CPU registers that
  54. have a defined reset value by the Architecture will assume that value. Other
  55. registers should not be expected to hold their values before the call was made.
  56. CPU endianness, however, is preserved from the previous execution state. Note
  57. that this switches the execution state of the calling CPU only. This is not a
  58. substitute for PSCI ``SYSTEM_RESET``.
  59. The service may return the following error codes:
  60. - ``STATE_SW_E_PARAM``: If any of the parameters were deemed invalid for
  61. a specific request.
  62. - ``STATE_SW_E_DENIED``: If the call is not successful, or when TF-A is
  63. built for AArch32.
  64. If the call is successful, the caller wouldn't observe the SMC returning.
  65. Instead, execution starts at the supplied entry point, with the CPU registers 0
  66. and 1 populated with the supplied *Cookie hi* and *Cookie lo* values,
  67. respectively.
  68. DebugFS interface
  69. -----------------
  70. The optional DebugFS interface is accessed through an SMC SiP service. Refer
  71. to the component documentation for details.
  72. String parameters are passed through a shared buffer using a specific union:
  73. .. code:: c
  74. union debugfs_parms {
  75. struct {
  76. char fname[MAX_PATH_LEN];
  77. } open;
  78. struct mount {
  79. char srv[MAX_PATH_LEN];
  80. char where[MAX_PATH_LEN];
  81. char spec[MAX_PATH_LEN];
  82. } mount;
  83. struct {
  84. char path[MAX_PATH_LEN];
  85. dir_t dir;
  86. } stat;
  87. struct {
  88. char oldpath[MAX_PATH_LEN];
  89. char newpath[MAX_PATH_LEN];
  90. } bind;
  91. };
  92. Format of the dir_t structure as such:
  93. .. code:: c
  94. typedef struct {
  95. char name[NAMELEN];
  96. long length;
  97. unsigned char mode;
  98. unsigned char index;
  99. unsigned char dev;
  100. qid_t qid;
  101. } dir_t;
  102. * Identifiers
  103. ======================== =============================================
  104. SMC_OK 0
  105. SMC_UNK -1
  106. DEBUGFS_E_INVALID_PARAMS -2
  107. ======================== =============================================
  108. ======================== =============================================
  109. MOUNT 0
  110. CREATE 1
  111. OPEN 2
  112. CLOSE 3
  113. READ 4
  114. WRITE 5
  115. SEEK 6
  116. BIND 7
  117. STAT 8
  118. INIT 10
  119. VERSION 11
  120. ======================== =============================================
  121. MOUNT
  122. ~~~~~
  123. Description
  124. ^^^^^^^^^^^
  125. This operation mounts a blob of data pointed to by path stored in `src`, at
  126. filesystem location pointed to by path stored in `where`, using driver pointed
  127. to by path in `spec`.
  128. Parameters
  129. ^^^^^^^^^^
  130. ======== ============================================================
  131. uint32_t FunctionID (0x82000030 / 0xC2000030)
  132. uint32_t ``MOUNT``
  133. ======== ============================================================
  134. Return values
  135. ^^^^^^^^^^^^^
  136. =============== ==========================================================
  137. int32_t w0 == SMC_OK on success
  138. w0 == DEBUGFS_E_INVALID_PARAMS if mount operation failed
  139. =============== ==========================================================
  140. OPEN
  141. ~~~~
  142. Description
  143. ^^^^^^^^^^^
  144. This operation opens the file path pointed to by `fname`.
  145. Parameters
  146. ^^^^^^^^^^
  147. ======== ============================================================
  148. uint32_t FunctionID (0x82000030 / 0xC2000030)
  149. uint32_t ``OPEN``
  150. uint32_t mode
  151. ======== ============================================================
  152. mode can be one of:
  153. .. code:: c
  154. enum mode {
  155. O_READ = 1 << 0,
  156. O_WRITE = 1 << 1,
  157. O_RDWR = 1 << 2,
  158. O_BIND = 1 << 3,
  159. O_DIR = 1 << 4,
  160. O_STAT = 1 << 5
  161. };
  162. Return values
  163. ^^^^^^^^^^^^^
  164. =============== ==========================================================
  165. int32_t w0 == SMC_OK on success
  166. w0 == DEBUGFS_E_INVALID_PARAMS if open operation failed
  167. uint32_t w1: file descriptor id on success.
  168. =============== ==========================================================
  169. CLOSE
  170. ~~~~~
  171. Description
  172. ^^^^^^^^^^^
  173. This operation closes a file described by a file descriptor obtained by a
  174. previous call to OPEN.
  175. Parameters
  176. ^^^^^^^^^^
  177. ======== ============================================================
  178. uint32_t FunctionID (0x82000030 / 0xC2000030)
  179. uint32_t ``CLOSE``
  180. uint32_t File descriptor id returned by OPEN
  181. ======== ============================================================
  182. Return values
  183. ^^^^^^^^^^^^^
  184. =============== ==========================================================
  185. int32_t w0 == SMC_OK on success
  186. w0 == DEBUGFS_E_INVALID_PARAMS if close operation failed
  187. =============== ==========================================================
  188. READ
  189. ~~~~
  190. Description
  191. ^^^^^^^^^^^
  192. This operation reads a number of bytes from a file descriptor obtained by
  193. a previous call to OPEN.
  194. Parameters
  195. ^^^^^^^^^^
  196. ======== ============================================================
  197. uint32_t FunctionID (0x82000030 / 0xC2000030)
  198. uint32_t ``READ``
  199. uint32_t File descriptor id returned by OPEN
  200. uint32_t Number of bytes to read
  201. ======== ============================================================
  202. Return values
  203. ^^^^^^^^^^^^^
  204. On success, the read data is retrieved from the shared buffer after the
  205. operation.
  206. =============== ==========================================================
  207. int32_t w0 == SMC_OK on success
  208. w0 == DEBUGFS_E_INVALID_PARAMS if read operation failed
  209. uint32_t w1: number of bytes read on success.
  210. =============== ==========================================================
  211. SEEK
  212. ~~~~
  213. Description
  214. ^^^^^^^^^^^
  215. Move file pointer for file described by given `file descriptor` of given
  216. `offset` related to `whence`.
  217. Parameters
  218. ^^^^^^^^^^
  219. ======== ============================================================
  220. uint32_t FunctionID (0x82000030 / 0xC2000030)
  221. uint32_t ``SEEK``
  222. uint32_t File descriptor id returned by OPEN
  223. sint32_t offset in the file relative to whence
  224. uint32_t whence
  225. ======== ============================================================
  226. whence can be one of:
  227. ========= ============================================================
  228. KSEEK_SET 0
  229. KSEEK_CUR 1
  230. KSEEK_END 2
  231. ========= ============================================================
  232. Return values
  233. ^^^^^^^^^^^^^
  234. =============== ==========================================================
  235. int32_t w0 == SMC_OK on success
  236. w0 == DEBUGFS_E_INVALID_PARAMS if seek operation failed
  237. =============== ==========================================================
  238. BIND
  239. ~~~~
  240. Description
  241. ^^^^^^^^^^^
  242. Create a link from `oldpath` to `newpath`.
  243. Parameters
  244. ^^^^^^^^^^
  245. ======== ============================================================
  246. uint32_t FunctionID (0x82000030 / 0xC2000030)
  247. uint32_t ``BIND``
  248. ======== ============================================================
  249. Return values
  250. ^^^^^^^^^^^^^
  251. =============== ==========================================================
  252. int32_t w0 == SMC_OK on success
  253. w0 == DEBUGFS_E_INVALID_PARAMS if bind operation failed
  254. =============== ==========================================================
  255. STAT
  256. ~~~~
  257. Description
  258. ^^^^^^^^^^^
  259. Perform a stat operation on provided file `name` and returns the directory
  260. entry statistics into `dir`.
  261. Parameters
  262. ^^^^^^^^^^
  263. ======== ============================================================
  264. uint32_t FunctionID (0x82000030 / 0xC2000030)
  265. uint32_t ``STAT``
  266. ======== ============================================================
  267. Return values
  268. ^^^^^^^^^^^^^
  269. =============== ==========================================================
  270. int32_t w0 == SMC_OK on success
  271. w0 == DEBUGFS_E_INVALID_PARAMS if stat operation failed
  272. =============== ==========================================================
  273. INIT
  274. ~~~~
  275. Description
  276. ^^^^^^^^^^^
  277. Initial call to setup the shared exchange buffer. Notice if successful once,
  278. subsequent calls fail after a first initialization. The caller maps the same
  279. page frame in its virtual space and uses this buffer to exchange string
  280. parameters with filesystem primitives.
  281. Parameters
  282. ^^^^^^^^^^
  283. ======== ============================================================
  284. uint32_t FunctionID (0x82000030 / 0xC2000030)
  285. uint32_t ``INIT``
  286. uint64_t Physical address of the shared buffer.
  287. ======== ============================================================
  288. Return values
  289. ^^^^^^^^^^^^^
  290. =============== ======================================================
  291. int32_t w0 == SMC_OK on success
  292. w0 == DEBUGFS_E_INVALID_PARAMS if already initialized,
  293. or internal error occurred.
  294. =============== ======================================================
  295. VERSION
  296. ~~~~~~~
  297. Description
  298. ^^^^^^^^^^^
  299. Returns the debugfs interface version if implemented in TF-A.
  300. Parameters
  301. ^^^^^^^^^^
  302. ======== ============================================================
  303. uint32_t FunctionID (0x82000030 / 0xC2000030)
  304. uint32_t ``VERSION``
  305. ======== ============================================================
  306. Return values
  307. ^^^^^^^^^^^^^
  308. =============== ======================================================
  309. int32_t w0 == SMC_OK on success
  310. w0 == SMC_UNK if interface is not implemented
  311. uint32_t w1: On success, debugfs interface version, 32 bits
  312. value with major version number in upper 16 bits and
  313. minor version in lower 16 bits.
  314. =============== ======================================================
  315. * CREATE(1) and WRITE (5) command identifiers are unimplemented and
  316. return `SMC_UNK`.
  317. --------------
  318. *Copyright (c) 2017-2020, Arm Limited and Contributors. All rights reserved.*
  319. .. _SMC Calling Convention: https://developer.arm.com/docs/den0028/latest