blob: dc50113aec0ad82212dd3a13631da998e3ae4b52 [file] [log] [blame]
Sona Mathew07384212022-11-28 13:19:11 -06001/*
2 * Copyright (c) 2023, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7/*
8 * Definitions related to the Errata ABI feature
9 * as per the SMC Calling Convention.
10 */
11
12#ifndef __ERRATA_ABI_H__
13#define __ERRATA_ABI_H__
14
15#ifndef __ASSEMBLY__
16#include <stdbool.h>
17#include <stdint.h>
18#include <tftf_lib.h>
19#include <platform_def.h>
20#endif
21
22/*******************************************************************************
23 * Macro to create the array entry for EM_ABI_functions[]
24 ******************************************************************************/
25#define DEFINE_EM_FUNC(_func_id, _mandatory) \
26 { EM_##_func_id, _mandatory, "SMC_" # _func_id }
27
28/*******************************************************************************
29 * Errata ABI feature supported function ids
30 ******************************************************************************/
31#define EM_VERSION 0x840000F0
32#define EM_FEATURES 0x840000F1
33#define EM_CPU_ERRATUM_FEATURES 0x840000F2
34
35/*
36 * Number of EM ABI calls defined in the specification.
37 */
38#define TOTAL_ABI_CALLS (3U)
39
Sona Mathew7bb1c842024-02-15 14:14:59 -060040#define ERRATA_COUNT (32U)
Sona Mathew07384212022-11-28 13:19:11 -060041
42typedef struct {
43 uint32_t id;
44 bool mandatory;
45 const char *str;
46} em_function_t;
47
48typedef struct em_cpu_errata {
49 int em_errata_id;
50 unsigned int rxpx_low;
51 unsigned int rxpx_high;
52} em_cpu_errata_t;
53
54typedef struct em_cpu{
55 uint16_t cpu_pn;
56 em_cpu_errata_t cpu_errata[ERRATA_COUNT];
57}em_cpu_t;
58
59extern const em_function_t em_functions[TOTAL_ABI_CALLS];
60int32_t tftf_em_abi_version(void);
61bool tftf_em_abi_feature_implemented(uint32_t id);
62smc_ret_values tftf_em_abi_cpu_feature_implemented(uint32_t cpu_erratum, uint32_t forward_flag);
63
64
65#define IN_RANGE(x, y, z) (((x >= y) && (x <= z)) ? true : false)
66
67/*******************************************************************************
68 * Errata ABI Version
69 ******************************************************************************/
70#define EM_MAJOR_VER_SHIFT (16)
71#define EM_MAJOR_VER_MASK (0xFFFF)
72#define EM_MINOR_VER_SHIFT (0)
73#define EM_MINOR_VER_MASK (0xFFFF)
74#define EM_ABI_VERSION(major, minor) (((major & EM_MAJOR_VER_MASK) << EM_MAJOR_VER_SHIFT) \
75 | ((minor & EM_MINOR_VER_MASK) << EM_MINOR_VER_SHIFT))
76/*******************************************************************************
77 * Error codes
78 ******************************************************************************/
79#define EM_HIGHER_EL_MITIGATION (3)
80#define EM_NOT_AFFECTED (2)
81#define EM_AFFECTED (1)
82#define EM_SUCCESS (0)
83#define EM_NOT_SUPPORTED (-1)
84#define EM_INVALID_PARAMETERS (-2)
85#define EM_UNKNOWN_ERRATUM (-3)
86#endif /* __ERRATA_ABI_H__ */
87