Manish V Badarkhe | cf48f49 | 2025-04-15 20:16:32 +0100 | [diff] [blame^] | 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 <lib/smccc.h> |
| 11 | |
| 12 | /* |
| 13 | * SMC function IDs for LFA Service |
| 14 | * Upper word bits set: Fast call, SMC64, Standard Secure Svc. Call (OEN = 4) |
| 15 | */ |
| 16 | #define LFA_FID(func_num) \ |
| 17 | ((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \ |
| 18 | (SMC_64 << FUNCID_CC_SHIFT) | \ |
| 19 | (OEN_STD_START << FUNCID_OEN_SHIFT) | \ |
| 20 | ((func_num) << FUNCID_NUM_SHIFT)) |
| 21 | |
| 22 | #define LFA_VERSION LFA_FID(0x2E0) |
| 23 | #define LFA_FEATURES LFA_FID(0x2E1) |
| 24 | #define LFA_GET_INFO LFA_FID(0x2E2) |
| 25 | #define LFA_GET_INVENTORY LFA_FID(0x2E3) |
| 26 | #define LFA_PRIME LFA_FID(0x2E4) |
| 27 | #define LFA_ACTIVATE LFA_FID(0x2E5) |
| 28 | #define LFA_CANCEL LFA_FID(0x2E6) |
| 29 | |
| 30 | /* Check whether FID is in the range */ |
| 31 | #define is_lfa_fid(_fid) \ |
| 32 | ((_fid >= LFA_VERSION) && (_fid <= LFA_CANCEL)) |
| 33 | |
| 34 | /* LFA Service Calls version numbers */ |
| 35 | #define LFA_VERSION_MAJOR U(1) |
| 36 | #define LFA_VERSION_MAJOR_SHIFT 16 |
| 37 | #define LFA_VERSION_MAJOR_MASK U(0x7FFF) |
| 38 | #define LFA_VERSION_MINOR U(0) |
| 39 | #define LFA_VERSION_MINOR_SHIFT 0 |
| 40 | #define LFA_VERSION_MINOR_MASK U(0xFFFF) |
| 41 | |
| 42 | #define LFA_VERSION_VAL \ |
| 43 | ((((LFA_VERSION_MAJOR) & LFA_VERSION_MAJOR_MASK) << \ |
| 44 | LFA_VERSION_MAJOR_SHIFT) \ |
| 45 | | (((LFA_VERSION_MINOR) & LFA_VERSION_MINOR_MASK) << \ |
| 46 | LFA_VERSION_MINOR_SHIFT)) |
| 47 | |
| 48 | /* List of errors as per the specification */ |
| 49 | enum lfa_retc { |
| 50 | LFA_SUCCESS = 0, |
| 51 | LFA_NOT_SUPPORTED = -1, |
| 52 | LFA_BUSY = -2, |
| 53 | LFA_AUTH_ERROR = -3, |
| 54 | LFA_NO_MEMORY = -4, |
| 55 | LFA_CRITICAL_ERROR = -5, |
| 56 | LFA_DEVICE_ERROR = -6, |
| 57 | LFA_WRONG_STATE = -7, |
| 58 | LFA_INVALID_PARAMETERS = -8, |
| 59 | LFA_COMPONENT_WRONG_STATE = -9, |
| 60 | LFA_INVALID_ADDRESS = -10, |
| 61 | LFA_ACTIVATION_FAILED = -11, |
| 62 | }; |
| 63 | |
| 64 | /* Initialization routine for the LFA service */ |
| 65 | int lfa_setup(void); |
| 66 | |
| 67 | uint64_t lfa_smc_handler(uint32_t smc_fid, u_register_t x1, u_register_t x2, |
| 68 | u_register_t x3, u_register_t x4, void *cookie, |
| 69 | void *handle, u_register_t flags); |
| 70 | |
| 71 | #endif /* LFA_SVC_H */ |