blob: 23fe6c01cfada678e785c79b76daa4608c6e433d [file] [log] [blame]
Soby Mathewb4c6df42022-11-09 11:13:29 +00001/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4 */
5
6#ifndef ARCH_FEATURES_H
7#define ARCH_FEATURES_H
8
9#include <arch_helpers.h>
10#include <stdbool.h>
11
12static inline bool is_armv8_4_ttst_present(void)
13{
AlexeiFedorov537bee02023-02-02 13:38:23 +000014 return (EXTRACT(ID_AA64MMFR2_EL1_ST,
15 read_id_aa64mmfr2_el1()) == 1U);
Soby Mathewb4c6df42022-11-09 11:13:29 +000016}
17
18/*
19 * Check if SVE is enabled
20 * ID_AA64PFR0_EL1.SVE, bits [35:32]:
21 * 0b0000 SVE architectural state and programmers' model are not implemented.
22 * 0b0001 SVE architectural state and programmers' model are implemented.
23 */
24static inline bool is_feat_sve_present(void)
25{
AlexeiFedorov537bee02023-02-02 13:38:23 +000026 return (EXTRACT(ID_AA64PFR0_EL1_SVE,
27 read_id_aa64pfr0_el1()) != 0UL);
Soby Mathewb4c6df42022-11-09 11:13:29 +000028}
29
30/*
31 * Check if RNDR is available
32 */
33static inline bool is_feat_rng_present(void)
34{
AlexeiFedorov537bee02023-02-02 13:38:23 +000035 return (EXTRACT(ID_AA64ISAR0_EL1_RNDR,
36 read_id_aa64isar0_el1()) != 0UL);
Soby Mathewb4c6df42022-11-09 11:13:29 +000037}
38
39/*
40 * Check if FEAT_VMID16 is implemented
41 * ID_AA64MMFR1_EL1.VMIDBits, bits [7:4]:
42 * 0b0000 8 bits.
43 * 0b0010 16 bits.
44 * All other values are reserved.
45 */
46static inline bool is_feat_vmid16_present(void)
47{
AlexeiFedorov537bee02023-02-02 13:38:23 +000048 return (EXTRACT(ID_AA64MMFR1_EL1_VMIDBits,
49 read_id_aa64mmfr1_el1()) == ID_AA64MMFR1_EL1_VMIDBits_16);
Soby Mathewb4c6df42022-11-09 11:13:29 +000050}
51
52/*
53 * Check if FEAT_LPA2 is implemented.
54 * 4KB granule at stage 2 supports 52-bit input and output addresses:
55 * ID_AA64MMFR0_EL1.TGran4_2 bits [43:40]: 0b0011
56 */
57static inline bool is_feat_lpa2_4k_present(void)
58{
AlexeiFedorov537bee02023-02-02 13:38:23 +000059 return (EXTRACT(ID_AA64MMFR0_EL1_TGRAN4_2,
60 read_id_aa64mmfr0_el1()) == ID_AA64MMFR0_EL1_TGRAN4_2_LPA2);
Soby Mathewb4c6df42022-11-09 11:13:29 +000061}
62
63unsigned int arch_feat_get_pa_width(void);
64
65#endif /* ARCH_FEATURES_H */