RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
l4stat.h
1/*
2 * L4STAT APB-Register Driver.
3 *
4 * COPYRIGHT (c) 2017.
5 * Cobham Gaisler AB.
6 *
7 * The license and distribution terms for this file may be
8 * found in the file LICENSE in this distribution or at
9 * http://www.rtems.org/license/LICENSE.
10 */
11
12#ifndef __L4STAT_H__
13#define __L4STAT_H__
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19#define L4STAT_ERR_OK 0
20#define L4STAT_ERR_EINVAL -1
21#define L4STAT_ERR_ERROR -2
22#define L4STAT_ERR_TOOMANY -3
23#define L4STAT_ERR_IMPLEMENTED -4
24
25/* Register L4STAT driver to Driver Manager */
26void l4stat_register_drv (void);
27
28extern int l4stat_counter_print(unsigned int counter);
29
30/*
31 * L4STAT CCTRL register fields
32 */
33#define CCTRL_NCPU (0xf << CCTRL_NCPU_BIT)
34#define CCTRL_NCNT_L3STAT (0x1ff << CCTRL_NCNT_BIT)
35#define CCTRL_NCNT (0x1f << CCTRL_NCNT_BIT)
36#define CCTRL_MC (0x1 << CCTRL_MC_BIT)
37#define CCTRL_IA (0x1 << CCTRL_IA_BIT)
38#define CCTRL_DS (0x1 << CCTRL_DS_BIT)
39#define CCTRL_EE (0x1 << CCTRL_EE_BIT)
40#define CCTRL_AE (0x1 << CCTRL_AE_BIT)
41#define CCTRL_EL (0x1 << CCTRL_EL_BIT)
42#define CCTRL_CD (0x1 << CCTRL_CD_BIT)
43#define CCTRL_SU (0x3 << CCTRL_SU_BIT)
44#define CCTRL_CL (0x1 << CCTRL_CL_BIT)
45#define CCTRL_EN (0x1 << CCTRL_EN_BIT)
46#define CCTRL_EVENTID (0xff << CCTRL_EVENTID_BIT)
47#define CCTRL_CPUAHBM (0xf << CCTRL_CPUAHBM_BIT)
48
49#define CCTRL_NCPU_BIT 28
50#define CCTRL_NCNT_BIT 23
51#define CCTRL_MC_BIT 22
52#define CCTRL_IA_BIT 21
53#define CCTRL_DS_BIT 20
54#define CCTRL_EE_BIT 19
55#define CCTRL_AE_BIT 18
56#define CCTRL_EL_BIT 17
57#define CCTRL_CD_BIT 16
58#define CCTRL_SU_BIT 14
59#define CCTRL_CL_BIT 13
60#define CCTRL_EN_BIT 12
61#define CCTRL_EVENTID_BIT 4
62#define CCTRL_CPUAHBM_BIT 0
63
64#define L4STAT_OPTIONS_EVENT_LEVEL_ENABLE CCTRL_EL
65#define L4STAT_OPTIONS_EVENT_LEVEL_DISABLE 0
66#define L4STAT_OPTIONS_MAXIMUM_DURATION CCTRL_CD
67#define L4STAT_OPTIONS_SUPERVISOR_MODE_FILTER (0x1 << CCTRL_SU_BIT)
68#define L4STAT_OPTIONS_USER_MODE_FILTER (0x2 << CCTRL_SU_BIT)
69#define L4STAT_OPTIONS_NO_FILTER 0
70#define L4STAT_OPTIONS_CLEAR_ON_READ CCTRL_CL
71
72extern int l4stat_counter_enable(unsigned int counter, int event, int cpu, int options);
73extern int l4stat_counter_disable(unsigned int counter);
74extern int l4stat_counter_set(unsigned int counter, uint32_t val);
75extern int l4stat_counter_get(unsigned int counter, uint32_t *val);
76
77static inline int l4stat_counter_clear(unsigned int counter)
78{
79 return l4stat_counter_set(counter, 0);
80}
81
82extern int l4stat_counter_max_set(unsigned int counter, uint32_t val);
83extern int l4stat_counter_max_get(unsigned int counter, uint32_t *val);
84extern int l4stat_tstamp_set(uint32_t val);
85extern int l4stat_tstamp_get(uint32_t *val);
86
87#ifdef __cplusplus
88}
89#endif
90
91#endif