blob: a923df32b68e2168013b70155b3b03e7acf37326 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <amu.h>
8#include <amu_private.h>
9#include <arch.h>
10#include <arch_helpers.h>
11#include <assert.h>
12
13int amu_supported(void)
14{
15 uint64_t features;
16
17 features = read_id_pfr0() >> ID_PFR0_AMU_SHIFT;
18 return (features & ID_PFR0_AMU_MASK) == 1;
19}
20
21/* Read the group 0 counter identified by the given `idx`. */
22uint64_t amu_group0_cnt_read(int idx)
23{
24 assert(amu_supported());
25 assert(idx >= 0 && idx < AMU_GROUP0_NR_COUNTERS);
26
27 return amu_group0_cnt_read_internal(idx);
28}
29
30/* Read the group 1 counter identified by the given `idx`. */
31uint64_t amu_group1_cnt_read(int idx)
32{
33 assert(amu_supported());
34 assert(idx >= 0 && idx < AMU_GROUP1_NR_COUNTERS);
35
36 return amu_group1_cnt_read_internal(idx);
37}