aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel/include
diff options
context:
space:
mode:
Diffstat (limited to 'os/kernel/include')
-rw-r--r--os/kernel/include/ch.h3
-rw-r--r--os/kernel/include/chrt.h24
-rw-r--r--os/kernel/include/chsys.h23
-rw-r--r--os/kernel/include/chvt.h12
4 files changed, 33 insertions, 29 deletions
diff --git a/os/kernel/include/ch.h b/os/kernel/include/ch.h
index 1d1e053ce..efade76bf 100644
--- a/os/kernel/include/ch.h
+++ b/os/kernel/include/ch.h
@@ -108,10 +108,11 @@ typedef struct thread thread_t;
#include "chconf.h"
#include "chtypes.h"
#include "chdebug.h"
+#include "chrt.h"
+#include "chstats.h"
#include "chcore.h"
#include "chsys.h"
#include "chvt.h"
-#include "chrt.h"
#include "chthreads.h"
#include "chlists.h"
#include "chschd.h"
diff --git a/os/kernel/include/chrt.h b/os/kernel/include/chrt.h
index dfb2a4277..caf27747e 100644
--- a/os/kernel/include/chrt.h
+++ b/os/kernel/include/chrt.h
@@ -59,9 +59,10 @@
* with interrupts enabled.
*/
typedef struct {
- rtcnt_t last; /**< @brief Last measurement. */
- rtcnt_t worst; /**< @brief Worst measurement. */
rtcnt_t best; /**< @brief Best measurement. */
+ rtcnt_t worst; /**< @brief Worst measurement. */
+ rtcnt_t cumulative; /**< @brief Cumulative measurement. */
+ rtcnt_t last; /**< @brief Last measurement. */
} time_measurement_t;
/*===========================================================================*/
@@ -149,6 +150,7 @@ typedef struct {
#ifdef __cplusplus
extern "C" {
#endif
+ void _rt_init(void);
bool chRTIsCounterWithin(rtcnt_t start, rtcnt_t end);
void chRTPolledDelay(rtcnt_t cycles);
void chRTTimeMeasurementObjectInit(time_measurement_t *tmp);
@@ -162,24 +164,6 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
-/**
- * @brief Returns the current value of the system real time counter.
- * @note This function can be called from any context.
- *
- * @return The value of the system free running counter of
- * type rtcnt_t.
- *
- * @special
- */
-static inline rtcnt_t chRTGetCounterValueX(void) {
-
-#if !CH_PORT_SUPPORTS_RT
- return port_rt_get_counter_value();
-#else
- return chVTGetSystemTimeX();
-#endif
-}
-
#endif /* CH_CFG_USE_RT */
#endif /* _CHRT_H_ */
diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h
index 5086e0b7f..3dc6623e9 100644
--- a/os/kernel/include/chsys.h
+++ b/os/kernel/include/chsys.h
@@ -61,7 +61,8 @@
*/
#define CH_IRQ_PROLOGUE() \
PORT_IRQ_PROLOGUE(); \
- dbg_check_enter_isr();
+ dbg_check_enter_isr(); \
+ _stats_increase_irq()
/**
* @brief IRQ handler exit code.
@@ -73,7 +74,7 @@
*/
#define CH_IRQ_EPILOGUE() \
dbg_check_leave_isr(); \
- PORT_IRQ_EPILOGUE();
+ PORT_IRQ_EPILOGUE()
/**
* @brief Standard normal IRQ handler declaration.
@@ -99,6 +100,23 @@
#define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
/** @} */
+/**
+ * @brief Returns the current value of the system real time counter.
+ * @note This function can be called from any context.
+ * @note If the port does not support a realtime counter then this
+ * function returns the system time.
+ *
+ * @return The value of the system realtime counter of
+ * type rtcnt_t.
+ *
+ * @special
+ */
+#if CH_PORT_SUPPORTS_RT || defined(__DOXYGEN__)
+#define chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value()
+#else
+#define chSysGetRealtimeCounterX() (rtcnt_t)chVTGetSystemTimeX()
+#endif
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
@@ -132,6 +150,7 @@ extern "C" {
static inline void chSysSwitch(thread_t *ntp, thread_t *otp) {
dbg_trace(otp);
+ _stats_increase_ctxswc();
CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp);
port_switch(ntp, otp);
}
diff --git a/os/kernel/include/chvt.h b/os/kernel/include/chvt.h
index a53a3f502..10168a66e 100644
--- a/os/kernel/include/chvt.h
+++ b/os/kernel/include/chvt.h
@@ -169,7 +169,7 @@ extern virtual_timers_list_t vtlist;
extern "C" {
#endif
void _vt_init(void);
- bool chVTIsTimeWithin(systime_t time, systime_t start, systime_t end);
+ bool chVTIsTimeWithinX(systime_t time, systime_t start, systime_t end);
void chVTDoSetI(virtual_timer_t *vtp, systime_t delay,
vtfunc_t vtfunc, void *par);
void chVTDoResetI(virtual_timer_t *vtp);
@@ -208,7 +208,7 @@ static inline void chVTObjectInit(virtual_timer_t *vtp) {
*
* @return The system time in ticks.
*
- * @special
+ * @xclass
*/
static inline systime_t chVTGetSystemTimeX(void) {
@@ -249,13 +249,13 @@ static inline systime_t chVTGetSystemTime(void) {
* @retval true current time within the specified time window.
* @retval false current time not within the specified time window.
*
- * @api
+ * @xclass
*/
-static inline bool chVTIsSystemTimeWithinI(systime_t start, systime_t end) {
+static inline bool chVTIsSystemTimeWithinX(systime_t start, systime_t end) {
chDbgCheckClassI();
- return chVTIsTimeWithin(chVTGetSystemTimeX(), start, end);
+ return chVTIsTimeWithinX(chVTGetSystemTimeX(), start, end);
}
/**
@@ -273,7 +273,7 @@ static inline bool chVTIsSystemTimeWithinI(systime_t start, systime_t end) {
*/
static inline bool chVTIsSystemTimeWithin(systime_t start, systime_t end) {
- return chVTIsTimeWithin(chVTGetSystemTime(), start, end);
+ return chVTIsTimeWithinX(chVTGetSystemTime(), start, end);
}
/**