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