git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6037 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
0cb6bc9b9d
commit
61f841306a
|
@ -341,6 +341,15 @@
|
|||
*/
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Debug option, kernel statistics.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#if !defined(CH_DBG_STATISTICS) || defined(__DOXYGEN__)
|
||||
#define CH_DBG_STATISTICS TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Debug option, system state check.
|
||||
* @details If enabled the correct call protocol for system APIs is checked
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,7 @@ KERNSRC = ${CHIBIOS}/os/kernel/src/chsys.c \
|
|||
${CHIBIOS}/os/kernel/src/chlists.c \
|
||||
${CHIBIOS}/os/kernel/src/chvt.c \
|
||||
${CHIBIOS}/os/kernel/src/chrt.c \
|
||||
${CHIBIOS}/os/kernel/src/chstats.c \
|
||||
${CHIBIOS}/os/kernel/src/chschd.c \
|
||||
${CHIBIOS}/os/kernel/src/chthreads.c \
|
||||
${CHIBIOS}/os/kernel/src/chdynamic.c \
|
||||
|
|
|
@ -131,7 +131,7 @@ void _rt_init(void) {
|
|||
* @special
|
||||
*/
|
||||
bool chRTIsCounterWithin(rtcnt_t start, rtcnt_t end) {
|
||||
rtcnt_t now = chRTGetCounterValueX();
|
||||
rtcnt_t now = chSysGetRealtimeCounterX();
|
||||
|
||||
return end > start ? (now >= start) && (now < end) :
|
||||
(now >= start) || (now < end);
|
||||
|
@ -148,7 +148,7 @@ bool chRTIsCounterWithin(rtcnt_t start, rtcnt_t end) {
|
|||
* @special
|
||||
*/
|
||||
void chRTPolledDelay(rtcnt_t cycles) {
|
||||
rtcnt_t start = chRTGetCounterValueX();
|
||||
rtcnt_t start = chSysGetRealtimeCounterX();
|
||||
rtcnt_t end = start + cycles;
|
||||
while (chRTIsCounterWithin(start, end))
|
||||
;
|
||||
|
@ -163,9 +163,10 @@ void chRTPolledDelay(rtcnt_t cycles) {
|
|||
*/
|
||||
void chRTTimeMeasurementObjectInit(time_measurement_t *tmp) {
|
||||
|
||||
tmp->last = (rtcnt_t)0;
|
||||
tmp->worst = (rtcnt_t)0;
|
||||
tmp->best = (rtcnt_t)-1;
|
||||
tmp->worst = (rtcnt_t)0;
|
||||
tmp->cumulative = (rtcnt_t)0;
|
||||
tmp->last = (rtcnt_t)0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,7 +180,7 @@ void chRTTimeMeasurementObjectInit(time_measurement_t *tmp) {
|
|||
*/
|
||||
NOINLINE void chRTTimeMeasurementStartX(time_measurement_t *tmp) {
|
||||
|
||||
tmp->last = chRTGetCounterValueX();
|
||||
tmp->last = chSysGetRealtimeCounterX();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -193,8 +194,9 @@ NOINLINE void chRTTimeMeasurementStartX(time_measurement_t *tmp) {
|
|||
*/
|
||||
NOINLINE void chRTTimeMeasurementStopX(time_measurement_t *tmp) {
|
||||
|
||||
rtcnt_t now = chRTGetCounterValueX();
|
||||
rtcnt_t now = chSysGetRealtimeCounterX();
|
||||
tmp->last = now - tmp->last - measurement_offset;
|
||||
tmp->cumulative += tmp->last;
|
||||
if (tmp->last > tmp->worst)
|
||||
tmp->worst = tmp->last;
|
||||
else if (tmp->last < tmp->best)
|
||||
|
|
|
@ -211,7 +211,7 @@ void chSysTimerHandlerI(void) {
|
|||
* @return The previous system status, the encoding of this
|
||||
* status word is architecture-dependent and opaque.
|
||||
*
|
||||
* @special
|
||||
* @xclass
|
||||
*/
|
||||
syssts_t chSysGetAndLockX(void) {
|
||||
|
||||
|
@ -230,7 +230,7 @@ syssts_t chSysGetAndLockX(void) {
|
|||
*
|
||||
* @param[in] sts the system status to be restored.
|
||||
*
|
||||
* @special
|
||||
* @xclass
|
||||
*/
|
||||
void chSysRestoreLockX(syssts_t sts) {
|
||||
|
||||
|
|
|
@ -88,9 +88,9 @@ void _vt_init(void) {
|
|||
* @retval true current time within the specified time window.
|
||||
* @retval false current time not within the specified time window.
|
||||
*
|
||||
* @special
|
||||
* @xclass
|
||||
*/
|
||||
bool chVTIsTimeWithin(systime_t time, systime_t start, systime_t end) {
|
||||
bool chVTIsTimeWithinX(systime_t time, systime_t start, systime_t end) {
|
||||
|
||||
return end > start ? (time >= start) && (time < end) :
|
||||
(time >= start) || (time < end);
|
||||
|
|
|
@ -342,6 +342,15 @@
|
|||
*/
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Debug option, kernel statistics.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#if !defined(CH_DBG_STATISTICS) || defined(__DOXYGEN__)
|
||||
#define CH_DBG_STATISTICS TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Debug option, system state check.
|
||||
* @details If enabled the correct call protocol for system APIs is checked
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
typedef bool bool_t; /**< Fast boolean type. */
|
||||
typedef uint32_t systime_t; /**< System time. */
|
||||
typedef uint32_t rtcnt_t; /**< Realtime counter. */
|
||||
typedef uint32_t syssts_t; /**< System status word. */
|
||||
typedef uint8_t tmode_t; /**< Thread flags. */
|
||||
|
@ -45,8 +46,8 @@ typedef int32_t msg_t; /**< Inter-thread message. */
|
|||
typedef int32_t eventid_t; /**< Numeric event identifier. */
|
||||
typedef uint32_t eventmask_t; /**< Mask of event identifiers. */
|
||||
typedef uint32_t eventflags_t; /**< Mask of event flags. */
|
||||
typedef uint32_t systime_t; /**< System time. */
|
||||
typedef int32_t cnt_t; /**< Resources counter. */
|
||||
typedef int32_t cnt_t; /**< Generic signed counter. */
|
||||
typedef uint32_t ucnt_t; /**< Generic unsigned counter. */
|
||||
|
||||
/**
|
||||
* @brief ROM constant modifier.
|
||||
|
|
Loading…
Reference in New Issue