aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--os/common/ports/ARMCMx/compilers/GCC/rules.mk3
-rw-r--r--os/rt/include/chdebug.h13
-rw-r--r--os/rt/include/chschd.h64
-rw-r--r--os/rt/include/chsystypes.h5
-rw-r--r--os/rt/include/chtm.h10
-rw-r--r--os/rt/src/chdebug.c46
-rw-r--r--os/rt/src/chsys.c11
-rw-r--r--os/rt/src/chtm.c6
8 files changed, 85 insertions, 73 deletions
diff --git a/os/common/ports/ARMCMx/compilers/GCC/rules.mk b/os/common/ports/ARMCMx/compilers/GCC/rules.mk
index 9ac0f2b8b..7b1c1c8d8 100644
--- a/os/common/ports/ARMCMx/compilers/GCC/rules.mk
+++ b/os/common/ports/ARMCMx/compilers/GCC/rules.mk
@@ -264,8 +264,6 @@ else
@$(OD) $(ODFLAGS) $< > $@
@echo
@$(SZ) $<
- @echo
- @echo Done
endif
%.list: %.elf $(LDSCRIPT)
@@ -274,6 +272,7 @@ ifeq ($(USE_VERBOSE_COMPILE),yes)
else
@echo Creating $@
@$(OD) -S $< > $@
+ @echo
@echo Done
endif
diff --git a/os/rt/include/chdebug.h b/os/rt/include/chdebug.h
index d0223ef10..d8643ea64 100644
--- a/os/rt/include/chdebug.h
+++ b/os/rt/include/chdebug.h
@@ -71,13 +71,6 @@
/* Derived constants and error checks. */
/*===========================================================================*/
-#if CH_DBG_ENABLE_ASSERTS || CH_DBG_ENABLE_CHECKS || \
- CH_DBG_ENABLE_STACK_CHECK || CH_DBG_SYSTEM_STATE_CHECK
-#define CH_DBG_ENABLED TRUE
-#else
-#define CH_DBG_ENABLED FALSE
-#endif
-
/*===========================================================================*/
/* Module data structures and types. */
/*===========================================================================*/
@@ -129,8 +122,8 @@ typedef struct {
/*===========================================================================*/
#if CH_DBG_SYSTEM_STATE_CHECK
-#define _dbg_enter_lock() (ch.dbg_lock_cnt = 1)
-#define _dbg_leave_lock() (ch.dbg_lock_cnt = 0)
+#define _dbg_enter_lock() (ch.dbg.lock_cnt = 1)
+#define _dbg_leave_lock() (ch.dbg.lock_cnt = 0)
#endif
/* When the state checker feature is disabled then the following functions
@@ -221,7 +214,7 @@ extern "C" {
void chDbgCheckClassS(void);
#endif
#if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__)
- void _trace_init(void);
+ void _dbg_trace_init(void);
void _dbg_trace(thread_t *otp);
#endif
#ifdef __cplusplus
diff --git a/os/rt/include/chschd.h b/os/rt/include/chschd.h
index 8a7a59aae..f2deb3b92 100644
--- a/os/rt/include/chschd.h
+++ b/os/rt/include/chschd.h
@@ -285,6 +285,36 @@ struct ch_ready_list {
};
/**
+ * @brief System debug data structure.
+ */
+struct ch_system_debug {
+ /**
+ * @brief Pointer to the panic message.
+ * @details This pointer is meant to be accessed through the debugger, it is
+ * written once and then the system is halted.
+ * @note Accesses to this pointer must never be optimized out so the
+ * field itself is declared volatile.
+ */
+ const char * volatile panic_msg;
+#if CH_DBG_SYSTEM_STATE_CHECK || defined(__DOXYGEN__)
+ /**
+ * @brief ISR nesting level.
+ */
+ cnt_t isr_cnt;
+ /**
+ * @brief Lock nesting level.
+ */
+ cnt_t lock_cnt;
+#endif
+#if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__)
+ /**
+ * @brief Public trace buffer.
+ */
+ ch_trace_buffer_t trace_buffer;
+#endif
+};
+
+/**
* @brief System data structure.
* @note This structure contain all the data areas used by the OS except
* stacks.
@@ -298,11 +328,15 @@ struct ch_system {
* @brief Virtual timers delta list header.
*/
virtual_timers_list_t vtlist;
+ /**
+ * @brief System debug.
+ */
+ system_debug_t dbg;
#if CH_CFG_USE_TM || defined(__DOXYGEN__)
/**
- * @brief Measurement calibration value.
+ * @brief Time measurement calibration data.
*/
- rtcnt_t measurement_offset;
+ tm_calibration_t tm;
#endif
#if CH_DBG_STATISTICS || defined(__DOXYGEN__)
/**
@@ -310,32 +344,6 @@ struct ch_system {
*/
kernel_stats_t kernel_stats;
#endif
-#if CH_DBG_ENABLED || defined(__DOXYGEN__)
- /**
- * @brief Pointer to the panic message.
- * @details This pointer is meant to be accessed through the debugger, it is
- * written once and then the system is halted.
- * @note Accesses to this pointer must never be optimized out so the
- * field itself is declared volatile.
- */
- const char * volatile dbg_panic_msg;
-#endif
-#if CH_DBG_SYSTEM_STATE_CHECK || defined(__DOXYGEN__)
- /**
- * @brief ISR nesting level.
- */
- cnt_t dbg_isr_cnt;
- /**
- * @brief Lock nesting level.
- */
- cnt_t dbg_lock_cnt;
-#endif
-#if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__)
- /**
- * @brief Public trace buffer.
- */
- ch_trace_buffer_t dbg_trace_buffer;
-#endif
};
/*===========================================================================*/
diff --git a/os/rt/include/chsystypes.h b/os/rt/include/chsystypes.h
index 2a64488db..cf42b80bc 100644
--- a/os/rt/include/chsystypes.h
+++ b/os/rt/include/chsystypes.h
@@ -98,6 +98,11 @@ typedef struct ch_virtual_timer virtual_timer_t;
typedef struct ch_virtual_timers_list virtual_timers_list_t;
/**
+ * @brief Type of a system debug structure.
+ */
+typedef struct ch_system_debug system_debug_t;
+
+/**
* @brief Type of system data structure.
*/
typedef struct ch_system ch_system_t;
diff --git a/os/rt/include/chtm.h b/os/rt/include/chtm.h
index 73850aad7..1bcd4b452 100644
--- a/os/rt/include/chtm.h
+++ b/os/rt/include/chtm.h
@@ -52,6 +52,16 @@
/*===========================================================================*/
/**
+ * @brief Type of a time measurement calibration data.
+ */
+typedef struct {
+ /**
+ * @brief Measurement calibration value.
+ */
+ rtcnt_t offset;
+} tm_calibration_t;
+
+/**
* @brief Type of a Time Measurement object.
* @note The maximum measurable time period depends on the implementation
* of the realtime counter and its clock frequency.
diff --git a/os/rt/src/chdebug.c b/os/rt/src/chdebug.c
index f9408d515..bf31b7cac 100644
--- a/os/rt/src/chdebug.c
+++ b/os/rt/src/chdebug.c
@@ -114,7 +114,7 @@
*/
void _dbg_check_disable(void) {
- if ((ch.dbg_isr_cnt != 0) || (ch.dbg_lock_cnt != 0))
+ if ((ch.dbg.isr_cnt != 0) || (ch.dbg.lock_cnt != 0))
chSysHalt("SV#1");
}
@@ -125,7 +125,7 @@ void _dbg_check_disable(void) {
*/
void _dbg_check_suspend(void) {
- if ((ch.dbg_isr_cnt != 0) || (ch.dbg_lock_cnt != 0))
+ if ((ch.dbg.isr_cnt != 0) || (ch.dbg.lock_cnt != 0))
chSysHalt("SV#2");
}
@@ -136,7 +136,7 @@ void _dbg_check_suspend(void) {
*/
void _dbg_check_enable(void) {
- if ((ch.dbg_isr_cnt != 0) || (ch.dbg_lock_cnt != 0))
+ if ((ch.dbg.isr_cnt != 0) || (ch.dbg.lock_cnt != 0))
chSysHalt("SV#3");
}
@@ -147,7 +147,7 @@ void _dbg_check_enable(void) {
*/
void _dbg_check_lock(void) {
- if ((ch.dbg_isr_cnt != 0) || (ch.dbg_lock_cnt != 0))
+ if ((ch.dbg.isr_cnt != 0) || (ch.dbg.lock_cnt != 0))
chSysHalt("SV#4");
_dbg_enter_lock();
}
@@ -159,7 +159,7 @@ void _dbg_check_lock(void) {
*/
void _dbg_check_unlock(void) {
- if ((ch.dbg_isr_cnt != 0) || (ch.dbg_lock_cnt <= 0))
+ if ((ch.dbg.isr_cnt != 0) || (ch.dbg.lock_cnt <= 0))
chSysHalt("SV#5");
_dbg_leave_lock();
}
@@ -171,7 +171,7 @@ void _dbg_check_unlock(void) {
*/
void _dbg_check_lock_from_isr(void) {
- if ((ch.dbg_isr_cnt <= 0) || (ch.dbg_lock_cnt != 0))
+ if ((ch.dbg.isr_cnt <= 0) || (ch.dbg.lock_cnt != 0))
chSysHalt("SV#6");
_dbg_enter_lock();
}
@@ -183,7 +183,7 @@ void _dbg_check_lock_from_isr(void) {
*/
void _dbg_check_unlock_from_isr(void) {
- if ((ch.dbg_isr_cnt <= 0) || (ch.dbg_lock_cnt <= 0))
+ if ((ch.dbg.isr_cnt <= 0) || (ch.dbg.lock_cnt <= 0))
chSysHalt("SV#7");
_dbg_leave_lock();
}
@@ -196,9 +196,9 @@ void _dbg_check_unlock_from_isr(void) {
void _dbg_check_enter_isr(void) {
port_lock_from_isr();
- if ((ch.dbg_isr_cnt < 0) || (ch.dbg_lock_cnt != 0))
+ if ((ch.dbg.isr_cnt < 0) || (ch.dbg.lock_cnt != 0))
chSysHalt("SV#8");
- ch.dbg_isr_cnt++;
+ ch.dbg.isr_cnt++;
port_unlock_from_isr();
}
@@ -210,9 +210,9 @@ void _dbg_check_enter_isr(void) {
void _dbg_check_leave_isr(void) {
port_lock_from_isr();
- if ((ch.dbg_isr_cnt <= 0) || (ch.dbg_lock_cnt != 0))
+ if ((ch.dbg.isr_cnt <= 0) || (ch.dbg.lock_cnt != 0))
chSysHalt("SV#9");
- ch.dbg_isr_cnt--;
+ ch.dbg.isr_cnt--;
port_unlock_from_isr();
}
@@ -226,7 +226,7 @@ void _dbg_check_leave_isr(void) {
*/
void chDbgCheckClassI(void) {
- if ((ch.dbg_isr_cnt < 0) || (ch.dbg_lock_cnt <= 0))
+ if ((ch.dbg.isr_cnt < 0) || (ch.dbg.lock_cnt <= 0))
chSysHalt("SV#10");
}
@@ -240,7 +240,7 @@ void chDbgCheckClassI(void) {
*/
void chDbgCheckClassS(void) {
- if ((ch.dbg_isr_cnt != 0) || (ch.dbg_lock_cnt <= 0))
+ if ((ch.dbg.isr_cnt != 0) || (ch.dbg.lock_cnt <= 0))
chSysHalt("SV#11");
}
@@ -251,10 +251,10 @@ void chDbgCheckClassS(void) {
* @brief Trace circular buffer subsystem initialization.
* @note Internal use only.
*/
-void _trace_init(void) {
+void _dbg_trace_init(void) {
- ch.dbg_trace_buffer.tb_size = CH_DBG_TRACE_BUFFER_SIZE;
- ch.dbg_trace_buffer.tb_ptr = &ch.dbg_trace_buffer.tb_buffer[0];
+ ch.dbg.trace_buffer.tb_size = CH_DBG_TRACE_BUFFER_SIZE;
+ ch.dbg.trace_buffer.tb_ptr = &ch.dbg.trace_buffer.tb_buffer[0];
}
/**
@@ -266,13 +266,13 @@ void _trace_init(void) {
*/
void _dbg_trace(thread_t *otp) {
- ch.dbg_trace_buffer.tb_ptr->se_time = chVTGetSystemTimeX();
- ch.dbg_trace_buffer.tb_ptr->se_tp = currp;
- ch.dbg_trace_buffer.tb_ptr->se_wtobjp = otp->p_u.wtobjp;
- ch.dbg_trace_buffer.tb_ptr->se_state = (uint8_t)otp->p_state;
- if (++ch.dbg_trace_buffer.tb_ptr >=
- &ch.dbg_trace_buffer.tb_buffer[CH_DBG_TRACE_BUFFER_SIZE])
- ch.dbg_trace_buffer.tb_ptr = &ch.dbg_trace_buffer.tb_buffer[0];
+ ch.dbg.trace_buffer.tb_ptr->se_time = chVTGetSystemTimeX();
+ ch.dbg.trace_buffer.tb_ptr->se_tp = currp;
+ ch.dbg.trace_buffer.tb_ptr->se_wtobjp = otp->p_u.wtobjp;
+ ch.dbg.trace_buffer.tb_ptr->se_state = (uint8_t)otp->p_state;
+ if (++ch.dbg.trace_buffer.tb_ptr >=
+ &ch.dbg.trace_buffer.tb_buffer[CH_DBG_TRACE_BUFFER_SIZE])
+ ch.dbg.trace_buffer.tb_ptr = &ch.dbg.trace_buffer.tb_buffer[0];
}
#endif /* CH_DBG_ENABLE_TRACE */
diff --git a/os/rt/src/chsys.c b/os/rt/src/chsys.c
index 53672e46d..b5c83b95a 100644
--- a/os/rt/src/chsys.c
+++ b/os/rt/src/chsys.c
@@ -119,7 +119,7 @@ void chSysInit(void) {
_stats_init();
#endif
#if CH_DBG_ENABLE_TRACE
- _trace_init();
+ _dbg_trace_init();
#endif
#if !CH_CFG_NO_IDLE_THREAD
@@ -165,16 +165,13 @@ void chSysHalt(const char *reason) {
port_disable();
-#if CH_DBG_ENABLED
- ch.dbg_panic_msg = reason;
-#else
- (void)reason;
-#endif
-
#if defined(CH_CFG_SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
CH_CFG_SYSTEM_HALT_HOOK(reason);
#endif
+ /* Pointing to the passed message.*/
+ ch.dbg.panic_msg = reason;
+
/* Harmless infinite loop.*/
while (true)
;
diff --git a/os/rt/src/chtm.c b/os/rt/src/chtm.c
index d0cd1a630..bb3aadd39 100644
--- a/os/rt/src/chtm.c
+++ b/os/rt/src/chtm.c
@@ -79,11 +79,11 @@ void _tm_init(void) {
/* Time Measurement subsystem calibration, it does a null measurement
and calculates the call overhead which is subtracted to real
measurements.*/
- ch.measurement_offset = 0;
+ ch.tm.offset = 0;
chTMObjectInit(&tm);
chTMStartMeasurementX(&tm);
chTMStopMeasurementX(&tm);
- ch.measurement_offset = tm.last;
+ ch.tm.offset = tm.last;
}
/**
@@ -125,7 +125,7 @@ NOINLINE void chTMStartMeasurementX(time_measurement_t *tmp) {
*/
NOINLINE void chTMStopMeasurementX(time_measurement_t *tmp) {
- tm_stop(tmp, chSysGetRealtimeCounterX(), ch.measurement_offset);
+ tm_stop(tmp, chSysGetRealtimeCounterX(), ch.tm.offset);
}
/**