blob: 78c739f94b4ddbb245861c101cf45f60517b9635 [file] [log] [blame]
Sona Mathew07384212022-11-28 13:19:11 -06001/*
Arvind Ram Prakash5668f342025-03-04 02:01:16 -06002 * Copyright (c) 2025, Arm Limited. All rights reserved.
Sona Mathew07384212022-11-28 13:19:11 -06003 *
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;
Arvind Ram Prakash5668f342025-03-04 02:01:16 -060052 unsigned int split_wa;
Sona Mathew07384212022-11-28 13:19:11 -060053} em_cpu_errata_t;
54
55typedef struct em_cpu{
56 uint16_t cpu_pn;
57 em_cpu_errata_t cpu_errata[ERRATA_COUNT];
58}em_cpu_t;
59
60extern const em_function_t em_functions[TOTAL_ABI_CALLS];
61int32_t tftf_em_abi_version(void);
62bool tftf_em_abi_feature_implemented(uint32_t id);
63smc_ret_values tftf_em_abi_cpu_feature_implemented(uint32_t cpu_erratum, uint32_t forward_flag);
64
65
66#define IN_RANGE(x, y, z) (((x >= y) && (x <= z)) ? true : false)
67
68/*******************************************************************************
69 * Errata ABI Version
70 ******************************************************************************/
71#define EM_MAJOR_VER_SHIFT (16)
72#define EM_MAJOR_VER_MASK (0xFFFF)
73#define EM_MINOR_VER_SHIFT (0)
74#define EM_MINOR_VER_MASK (0xFFFF)
75#define EM_ABI_VERSION(major, minor) (((major & EM_MAJOR_VER_MASK) << EM_MAJOR_VER_SHIFT) \
76 | ((minor & EM_MINOR_VER_MASK) << EM_MINOR_VER_SHIFT))
77/*******************************************************************************
78 * Error codes
79 ******************************************************************************/
80#define EM_HIGHER_EL_MITIGATION (3)
81#define EM_NOT_AFFECTED (2)
82#define EM_AFFECTED (1)
83#define EM_SUCCESS (0)
84#define EM_NOT_SUPPORTED (-1)
85#define EM_INVALID_PARAMETERS (-2)
86#define EM_UNKNOWN_ERRATUM (-3)
87#endif /* __ERRATA_ABI_H__ */
88