18aa05055SPaul BeesleyArm SiP Services 28aa05055SPaul Beesley================ 340d553cfSPaul Beesley 440d553cfSPaul BeesleyThis document enumerates and describes the Arm SiP (Silicon Provider) services. 540d553cfSPaul Beesley 640d553cfSPaul BeesleySiP services are non-standard, platform-specific services offered by the silicon 740d553cfSPaul Beesleyimplementer or platform provider. They are accessed via ``SMC`` ("SMC calls") 840d553cfSPaul Beesleyinstruction executed from Exception Levels below EL3. SMC calls for SiP 940d553cfSPaul Beesleyservices: 1040d553cfSPaul Beesley 1140d553cfSPaul Beesley- Follow `SMC Calling Convention`_; 1240d553cfSPaul Beesley- Use SMC function IDs that fall in the SiP range, which are ``0xc2000000`` - 1340d553cfSPaul Beesley ``0xc200ffff`` for 64-bit calls, and ``0x82000000`` - ``0x8200ffff`` for 32-bit 1440d553cfSPaul Beesley calls. 1540d553cfSPaul Beesley 1640d553cfSPaul BeesleyThe Arm SiP implementation offers the following services: 1740d553cfSPaul Beesley 1840d553cfSPaul Beesley- Performance Measurement Framework (PMF) 1940d553cfSPaul Beesley- Execution State Switching service 2040d553cfSPaul Beesley 2140d553cfSPaul BeesleySource definitions for Arm SiP service are located in the ``arm_sip_svc.h`` header 2240d553cfSPaul Beesleyfile. 2340d553cfSPaul Beesley 2440d553cfSPaul BeesleyPerformance Measurement Framework (PMF) 2540d553cfSPaul Beesley--------------------------------------- 2640d553cfSPaul Beesley 2734760951SPaul BeesleyThe :ref:`Performance Measurement Framework <firmware_design_pmf>` 2840d553cfSPaul Beesleyallows callers to retrieve timestamps captured at various paths in TF-A 2934760951SPaul Beesleyexecution. 3040d553cfSPaul Beesley 3140d553cfSPaul BeesleyExecution State Switching service 3240d553cfSPaul Beesley--------------------------------- 3340d553cfSPaul Beesley 3440d553cfSPaul BeesleyExecution State Switching service provides a mechanism for a non-secure lower 3540d553cfSPaul BeesleyException Level (either EL2, or NS EL1 if EL2 isn't implemented) to request to 3640d553cfSPaul Beesleyswitch its execution state (a.k.a. Register Width), either from AArch64 to 3740d553cfSPaul BeesleyAArch32, or from AArch32 to AArch64, for the calling CPU. This service is only 3840d553cfSPaul Beesleyavailable when Trusted Firmware-A (TF-A) is built for AArch64 (i.e. when build 3940d553cfSPaul Beesleyoption ``ARCH`` is set to ``aarch64``). 4040d553cfSPaul Beesley 4140d553cfSPaul Beesley``ARM_SIP_SVC_EXE_STATE_SWITCH`` 4240d553cfSPaul Beesley~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4340d553cfSPaul Beesley 4440d553cfSPaul Beesley:: 4540d553cfSPaul Beesley 4640d553cfSPaul Beesley Arguments: 4740d553cfSPaul Beesley uint32_t Function ID 4840d553cfSPaul Beesley uint32_t PC hi 4940d553cfSPaul Beesley uint32_t PC lo 5040d553cfSPaul Beesley uint32_t Cookie hi 5140d553cfSPaul Beesley uint32_t Cookie lo 5240d553cfSPaul Beesley 5340d553cfSPaul Beesley Return: 5440d553cfSPaul Beesley uint32_t 5540d553cfSPaul Beesley 5640d553cfSPaul BeesleyThe function ID parameter must be ``0x82000020``. It uniquely identifies the 5740d553cfSPaul BeesleyExecution State Switching service being requested. 5840d553cfSPaul Beesley 5940d553cfSPaul BeesleyThe parameters *PC hi* and *PC lo* defines upper and lower words, respectively, 6040d553cfSPaul Beesleyof the entry point (physical address) at which execution should start, after 6140d553cfSPaul BeesleyExecution State has been switched. When calling from AArch64, *PC hi* must be 0. 6240d553cfSPaul Beesley 6340d553cfSPaul BeesleyWhen execution starts at the supplied entry point after Execution State has been 6440d553cfSPaul Beesleyswitched, the parameters *Cookie hi* and *Cookie lo* are passed in CPU registers 6540d553cfSPaul Beesley0 and 1, respectively. When calling from AArch64, *Cookie hi* must be 0. 6640d553cfSPaul Beesley 6740d553cfSPaul BeesleyThis call can only be made on the primary CPU, before any secondaries were 6840d553cfSPaul Beesleybrought up with ``CPU_ON`` PSCI call. Otherwise, the call will always fail. 6940d553cfSPaul Beesley 7040d553cfSPaul BeesleyThe effect of switching execution state is as if the Exception Level were 7140d553cfSPaul Beesleyentered for the first time, following power on. This means CPU registers that 7240d553cfSPaul Beesleyhave a defined reset value by the Architecture will assume that value. Other 7340d553cfSPaul Beesleyregisters should not be expected to hold their values before the call was made. 7440d553cfSPaul BeesleyCPU endianness, however, is preserved from the previous execution state. Note 7540d553cfSPaul Beesleythat this switches the execution state of the calling CPU only. This is not a 7640d553cfSPaul Beesleysubstitute for PSCI ``SYSTEM_RESET``. 7740d553cfSPaul Beesley 7840d553cfSPaul BeesleyThe service may return the following error codes: 7940d553cfSPaul Beesley 8040d553cfSPaul Beesley- ``STATE_SW_E_PARAM``: If any of the parameters were deemed invalid for 8140d553cfSPaul Beesley a specific request. 8240d553cfSPaul Beesley- ``STATE_SW_E_DENIED``: If the call is not successful, or when TF-A is 8340d553cfSPaul Beesley built for AArch32. 8440d553cfSPaul Beesley 8540d553cfSPaul BeesleyIf the call is successful, the caller wouldn't observe the SMC returning. 8640d553cfSPaul BeesleyInstead, execution starts at the supplied entry point, with the CPU registers 0 8740d553cfSPaul Beesleyand 1 populated with the supplied *Cookie hi* and *Cookie lo* values, 8840d553cfSPaul Beesleyrespectively. 8940d553cfSPaul Beesley 9040d553cfSPaul Beesley-------------- 9140d553cfSPaul Beesley 92*273b8983SGovindraj Raja*Copyright (c) 2017-2024, Arm Limited and Contributors. All rights reserved.* 9340d553cfSPaul Beesley 943ba55a3cSlaurenw-arm.. _SMC Calling Convention: https://developer.arm.com/docs/den0028/latest 95