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 | |
Manish V Badarkhe | b9dee50 | 2025-05-30 13:17:05 +0100 | [diff] [blame] | 10 | #include <stdbool.h> |
| 11 | #include <stdint.h> |
| 12 | |
Manish V Badarkhe | cf48f49 | 2025-04-15 20:16:32 +0100 | [diff] [blame] | 13 | #include <lib/smccc.h> |
Manish V Badarkhe | b9dee50 | 2025-05-30 13:17:05 +0100 | [diff] [blame] | 14 | #include <services/lfa_component_desc.h> |
| 15 | #include <tools_share/uuid.h> |
Manish V Badarkhe | cf48f49 | 2025-04-15 20:16:32 +0100 | [diff] [blame] | 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 | |
Manish V Badarkhe | b9dee50 | 2025-05-30 13:17:05 +0100 | [diff] [blame] | 53 | #define LFA_INVALID_COMPONENT U(0xFFFFFFFF) |
| 54 | |
Manish V Badarkhe | 06a6f29 | 2025-04-15 20:16:34 +0100 | [diff] [blame] | 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 | |
Manish V Badarkhe | 07de22d | 2025-05-16 15:16:53 +0100 | [diff] [blame] | 60 | #define LFA_SKIP_CPU_RENDEZVOUS_BIT BIT(0) |
| 61 | |
Manish V Badarkhe | cf48f49 | 2025-04-15 20:16:32 +0100 | [diff] [blame] | 62 | /* List of errors as per the specification */ |
| 63 | enum lfa_retc { |
| 64 | LFA_SUCCESS = 0, |
| 65 | LFA_NOT_SUPPORTED = -1, |
| 66 | LFA_BUSY = -2, |
| 67 | LFA_AUTH_ERROR = -3, |
| 68 | LFA_NO_MEMORY = -4, |
| 69 | LFA_CRITICAL_ERROR = -5, |
| 70 | LFA_DEVICE_ERROR = -6, |
| 71 | LFA_WRONG_STATE = -7, |
| 72 | LFA_INVALID_PARAMETERS = -8, |
| 73 | LFA_COMPONENT_WRONG_STATE = -9, |
| 74 | LFA_INVALID_ADDRESS = -10, |
| 75 | LFA_ACTIVATION_FAILED = -11, |
| 76 | }; |
| 77 | |
| 78 | /* Initialization routine for the LFA service */ |
| 79 | int lfa_setup(void); |
| 80 | |
| 81 | uint64_t lfa_smc_handler(uint32_t smc_fid, u_register_t x1, u_register_t x2, |
| 82 | u_register_t x3, u_register_t x4, void *cookie, |
| 83 | void *handle, u_register_t flags); |
Manish V Badarkhe | b9dee50 | 2025-05-30 13:17:05 +0100 | [diff] [blame] | 84 | void lfa_reset_activation(void); |
Manish V Badarkhe | cf48f49 | 2025-04-15 20:16:32 +0100 | [diff] [blame] | 85 | |
| 86 | #endif /* LFA_SVC_H */ |