1 /* 2 * Copyright (c) 2024, STMicroelectronics - All Rights Reserved 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <stdbool.h> 8 #include <stdint.h> 9 10 #include <common/debug.h> 11 #include <common/runtime_svc.h> 12 #include <lib/mmio.h> 13 14 #include <stm32mp2_smc.h> 15 #include <stm32mp_svc_setup.h> 16 17 #include "stgen_svc.h" 18 19 /* 20 * Platform-level Standard Service SIP SMC handler. This handler will dispatch 21 * the SMC to the correct feature handler. 22 */ 23 void plat_svc_smc_handler(uint32_t smc_fid, u_register_t x1, 24 u_register_t x2, u_register_t x3, 25 u_register_t x4, uint32_t *ret1, 26 uint32_t *ret2, bool *ret2_enabled, 27 u_register_t flags) 28 { 29 switch (smc_fid) { 30 case STM32_SIP_SVC_CALL_COUNT: 31 *ret1 = STM32_COMMON_SIP_NUM_CALLS; 32 break; 33 case STM32_SIP_SMC_STGEN_SET_RATE: 34 if (!is_caller_secure(flags)) { 35 *ret1 = STM32_SMC_FAILED; 36 break; 37 } 38 39 *ret1 = stgen_svc_handler(); 40 break; 41 default: 42 WARN("Unimplemented STM32MP2 Service Call: 0x%x\n", smc_fid); 43 *ret1 = STM32_SMC_NOT_SUPPORTED; 44 break; 45 } 46 } 47