blob: a0255f2b3637ab8fcb0d7d337097ed8d3d0296d8 [file] [log] [blame]
Manish V Badarkhecf48f492025-04-15 20:16:32 +01001/*
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 Badarkheb9dee502025-05-30 13:17:05 +010010#include <stdbool.h>
11#include <stdint.h>
12
Manish V Badarkhecf48f492025-04-15 20:16:32 +010013#include <lib/smccc.h>
Manish V Badarkheb9dee502025-05-30 13:17:05 +010014#include <services/lfa_component_desc.h>
15#include <tools_share/uuid.h>
Manish V Badarkhecf48f492025-04-15 20:16:32 +010016
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 Badarkheb9dee502025-05-30 13:17:05 +010053#define LFA_INVALID_COMPONENT U(0xFFFFFFFF)
54
Manish V Badarkhecf48f492025-04-15 20:16:32 +010055/* List of errors as per the specification */
56enum lfa_retc {
57 LFA_SUCCESS = 0,
58 LFA_NOT_SUPPORTED = -1,
59 LFA_BUSY = -2,
60 LFA_AUTH_ERROR = -3,
61 LFA_NO_MEMORY = -4,
62 LFA_CRITICAL_ERROR = -5,
63 LFA_DEVICE_ERROR = -6,
64 LFA_WRONG_STATE = -7,
65 LFA_INVALID_PARAMETERS = -8,
66 LFA_COMPONENT_WRONG_STATE = -9,
67 LFA_INVALID_ADDRESS = -10,
68 LFA_ACTIVATION_FAILED = -11,
69};
70
71/* Initialization routine for the LFA service */
72int lfa_setup(void);
73
74uint64_t lfa_smc_handler(uint32_t smc_fid, u_register_t x1, u_register_t x2,
75 u_register_t x3, u_register_t x4, void *cookie,
76 void *handle, u_register_t flags);
Manish V Badarkheb9dee502025-05-30 13:17:05 +010077void lfa_reset_activation(void);
Manish V Badarkhecf48f492025-04-15 20:16:32 +010078
79#endif /* LFA_SVC_H */