1 /* 2 * Copyright (c) 2025, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef LFA_SVC_H 8 #define LFA_SVC_H 9 10 #include <stdbool.h> 11 #include <stdint.h> 12 13 #include <lib/smccc.h> 14 #include <services/lfa_component_desc.h> 15 #include <tools_share/uuid.h> 16 17 /* 18 * SMC function IDs for LFA Service 19 * Upper word bits set: Fast call, SMC64, Standard Secure Svc. Call (OEN = 4) 20 */ 21 #define LFA_FID(func_num) \ 22 ((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \ 23 (SMC_64 << FUNCID_CC_SHIFT) | \ 24 (OEN_STD_START << FUNCID_OEN_SHIFT) | \ 25 ((func_num) << FUNCID_NUM_SHIFT)) 26 27 #define LFA_VERSION LFA_FID(0x2E0) 28 #define LFA_FEATURES LFA_FID(0x2E1) 29 #define LFA_GET_INFO LFA_FID(0x2E2) 30 #define LFA_GET_INVENTORY LFA_FID(0x2E3) 31 #define LFA_PRIME LFA_FID(0x2E4) 32 #define LFA_ACTIVATE LFA_FID(0x2E5) 33 #define LFA_CANCEL LFA_FID(0x2E6) 34 35 /* Check whether FID is in the range */ 36 #define is_lfa_fid(_fid) \ 37 ((_fid >= LFA_VERSION) && (_fid <= LFA_CANCEL)) 38 39 /* LFA Service Calls version numbers */ 40 #define LFA_VERSION_MAJOR U(1) 41 #define LFA_VERSION_MAJOR_SHIFT 16 42 #define LFA_VERSION_MAJOR_MASK U(0x7FFF) 43 #define LFA_VERSION_MINOR U(0) 44 #define LFA_VERSION_MINOR_SHIFT 0 45 #define LFA_VERSION_MINOR_MASK U(0xFFFF) 46 47 #define LFA_VERSION_VAL \ 48 ((((LFA_VERSION_MAJOR) & LFA_VERSION_MAJOR_MASK) << \ 49 LFA_VERSION_MAJOR_SHIFT) \ 50 | (((LFA_VERSION_MINOR) & LFA_VERSION_MINOR_MASK) << \ 51 LFA_VERSION_MINOR_SHIFT)) 52 53 #define LFA_INVALID_COMPONENT U(0xFFFFFFFF) 54 55 #define LFA_ACTIVATION_CAPABLE_SHIFT 0 56 #define LFA_ACTIVATION_PENDING_SHIFT 1 57 #define LFA_MAY_RESET_CPU_SHIFT 2 58 #define LFA_CPU_RENDEZVOUS_OPTIONAL_SHIFT 3 59 60 #define LFA_SKIP_CPU_RENDEZVOUS_BIT BIT(0) 61 62 #define LFA_CALL_AGAIN ULL(1) 63 64 /* List of errors as per the specification */ 65 enum lfa_retc { 66 LFA_SUCCESS = 0, 67 LFA_NOT_SUPPORTED = -1, 68 LFA_BUSY = -2, 69 LFA_AUTH_ERROR = -3, 70 LFA_NO_MEMORY = -4, 71 LFA_CRITICAL_ERROR = -5, 72 LFA_DEVICE_ERROR = -6, 73 LFA_WRONG_STATE = -7, 74 LFA_INVALID_PARAMETERS = -8, 75 LFA_COMPONENT_WRONG_STATE = -9, 76 LFA_INVALID_ADDRESS = -10, 77 LFA_ACTIVATION_FAILED = -11, 78 }; 79 80 /* Initialization routine for the LFA service */ 81 int lfa_setup(void); 82 83 uint64_t lfa_smc_handler(uint32_t smc_fid, u_register_t x1, u_register_t x2, 84 u_register_t x3, u_register_t x4, void *cookie, 85 void *handle, u_register_t flags); 86 void lfa_reset_activation(void); 87 bool lfa_is_prime_complete(uint32_t lfa_component_id); 88 89 #endif /* LFA_SVC_H */ 90