xref: /rk3399_ARM-atf/docs/components/arm-sip-service.rst (revision 40d553cfde38d4f68449c62967cd1ce0d6478750)
1*40d553cfSPaul BeesleyArm SiP Service
2*40d553cfSPaul Beesley===============
3*40d553cfSPaul Beesley
4*40d553cfSPaul BeesleyThis document enumerates and describes the Arm SiP (Silicon Provider) services.
5*40d553cfSPaul Beesley
6*40d553cfSPaul BeesleySiP services are non-standard, platform-specific services offered by the silicon
7*40d553cfSPaul Beesleyimplementer or platform provider. They are accessed via ``SMC`` ("SMC calls")
8*40d553cfSPaul Beesleyinstruction executed from Exception Levels below EL3. SMC calls for SiP
9*40d553cfSPaul Beesleyservices:
10*40d553cfSPaul Beesley
11*40d553cfSPaul Beesley-  Follow `SMC Calling Convention`_;
12*40d553cfSPaul Beesley-  Use SMC function IDs that fall in the SiP range, which are ``0xc2000000`` -
13*40d553cfSPaul Beesley   ``0xc200ffff`` for 64-bit calls, and ``0x82000000`` - ``0x8200ffff`` for 32-bit
14*40d553cfSPaul Beesley   calls.
15*40d553cfSPaul Beesley
16*40d553cfSPaul BeesleyThe Arm SiP implementation offers the following services:
17*40d553cfSPaul Beesley
18*40d553cfSPaul Beesley-  Performance Measurement Framework (PMF)
19*40d553cfSPaul Beesley-  Execution State Switching service
20*40d553cfSPaul Beesley
21*40d553cfSPaul BeesleySource definitions for Arm SiP service are located in the ``arm_sip_svc.h`` header
22*40d553cfSPaul Beesleyfile.
23*40d553cfSPaul Beesley
24*40d553cfSPaul BeesleyPerformance Measurement Framework (PMF)
25*40d553cfSPaul Beesley---------------------------------------
26*40d553cfSPaul Beesley
27*40d553cfSPaul BeesleyThe `Performance Measurement Framework`_
28*40d553cfSPaul Beesleyallows callers to retrieve timestamps captured at various paths in TF-A
29*40d553cfSPaul Beesleyexecution. It's described in detail in `Firmware Design document`_.
30*40d553cfSPaul Beesley
31*40d553cfSPaul BeesleyExecution State Switching service
32*40d553cfSPaul Beesley---------------------------------
33*40d553cfSPaul Beesley
34*40d553cfSPaul BeesleyExecution State Switching service provides a mechanism for a non-secure lower
35*40d553cfSPaul BeesleyException Level (either EL2, or NS EL1 if EL2 isn't implemented) to request to
36*40d553cfSPaul Beesleyswitch its execution state (a.k.a. Register Width), either from AArch64 to
37*40d553cfSPaul BeesleyAArch32, or from AArch32 to AArch64, for the calling CPU. This service is only
38*40d553cfSPaul Beesleyavailable when Trusted Firmware-A (TF-A) is built for AArch64 (i.e. when build
39*40d553cfSPaul Beesleyoption ``ARCH`` is set to ``aarch64``).
40*40d553cfSPaul Beesley
41*40d553cfSPaul Beesley``ARM_SIP_SVC_EXE_STATE_SWITCH``
42*40d553cfSPaul Beesley~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43*40d553cfSPaul Beesley
44*40d553cfSPaul Beesley::
45*40d553cfSPaul Beesley
46*40d553cfSPaul Beesley    Arguments:
47*40d553cfSPaul Beesley        uint32_t Function ID
48*40d553cfSPaul Beesley        uint32_t PC hi
49*40d553cfSPaul Beesley        uint32_t PC lo
50*40d553cfSPaul Beesley        uint32_t Cookie hi
51*40d553cfSPaul Beesley        uint32_t Cookie lo
52*40d553cfSPaul Beesley
53*40d553cfSPaul Beesley    Return:
54*40d553cfSPaul Beesley        uint32_t
55*40d553cfSPaul Beesley
56*40d553cfSPaul BeesleyThe function ID parameter must be ``0x82000020``. It uniquely identifies the
57*40d553cfSPaul BeesleyExecution State Switching service being requested.
58*40d553cfSPaul Beesley
59*40d553cfSPaul BeesleyThe parameters *PC hi* and *PC lo* defines upper and lower words, respectively,
60*40d553cfSPaul Beesleyof the entry point (physical address) at which execution should start, after
61*40d553cfSPaul BeesleyExecution State has been switched. When calling from AArch64, *PC hi* must be 0.
62*40d553cfSPaul Beesley
63*40d553cfSPaul BeesleyWhen execution starts at the supplied entry point after Execution State has been
64*40d553cfSPaul Beesleyswitched, the parameters *Cookie hi* and *Cookie lo* are passed in CPU registers
65*40d553cfSPaul Beesley0 and 1, respectively. When calling from AArch64, *Cookie hi* must be 0.
66*40d553cfSPaul Beesley
67*40d553cfSPaul BeesleyThis call can only be made on the primary CPU, before any secondaries were
68*40d553cfSPaul Beesleybrought up with ``CPU_ON`` PSCI call. Otherwise, the call will always fail.
69*40d553cfSPaul Beesley
70*40d553cfSPaul BeesleyThe effect of switching execution state is as if the Exception Level were
71*40d553cfSPaul Beesleyentered for the first time, following power on. This means CPU registers that
72*40d553cfSPaul Beesleyhave a defined reset value by the Architecture will assume that value. Other
73*40d553cfSPaul Beesleyregisters should not be expected to hold their values before the call was made.
74*40d553cfSPaul BeesleyCPU endianness, however, is preserved from the previous execution state. Note
75*40d553cfSPaul Beesleythat this switches the execution state of the calling CPU only. This is not a
76*40d553cfSPaul Beesleysubstitute for PSCI ``SYSTEM_RESET``.
77*40d553cfSPaul Beesley
78*40d553cfSPaul BeesleyThe service may return the following error codes:
79*40d553cfSPaul Beesley
80*40d553cfSPaul Beesley-  ``STATE_SW_E_PARAM``: If any of the parameters were deemed invalid for
81*40d553cfSPaul Beesley   a specific request.
82*40d553cfSPaul Beesley-  ``STATE_SW_E_DENIED``: If the call is not successful, or when TF-A is
83*40d553cfSPaul Beesley   built for AArch32.
84*40d553cfSPaul Beesley
85*40d553cfSPaul BeesleyIf the call is successful, the caller wouldn't observe the SMC returning.
86*40d553cfSPaul BeesleyInstead, execution starts at the supplied entry point, with the CPU registers 0
87*40d553cfSPaul Beesleyand 1 populated with the supplied *Cookie hi* and *Cookie lo* values,
88*40d553cfSPaul Beesleyrespectively.
89*40d553cfSPaul Beesley
90*40d553cfSPaul Beesley--------------
91*40d553cfSPaul Beesley
92*40d553cfSPaul Beesley*Copyright (c) 2017-2018, Arm Limited and Contributors. All rights reserved.*
93*40d553cfSPaul Beesley
94*40d553cfSPaul Beesley.. _SMC Calling Convention: http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html
95*40d553cfSPaul Beesley.. _Performance Measurement Framework: ./firmware-design.rst#user-content-performance-measurement-framework
96*40d553cfSPaul Beesley.. _Firmware Design document: ./firmware-design.rst
97