Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:43

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  * L4STAT APB-Register Driver.
0005  * 
0006  * COPYRIGHT (c) 2017.
0007  * Cobham Gaisler AB.
0008  *
0009  * Redistribution and use in source and binary forms, with or without
0010  * modification, are permitted provided that the following conditions
0011  * are met:
0012  * 1. Redistributions of source code must retain the above copyright
0013  *    notice, this list of conditions and the following disclaimer.
0014  * 2. Redistributions in binary form must reproduce the above copyright
0015  *    notice, this list of conditions and the following disclaimer in the
0016  *    documentation and/or other materials provided with the distribution.
0017  *
0018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0019  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0020  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0021  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0022  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0023  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0024  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0025  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0026  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0027  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0028  * POSSIBILITY OF SUCH DAMAGE.
0029  */
0030 
0031 #ifndef __L4STAT_H__
0032 #define __L4STAT_H__
0033 
0034 #ifdef __cplusplus
0035 extern "C" {
0036 #endif
0037 
0038 #define L4STAT_ERR_OK 0
0039 #define L4STAT_ERR_EINVAL -1
0040 #define L4STAT_ERR_ERROR -2
0041 #define L4STAT_ERR_TOOMANY -3
0042 #define L4STAT_ERR_IMPLEMENTED -4
0043 
0044 /* Register L4STAT driver to Driver Manager */
0045 void l4stat_register_drv (void);
0046 
0047 extern int l4stat_counter_print(unsigned int counter);
0048 
0049 /*
0050  * L4STAT CCTRL register fields
0051  */
0052 #define CCTRL_NCPU (0xf << CCTRL_NCPU_BIT)
0053 #define CCTRL_NCNT_L3STAT (0x1ff << CCTRL_NCNT_BIT)
0054 #define CCTRL_NCNT (0x1f << CCTRL_NCNT_BIT)
0055 #define CCTRL_MC (0x1 << CCTRL_MC_BIT)
0056 #define CCTRL_IA (0x1 << CCTRL_IA_BIT)
0057 #define CCTRL_DS (0x1 << CCTRL_DS_BIT)
0058 #define CCTRL_EE (0x1 << CCTRL_EE_BIT)
0059 #define CCTRL_AE (0x1 << CCTRL_AE_BIT)
0060 #define CCTRL_EL (0x1 << CCTRL_EL_BIT)
0061 #define CCTRL_CD (0x1 << CCTRL_CD_BIT)
0062 #define CCTRL_SU (0x3 << CCTRL_SU_BIT)
0063 #define CCTRL_CL (0x1 << CCTRL_CL_BIT)
0064 #define CCTRL_EN (0x1 << CCTRL_EN_BIT)
0065 #define CCTRL_EVENTID (0xff << CCTRL_EVENTID_BIT)
0066 #define CCTRL_CPUAHBM (0xf << CCTRL_CPUAHBM_BIT)
0067 
0068 #define CCTRL_NCPU_BIT 28
0069 #define CCTRL_NCNT_BIT 23
0070 #define CCTRL_MC_BIT 22
0071 #define CCTRL_IA_BIT 21
0072 #define CCTRL_DS_BIT 20
0073 #define CCTRL_EE_BIT 19
0074 #define CCTRL_AE_BIT 18
0075 #define CCTRL_EL_BIT 17
0076 #define CCTRL_CD_BIT 16
0077 #define CCTRL_SU_BIT 14
0078 #define CCTRL_CL_BIT 13
0079 #define CCTRL_EN_BIT 12
0080 #define CCTRL_EVENTID_BIT 4
0081 #define CCTRL_CPUAHBM_BIT 0
0082 
0083 #define L4STAT_OPTIONS_EVENT_LEVEL_ENABLE CCTRL_EL 
0084 #define L4STAT_OPTIONS_EVENT_LEVEL_DISABLE 0
0085 #define L4STAT_OPTIONS_MAXIMUM_DURATION CCTRL_CD
0086 #define L4STAT_OPTIONS_SUPERVISOR_MODE_FILTER (0x1 << CCTRL_SU_BIT)
0087 #define L4STAT_OPTIONS_USER_MODE_FILTER (0x2 << CCTRL_SU_BIT)
0088 #define L4STAT_OPTIONS_NO_FILTER 0
0089 #define L4STAT_OPTIONS_CLEAR_ON_READ CCTRL_CL
0090 
0091 extern int l4stat_counter_enable(unsigned int counter, int event, int cpu, int options);
0092 extern int l4stat_counter_disable(unsigned int counter);
0093 extern int l4stat_counter_set(unsigned int counter, uint32_t val);
0094 extern int l4stat_counter_get(unsigned int counter, uint32_t *val);
0095 
0096 static inline int l4stat_counter_clear(unsigned int counter)
0097 {
0098     return l4stat_counter_set(counter, 0);
0099 }
0100 
0101 extern int l4stat_counter_max_set(unsigned int counter, uint32_t val);
0102 extern int l4stat_counter_max_get(unsigned int counter, uint32_t *val);
0103 extern int l4stat_tstamp_set(uint32_t val);
0104 extern int l4stat_tstamp_get(uint32_t *val);
0105 
0106 #ifdef __cplusplus
0107 }
0108 #endif
0109 
0110 #endif