More adjustments for consistency.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14235 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-04-19 13:11:58 +00:00
parent 09945f4cc8
commit 4f8939fdc8
7 changed files with 48 additions and 49 deletions

View File

@ -79,13 +79,13 @@
* + {static} chSchGoSleepTimeoutS() * + {static} chSchGoSleepTimeoutS()
* } * }
* class tm_calibration_t { * class tm_calibration_t {
* # __tm_calibration_init() * # __tm_calibration_object_init()
* } * }
* class system_debug_t { * class system_debug_t {
* # __dbg_object_init() * # __dbg_object_init()
* } * }
* class trace_buffer_t { * class trace_buffer_t {
* # __trace_init() * # __trace_object_init()
* } * }
* class kernel_stats_t { * class kernel_stats_t {
* # __stats_object_init() * # __stats_object_init()

View File

@ -34,6 +34,13 @@
/* Module constants. */ /* Module constants. */
/*===========================================================================*/ /*===========================================================================*/
/**
* @brief Number of iterations in the calibration loop.
* @note This is required in order to assess the best result in
* architectures with instruction cache.
*/
#define TM_CALIBRATION_LOOP 4U
/*===========================================================================*/ /*===========================================================================*/
/* Module pre-compile time settings. */ /* Module pre-compile time settings. */
/*===========================================================================*/ /*===========================================================================*/
@ -88,7 +95,6 @@ typedef struct {
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void __tm_calibration_init(void);
void chTMObjectInit(time_measurement_t *tmp); void chTMObjectInit(time_measurement_t *tmp);
NOINLINE void chTMStartMeasurementX(time_measurement_t *tmp); NOINLINE void chTMStartMeasurementX(time_measurement_t *tmp);
NOINLINE void chTMStopMeasurementX(time_measurement_t *tmp); NOINLINE void chTMStopMeasurementX(time_measurement_t *tmp);
@ -102,6 +108,32 @@ extern "C" {
/* Module inline functions. */ /* Module inline functions. */
/*===========================================================================*/ /*===========================================================================*/
/**
* @brief Time measurement initialization.
* @note Internal use only.
*
* @param[out] tcp pointer to the @p tm_calibration_t structure
*
* @notapi
*/
static inline void __tm_calibration_object_init(tm_calibration_t *tcp) {
unsigned i;
time_measurement_t tm;
/* Time Measurement subsystem calibration, it does a null measurement
and calculates the call overhead which is subtracted to real
measurements.*/
tcp->offset = (rtcnt_t)0;
chTMObjectInit(&tm);
i = TM_CALIBRATION_LOOP;
do {
chTMStartMeasurementX(&tm);
chTMStopMeasurementX(&tm);
i--;
} while (i > 0U);
tcp->offset = tm.best;
}
#endif /* CH_CFG_USE_TM == TRUE */ #endif /* CH_CFG_USE_TM == TRUE */
#endif /* CHTM_H */ #endif /* CHTM_H */

View File

@ -248,7 +248,7 @@ typedef struct {
extern "C" { extern "C" {
#endif #endif
#if (CH_DBG_TRACE_MASK != CH_DBG_TRACE_MASK_DISABLED) || defined(__DOXYGEN__) #if (CH_DBG_TRACE_MASK != CH_DBG_TRACE_MASK_DISABLED) || defined(__DOXYGEN__)
void __trace_init(os_instance_t *oip); void __trace_object_init(trace_buffer_t *tbp);
void __trace_ready(thread_t *tp, msg_t msg); void __trace_ready(thread_t *tp, msg_t msg);
void __trace_switch(thread_t *ntp, thread_t *otp); void __trace_switch(thread_t *ntp, thread_t *otp);
void __trace_isr_enter(const char *isr); void __trace_isr_enter(const char *isr);

View File

@ -124,7 +124,7 @@ void chInstanceObjectInit(os_instance_t *oip,
#if CH_DBG_TRACE_MASK != CH_DBG_TRACE_MASK_DISABLED #if CH_DBG_TRACE_MASK != CH_DBG_TRACE_MASK_DISABLED
/* Trace buffer initialization.*/ /* Trace buffer initialization.*/
__trace_init(oip); __trace_object_init(&oip->trace_buffer);
#endif #endif
/* Statistics initialization.*/ /* Statistics initialization.*/

View File

@ -163,16 +163,16 @@ void chSysInit(void) {
ch_system.instances[i] = NULL; ch_system.instances[i] = NULL;
} }
#if CH_CFG_USE_TM == TRUE
/* Time Measurement calibration.*/
__tm_calibration_object_init(&ch_system.tmc);
#endif
#if (CH_CFG_USE_REGISTRY == TRUE) && (CH_CFG_SMP_MODE == TRUE) #if (CH_CFG_USE_REGISTRY == TRUE) && (CH_CFG_SMP_MODE == TRUE)
/* Registry initialization when SMP mode is enabled.*/ /* Registry initialization when SMP mode is enabled.*/
chRegObjectInit(&ch_system.reglist); chRegObjectInit(&ch_system.reglist);
#endif #endif
#if CH_CFG_USE_TM == TRUE
/* Time Measurement initialization.*/
__tm_calibration_init();
#endif
/* User system initialization hook.*/ /* User system initialization hook.*/
CH_CFG_SYSTEM_INIT_HOOK(); CH_CFG_SYSTEM_INIT_HOOK();

View File

@ -34,13 +34,6 @@
/* Module local definitions. */ /* Module local definitions. */
/*===========================================================================*/ /*===========================================================================*/
/**
* @brief Number of iterations in the calibration loop.
* @note This is required in order to assess the best result in
* architectures with instruction cache.
*/
#define TM_CALIBRATION_LOOP 4U
/*===========================================================================*/ /*===========================================================================*/
/* Module exported variables. */ /* Module exported variables. */
/*===========================================================================*/ /*===========================================================================*/
@ -76,32 +69,6 @@ static inline void tm_stop(time_measurement_t *tmp,
/* Module exported functions. */ /* Module exported functions. */
/*===========================================================================*/ /*===========================================================================*/
/**
* @brief Time measurement initialization.
* @note Internal use only.
*
* @param[out] tcp pointer to the @p tm_calibration_t structure
*
* @notapi
*/
void __tm_calibration_init(void) {
time_measurement_t tm;
unsigned i;
/* Time Measurement subsystem calibration, it does a null measurement
and calculates the call overhead which is subtracted to real
measurements.*/
ch_system.tmc.offset = (rtcnt_t)0;
chTMObjectInit(&tm);
i = TM_CALIBRATION_LOOP;
do {
chTMStartMeasurementX(&tm);
chTMStopMeasurementX(&tm);
i--;
} while (i > 0U);
ch_system.tmc.offset = tm.best;
}
/** /**
* @brief Initializes a @p TimeMeasurement object. * @brief Initializes a @p TimeMeasurement object.
* *

View File

@ -81,18 +81,18 @@ NOINLINE static void trace_next(os_instance_t *oip) {
* @brief Circular trace buffer initialization. * @brief Circular trace buffer initialization.
* @note Internal use only. * @note Internal use only.
* *
* @param[out] oip pointer to the @p os_instance_t structure * @param[out] tbp pointer to the @p trace_buffer_t structure
* *
* @notapi * @notapi
*/ */
void __trace_init(os_instance_t *oip) { void __trace_object_init(trace_buffer_t *tbp) {
unsigned i; unsigned i;
oip->trace_buffer.suspended = (uint16_t)~CH_DBG_TRACE_MASK; tbp->suspended = (uint16_t)~CH_DBG_TRACE_MASK;
oip->trace_buffer.size = CH_DBG_TRACE_BUFFER_SIZE; tbp->size = CH_DBG_TRACE_BUFFER_SIZE;
oip->trace_buffer.ptr = &oip->trace_buffer.buffer[0]; tbp->ptr = &tbp->buffer[0];
for (i = 0U; i < (unsigned)CH_DBG_TRACE_BUFFER_SIZE; i++) { for (i = 0U; i < (unsigned)CH_DBG_TRACE_BUFFER_SIZE; i++) {
oip->trace_buffer.buffer[i].type = CH_TRACE_TYPE_UNUSED; tbp->buffer[i].type = CH_TRACE_TYPE_UNUSED;
} }
} }