arm-sip-service.rst 12.3 KB
Newer Older
Paul Beesley's avatar
Paul Beesley committed
1
2
Arm SiP Services
================
3

Dan Handley's avatar
Dan Handley committed
4
This document enumerates and describes the Arm SiP (Silicon Provider) services.
5
6

SiP services are non-standard, platform-specific services offered by the silicon
7
implementer or platform provider. They are accessed via ``SMC`` ("SMC calls")
8
9
10
11
12
13
14
15
instruction executed from Exception Levels below EL3. SMC calls for SiP
services:

-  Follow `SMC Calling Convention`_;
-  Use SMC function IDs that fall in the SiP range, which are ``0xc2000000`` -
   ``0xc200ffff`` for 64-bit calls, and ``0x82000000`` - ``0x8200ffff`` for 32-bit
   calls.

Dan Handley's avatar
Dan Handley committed
16
The Arm SiP implementation offers the following services:
17
18
19

-  Performance Measurement Framework (PMF)
-  Execution State Switching service
Ambroise Vincent's avatar
Ambroise Vincent committed
20
-  DebugFS interface
21

Dan Handley's avatar
Dan Handley committed
22
Source definitions for Arm SiP service are located in the ``arm_sip_svc.h`` header
23
24
25
26
27
file.

Performance Measurement Framework (PMF)
---------------------------------------

28
The :ref:`Performance Measurement Framework <firmware_design_pmf>`
Dan Handley's avatar
Dan Handley committed
29
allows callers to retrieve timestamps captured at various paths in TF-A
30
execution.
31
32
33
34
35
36
37
38

Execution State Switching service
---------------------------------

Execution State Switching service provides a mechanism for a non-secure lower
Exception Level (either EL2, or NS EL1 if EL2 isn't implemented) to request to
switch its execution state (a.k.a. Register Width), either from AArch64 to
AArch32, or from AArch32 to AArch64, for the calling CPU. This service is only
Dan Handley's avatar
Dan Handley committed
39
40
available when Trusted Firmware-A (TF-A) is built for AArch64 (i.e. when build
option ``ARCH`` is set to ``aarch64``).
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

``ARM_SIP_SVC_EXE_STATE_SWITCH``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

::

    Arguments:
        uint32_t Function ID
        uint32_t PC hi
        uint32_t PC lo
        uint32_t Cookie hi
        uint32_t Cookie lo

    Return:
        uint32_t

The function ID parameter must be ``0x82000020``. It uniquely identifies the
Execution State Switching service being requested.

The parameters *PC hi* and *PC lo* defines upper and lower words, respectively,
of the entry point (physical address) at which execution should start, after
Execution State has been switched. When calling from AArch64, *PC hi* must be 0.

When execution starts at the supplied entry point after Execution State has been
switched, the parameters *Cookie hi* and *Cookie lo* are passed in CPU registers
0 and 1, respectively. When calling from AArch64, *Cookie hi* must be 0.

This call can only be made on the primary CPU, before any secondaries were
brought up with ``CPU_ON`` PSCI call. Otherwise, the call will always fail.

The effect of switching execution state is as if the Exception Level were
entered for the first time, following power on. This means CPU registers that
have a defined reset value by the Architecture will assume that value. Other
registers should not be expected to hold their values before the call was made.
CPU endianness, however, is preserved from the previous execution state. Note
that this switches the execution state of the calling CPU only. This is not a
substitute for PSCI ``SYSTEM_RESET``.

The service may return the following error codes:

-  ``STATE_SW_E_PARAM``: If any of the parameters were deemed invalid for
   a specific request.
Dan Handley's avatar
Dan Handley committed
83
84
-  ``STATE_SW_E_DENIED``: If the call is not successful, or when TF-A is
   built for AArch32.
85
86
87
88
89
90

If the call is successful, the caller wouldn't observe the SMC returning.
Instead, execution starts at the supplied entry point, with the CPU registers 0
and 1 populated with the supplied *Cookie hi* and *Cookie lo* values,
respectively.

Ambroise Vincent's avatar
Ambroise Vincent committed
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
DebugFS interface
-----------------

The optional DebugFS interface is accessed through an SMC SiP service. Refer
to the component documentation for details.

String parameters are passed through a shared buffer using a specific union:

.. code:: c

    union debugfs_parms {
        struct {
            char fname[MAX_PATH_LEN];
        } open;

        struct mount {
            char srv[MAX_PATH_LEN];
            char where[MAX_PATH_LEN];
            char spec[MAX_PATH_LEN];
        } mount;

        struct {
            char path[MAX_PATH_LEN];
            dir_t dir;
        } stat;

        struct {
            char oldpath[MAX_PATH_LEN];
            char newpath[MAX_PATH_LEN];
        } bind;
    };

Format of the dir_t structure as such:

.. code:: c

    typedef struct {
        char		name[NAMELEN];
        long		length;
        unsigned char	mode;
        unsigned char	index;
        unsigned char	dev;
        qid_t		qid;
    } dir_t;


* Identifiers

======================== =============================================
SMC_OK                   0
SMC_UNK                  -1
DEBUGFS_E_INVALID_PARAMS -2
======================== =============================================

======================== =============================================
MOUNT                    0
CREATE                   1
OPEN                     2
CLOSE                    3
READ                     4
WRITE                    5
SEEK                     6
BIND                     7
STAT                     8
INIT                     10
VERSION                  11
======================== =============================================

MOUNT
~~~~~

Description
^^^^^^^^^^^
This operation mounts a blob of data pointed to by path stored in `src`, at
filesystem location pointed to by path stored in `where`, using driver pointed
to by path in `spec`.

Parameters
^^^^^^^^^^
======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``MOUNT``
======== ============================================================

Return values
^^^^^^^^^^^^^

=============== ==========================================================
int32_t         w0 == SMC_OK on success

                w0 == DEBUGFS_E_INVALID_PARAMS if mount operation failed
=============== ==========================================================

OPEN
~~~~

Description
^^^^^^^^^^^
This operation opens the file path pointed to by `fname`.

Parameters
^^^^^^^^^^

======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``OPEN``
uint32_t mode
======== ============================================================

mode can be one of:

.. code:: c

    enum mode {
        O_READ   = 1 << 0,
        O_WRITE  = 1 << 1,
        O_RDWR   = 1 << 2,
        O_BIND   = 1 << 3,
        O_DIR    = 1 << 4,
        O_STAT   = 1 << 5
    };

Return values
^^^^^^^^^^^^^

=============== ==========================================================
int32_t         w0 == SMC_OK on success

                w0 == DEBUGFS_E_INVALID_PARAMS if open operation failed

uint32_t        w1: file descriptor id on success.
=============== ==========================================================

CLOSE
~~~~~

Description
^^^^^^^^^^^

This operation closes a file described by a file descriptor obtained by a
previous call to OPEN.

Parameters
^^^^^^^^^^

======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``CLOSE``
uint32_t File descriptor id returned by OPEN
======== ============================================================

Return values
^^^^^^^^^^^^^
=============== ==========================================================
int32_t         w0 == SMC_OK on success

                w0 == DEBUGFS_E_INVALID_PARAMS if close operation failed
=============== ==========================================================

READ
~~~~

Description
^^^^^^^^^^^

This operation reads a number of bytes from a file descriptor obtained by
a previous call to OPEN.

Parameters
^^^^^^^^^^

======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``READ``
uint32_t File descriptor id returned by OPEN
uint32_t Number of bytes to read
======== ============================================================

Return values
^^^^^^^^^^^^^

On success, the read data is retrieved from the shared buffer after the
operation.

=============== ==========================================================
int32_t         w0 == SMC_OK on success

                w0 == DEBUGFS_E_INVALID_PARAMS if read operation failed

uint32_t        w1: number of bytes read on success.
=============== ==========================================================

SEEK
~~~~

Description
^^^^^^^^^^^

Move file pointer for file described by given `file descriptor` of given
`offset` related to `whence`.

Parameters
^^^^^^^^^^

======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``SEEK``
uint32_t File descriptor id returned by OPEN
sint32_t offset in the file relative to whence
uint32_t whence
======== ============================================================

whence can be one of:

========= ============================================================
KSEEK_SET 0
KSEEK_CUR 1
KSEEK_END 2
========= ============================================================

Return values
^^^^^^^^^^^^^

=============== ==========================================================
int32_t         w0 == SMC_OK on success

                w0 == DEBUGFS_E_INVALID_PARAMS if seek operation failed
=============== ==========================================================

BIND
~~~~

Description
^^^^^^^^^^^

Create a link from `oldpath` to `newpath`.

Parameters
^^^^^^^^^^

======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``BIND``
======== ============================================================

Return values
^^^^^^^^^^^^^

=============== ==========================================================
int32_t         w0 == SMC_OK on success

                w0 == DEBUGFS_E_INVALID_PARAMS if bind operation failed
=============== ==========================================================

STAT
~~~~

Description
^^^^^^^^^^^

Perform a stat operation on provided file `name` and returns the directory
entry statistics into `dir`.

Parameters
^^^^^^^^^^

======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``STAT``
======== ============================================================

Return values
^^^^^^^^^^^^^

=============== ==========================================================
int32_t         w0 == SMC_OK on success

                w0 == DEBUGFS_E_INVALID_PARAMS if stat operation failed
=============== ==========================================================

INIT
~~~~

Description
^^^^^^^^^^^
Initial call to setup the shared exchange buffer. Notice if successful once,
subsequent calls fail after a first initialization. The caller maps the same
page frame in its virtual space and uses this buffer to exchange string
parameters with filesystem primitives.

Parameters
^^^^^^^^^^

======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``INIT``
uint64_t Physical address of the shared buffer.
======== ============================================================

Return values
^^^^^^^^^^^^^

=============== ======================================================
int32_t         w0 == SMC_OK on success

                w0 == DEBUGFS_E_INVALID_PARAMS if already initialized,
                or internal error occurred.
=============== ======================================================

VERSION
~~~~~~~

Description
^^^^^^^^^^^
Returns the debugfs interface version if implemented in TF-A.

Parameters
^^^^^^^^^^

======== ============================================================
uint32_t FunctionID (0x82000030 / 0xC2000030)
uint32_t ``VERSION``
======== ============================================================

Return values
^^^^^^^^^^^^^

=============== ======================================================
int32_t         w0 == SMC_OK on success

                w0 == SMC_UNK if interface is not implemented

uint32_t        w1: On success, debugfs interface version, 32 bits
                value with major version number in upper 16 bits and
                minor version in lower 16 bits.
=============== ======================================================

* CREATE(1) and WRITE (5) command identifiers are unimplemented and
  return `SMC_UNK`.

431
432
--------------

433
*Copyright (c) 2017-2020, Arm Limited and Contributors. All rights reserved.*
434

435
.. _SMC Calling Convention: https://developer.arm.com/docs/den0028/latest