1 /* 2 * Copyright (c) 2019-2023, 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 #include <common/feat_detect.h> 14 15 #define ISOLATE_FIELD(reg, feat) \ 16 ((unsigned int)(((reg) >> (feat ## _SHIFT)) & (feat ## _MASK))) 17 18 static inline bool is_armv7_gentimer_present(void) 19 { 20 return ISOLATE_FIELD(read_id_pfr1(), ID_PFR1_GENTIMER) != 0U; 21 } 22 23 static inline bool is_armv8_2_ttcnp_present(void) 24 { 25 return ISOLATE_FIELD(read_id_mmfr4(), ID_MMFR4_CNP) != 0U; 26 } 27 28 static inline unsigned int read_feat_trf_id_field(void) 29 { 30 return ISOLATE_FIELD(read_id_dfr0(), ID_DFR0_TRACEFILT); 31 } 32 33 static inline bool is_feat_trf_supported(void) 34 { 35 if (ENABLE_TRF_FOR_NS == FEAT_STATE_DISABLED) { 36 return false; 37 } 38 39 if (ENABLE_TRF_FOR_NS == FEAT_STATE_ALWAYS) { 40 return true; 41 } 42 43 return read_feat_trf_id_field() != 0U; 44 } 45 46 #endif /* ARCH_FEATURES_H */ 47