blob: 1129b8e432995ab175223dc4ac63e69aa3d58ba6 [file] [log] [blame]
Antonio Nino Diazc326c342019-01-11 11:20:10 +00001/*
2 * Copyright (c) 2019, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef ARCH_FEATURES_H
8#define ARCH_FEATURES_H
9
10#include <stdbool.h>
11
12#include <arch_helpers.h>
13
Antonio Nino Diazd29d21e2019-02-06 09:23:04 +000014static inline bool is_armv7_gentimer_present(void)
15{
16 /* The Generic Timer is always present in an ARMv8-A implementation */
17 return true;
18}
19
Antonio Nino Diazc326c342019-01-11 11:20:10 +000020static inline bool is_armv8_2_ttcnp_present(void)
21{
22 return ((read_id_aa64mmfr2_el1() >> ID_AA64MMFR2_EL1_CNP_SHIFT) &
23 ID_AA64MMFR2_EL1_CNP_MASK) != 0U;
24}
25
Antonio Nino Diaz25cda672019-02-19 11:53:51 +000026static inline bool is_armv8_3_pauth_present(void)
27{
28 uint64_t mask = (ID_AA64ISAR1_GPI_MASK << ID_AA64ISAR1_GPI_SHIFT) |
29 (ID_AA64ISAR1_GPA_MASK << ID_AA64ISAR1_GPA_SHIFT) |
30 (ID_AA64ISAR1_API_MASK << ID_AA64ISAR1_API_SHIFT) |
31 (ID_AA64ISAR1_APA_MASK << ID_AA64ISAR1_APA_SHIFT);
32
33 /* If any of the fields is not zero, PAuth is present */
34 return (read_id_aa64isar1_el1() & mask) != 0U;
35}
36
Antonio Nino Diaze1e78452019-03-01 09:35:26 +000037static inline bool is_armv8_3_pauth_apa_api_present(void)
Antonio Nino Diaz25cda672019-02-19 11:53:51 +000038{
Antonio Nino Diaze1e78452019-03-01 09:35:26 +000039 uint64_t mask = (ID_AA64ISAR1_API_MASK << ID_AA64ISAR1_API_SHIFT) |
40 (ID_AA64ISAR1_APA_MASK << ID_AA64ISAR1_APA_SHIFT);
41
42 return (read_id_aa64isar1_el1() & mask) != 0U;
Antonio Nino Diaz25cda672019-02-19 11:53:51 +000043}
44
Sathees Balya74155972019-01-25 11:36:01 +000045static inline bool is_armv8_4_ttst_present(void)
46{
47 return ((read_id_aa64mmfr2_el1() >> ID_AA64MMFR2_EL1_ST_SHIFT) &
48 ID_AA64MMFR2_EL1_ST_MASK) == 1U;
49}
50
Alexei Fedorov90f2e882019-05-24 12:17:09 +010051static inline bool is_armv8_5_bti_present(void)
52{
53 return ((read_id_aa64pfr1_el1() >> ID_AA64PFR1_EL1_BT_SHIFT) &
54 ID_AA64PFR1_EL1_BT_MASK) == BTI_IMPLEMENTED;
55}
56
Antonio Nino Diazc326c342019-01-11 11:20:10 +000057#endif /* ARCH_FEATURES_H */