diff options
Diffstat (limited to 'lib/chibios/os/rt/include/chstats.h')
-rw-r--r-- | lib/chibios/os/rt/include/chstats.h | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/lib/chibios/os/rt/include/chstats.h b/lib/chibios/os/rt/include/chstats.h new file mode 100644 index 000000000..3a51c71c4 --- /dev/null +++ b/lib/chibios/os/rt/include/chstats.h | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014, | ||
3 | 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio. | ||
4 | |||
5 | This file is part of ChibiOS. | ||
6 | |||
7 | ChibiOS is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation version 3 of the License. | ||
10 | |||
11 | ChibiOS is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | /** | ||
21 | * @file rt/include/chstats.h | ||
22 | * @brief Statistics module macros and structures. | ||
23 | * | ||
24 | * @addtogroup statistics | ||
25 | * @{ | ||
26 | */ | ||
27 | |||
28 | #ifndef CHSTATS_H | ||
29 | #define CHSTATS_H | ||
30 | |||
31 | #if (CH_DBG_STATISTICS == TRUE) || defined(__DOXYGEN__) | ||
32 | |||
33 | /*===========================================================================*/ | ||
34 | /* Module constants. */ | ||
35 | /*===========================================================================*/ | ||
36 | |||
37 | /*===========================================================================*/ | ||
38 | /* Module pre-compile time settings. */ | ||
39 | /*===========================================================================*/ | ||
40 | |||
41 | #if CH_CFG_USE_TM == FALSE | ||
42 | #error "CH_DBG_STATISTICS requires CH_CFG_USE_TM" | ||
43 | #endif | ||
44 | |||
45 | /*===========================================================================*/ | ||
46 | /* Derived constants and error checks. */ | ||
47 | /*===========================================================================*/ | ||
48 | |||
49 | /*===========================================================================*/ | ||
50 | /* Module data structures and types. */ | ||
51 | /*===========================================================================*/ | ||
52 | |||
53 | /** | ||
54 | * @brief Type of a kernel statistics structure. | ||
55 | */ | ||
56 | typedef struct { | ||
57 | ucnt_t n_irq; /**< @brief Number of IRQs. */ | ||
58 | ucnt_t n_ctxswc; /**< @brief Number of context switches. */ | ||
59 | time_measurement_t m_crit_thd; /**< @brief Measurement of threads | ||
60 | critical zones duration. */ | ||
61 | time_measurement_t m_crit_isr; /**< @brief Measurement of ISRs critical | ||
62 | zones duration. */ | ||
63 | } kernel_stats_t; | ||
64 | |||
65 | /*===========================================================================*/ | ||
66 | /* Module macros. */ | ||
67 | /*===========================================================================*/ | ||
68 | |||
69 | /*===========================================================================*/ | ||
70 | /* External declarations. */ | ||
71 | /*===========================================================================*/ | ||
72 | |||
73 | #ifdef __cplusplus | ||
74 | extern "C" { | ||
75 | #endif | ||
76 | void _stats_init(void); | ||
77 | void _stats_increase_irq(void); | ||
78 | void _stats_ctxswc(thread_t *ntp, thread_t *otp); | ||
79 | void _stats_start_measure_crit_thd(void); | ||
80 | void _stats_stop_measure_crit_thd(void); | ||
81 | void _stats_start_measure_crit_isr(void); | ||
82 | void _stats_stop_measure_crit_isr(void); | ||
83 | #ifdef __cplusplus | ||
84 | } | ||
85 | #endif | ||
86 | |||
87 | /*===========================================================================*/ | ||
88 | /* Module inline functions. */ | ||
89 | /*===========================================================================*/ | ||
90 | |||
91 | #else /* CH_DBG_STATISTICS == FALSE */ | ||
92 | |||
93 | /* Stub functions for when the statistics module is disabled. */ | ||
94 | #define _stats_increase_irq() | ||
95 | #define _stats_ctxswc(old, new) | ||
96 | #define _stats_start_measure_crit_thd() | ||
97 | #define _stats_stop_measure_crit_thd() | ||
98 | #define _stats_start_measure_crit_isr() | ||
99 | #define _stats_stop_measure_crit_isr() | ||
100 | |||
101 | #endif /* CH_DBG_STATISTICS == FALSE */ | ||
102 | |||
103 | #endif /* CHSTATS_H */ | ||
104 | |||
105 | /** @} */ | ||