git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7507 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2014-11-14 11:07:04 +00:00
parent 79a1586513
commit 1409bd15bd
8 changed files with 85 additions and 73 deletions

View File

@ -264,8 +264,6 @@ else
@$(OD) $(ODFLAGS) $< > $@ @$(OD) $(ODFLAGS) $< > $@
@echo @echo
@$(SZ) $< @$(SZ) $<
@echo
@echo Done
endif endif
%.list: %.elf $(LDSCRIPT) %.list: %.elf $(LDSCRIPT)
@ -274,6 +272,7 @@ ifeq ($(USE_VERBOSE_COMPILE),yes)
else else
@echo Creating $@ @echo Creating $@
@$(OD) -S $< > $@ @$(OD) -S $< > $@
@echo
@echo Done @echo Done
endif endif

View File

@ -71,13 +71,6 @@
/* Derived constants and error checks. */ /* 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. */ /* Module data structures and types. */
/*===========================================================================*/ /*===========================================================================*/
@ -129,8 +122,8 @@ typedef struct {
/*===========================================================================*/ /*===========================================================================*/
#if CH_DBG_SYSTEM_STATE_CHECK #if CH_DBG_SYSTEM_STATE_CHECK
#define _dbg_enter_lock() (ch.dbg_lock_cnt = 1) #define _dbg_enter_lock() (ch.dbg.lock_cnt = 1)
#define _dbg_leave_lock() (ch.dbg_lock_cnt = 0) #define _dbg_leave_lock() (ch.dbg.lock_cnt = 0)
#endif #endif
/* When the state checker feature is disabled then the following functions /* When the state checker feature is disabled then the following functions
@ -221,7 +214,7 @@ extern "C" {
void chDbgCheckClassS(void); void chDbgCheckClassS(void);
#endif #endif
#if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__) #if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__)
void _trace_init(void); void _dbg_trace_init(void);
void _dbg_trace(thread_t *otp); void _dbg_trace(thread_t *otp);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -284,6 +284,36 @@ struct ch_ready_list {
thread. */ thread. */
}; };
/**
* @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. * @brief System data structure.
* @note This structure contain all the data areas used by the OS except * @note This structure contain all the data areas used by the OS except
@ -298,11 +328,15 @@ struct ch_system {
* @brief Virtual timers delta list header. * @brief Virtual timers delta list header.
*/ */
virtual_timers_list_t vtlist; virtual_timers_list_t vtlist;
/**
* @brief System debug.
*/
system_debug_t dbg;
#if CH_CFG_USE_TM || defined(__DOXYGEN__) #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 #endif
#if CH_DBG_STATISTICS || defined(__DOXYGEN__) #if CH_DBG_STATISTICS || defined(__DOXYGEN__)
/** /**
@ -310,32 +344,6 @@ struct ch_system {
*/ */
kernel_stats_t kernel_stats; kernel_stats_t kernel_stats;
#endif #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
}; };
/*===========================================================================*/ /*===========================================================================*/

View File

@ -97,6 +97,11 @@ typedef struct ch_virtual_timer virtual_timer_t;
*/ */
typedef struct ch_virtual_timers_list virtual_timers_list_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. * @brief Type of system data structure.
*/ */

View File

@ -51,6 +51,16 @@
/* Module data structures and types. */ /* Module data structures and types. */
/*===========================================================================*/ /*===========================================================================*/
/**
* @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. * @brief Type of a Time Measurement object.
* @note The maximum measurable time period depends on the implementation * @note The maximum measurable time period depends on the implementation

View File

@ -114,7 +114,7 @@
*/ */
void _dbg_check_disable(void) { 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"); chSysHalt("SV#1");
} }
@ -125,7 +125,7 @@ void _dbg_check_disable(void) {
*/ */
void _dbg_check_suspend(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"); chSysHalt("SV#2");
} }
@ -136,7 +136,7 @@ void _dbg_check_suspend(void) {
*/ */
void _dbg_check_enable(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"); chSysHalt("SV#3");
} }
@ -147,7 +147,7 @@ void _dbg_check_enable(void) {
*/ */
void _dbg_check_lock(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"); chSysHalt("SV#4");
_dbg_enter_lock(); _dbg_enter_lock();
} }
@ -159,7 +159,7 @@ void _dbg_check_lock(void) {
*/ */
void _dbg_check_unlock(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"); chSysHalt("SV#5");
_dbg_leave_lock(); _dbg_leave_lock();
} }
@ -171,7 +171,7 @@ void _dbg_check_unlock(void) {
*/ */
void _dbg_check_lock_from_isr(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"); chSysHalt("SV#6");
_dbg_enter_lock(); _dbg_enter_lock();
} }
@ -183,7 +183,7 @@ void _dbg_check_lock_from_isr(void) {
*/ */
void _dbg_check_unlock_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"); chSysHalt("SV#7");
_dbg_leave_lock(); _dbg_leave_lock();
} }
@ -196,9 +196,9 @@ void _dbg_check_unlock_from_isr(void) {
void _dbg_check_enter_isr(void) { void _dbg_check_enter_isr(void) {
port_lock_from_isr(); 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"); chSysHalt("SV#8");
ch.dbg_isr_cnt++; ch.dbg.isr_cnt++;
port_unlock_from_isr(); port_unlock_from_isr();
} }
@ -210,9 +210,9 @@ void _dbg_check_enter_isr(void) {
void _dbg_check_leave_isr(void) { void _dbg_check_leave_isr(void) {
port_lock_from_isr(); 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"); chSysHalt("SV#9");
ch.dbg_isr_cnt--; ch.dbg.isr_cnt--;
port_unlock_from_isr(); port_unlock_from_isr();
} }
@ -226,7 +226,7 @@ void _dbg_check_leave_isr(void) {
*/ */
void chDbgCheckClassI(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"); chSysHalt("SV#10");
} }
@ -240,7 +240,7 @@ void chDbgCheckClassI(void) {
*/ */
void chDbgCheckClassS(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"); chSysHalt("SV#11");
} }
@ -251,10 +251,10 @@ void chDbgCheckClassS(void) {
* @brief Trace circular buffer subsystem initialization. * @brief Trace circular buffer subsystem initialization.
* @note Internal use only. * @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_size = CH_DBG_TRACE_BUFFER_SIZE;
ch.dbg_trace_buffer.tb_ptr = &ch.dbg_trace_buffer.tb_buffer[0]; 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) { void _dbg_trace(thread_t *otp) {
ch.dbg_trace_buffer.tb_ptr->se_time = chVTGetSystemTimeX(); 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_tp = currp;
ch.dbg_trace_buffer.tb_ptr->se_wtobjp = otp->p_u.wtobjp; 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; ch.dbg.trace_buffer.tb_ptr->se_state = (uint8_t)otp->p_state;
if (++ch.dbg_trace_buffer.tb_ptr >= if (++ch.dbg.trace_buffer.tb_ptr >=
&ch.dbg_trace_buffer.tb_buffer[CH_DBG_TRACE_BUFFER_SIZE]) &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 = &ch.dbg.trace_buffer.tb_buffer[0];
} }
#endif /* CH_DBG_ENABLE_TRACE */ #endif /* CH_DBG_ENABLE_TRACE */

View File

@ -119,7 +119,7 @@ void chSysInit(void) {
_stats_init(); _stats_init();
#endif #endif
#if CH_DBG_ENABLE_TRACE #if CH_DBG_ENABLE_TRACE
_trace_init(); _dbg_trace_init();
#endif #endif
#if !CH_CFG_NO_IDLE_THREAD #if !CH_CFG_NO_IDLE_THREAD
@ -165,16 +165,13 @@ void chSysHalt(const char *reason) {
port_disable(); port_disable();
#if CH_DBG_ENABLED
ch.dbg_panic_msg = reason;
#else
(void)reason;
#endif
#if defined(CH_CFG_SYSTEM_HALT_HOOK) || defined(__DOXYGEN__) #if defined(CH_CFG_SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
CH_CFG_SYSTEM_HALT_HOOK(reason); CH_CFG_SYSTEM_HALT_HOOK(reason);
#endif #endif
/* Pointing to the passed message.*/
ch.dbg.panic_msg = reason;
/* Harmless infinite loop.*/ /* Harmless infinite loop.*/
while (true) while (true)
; ;

View File

@ -79,11 +79,11 @@ void _tm_init(void) {
/* Time Measurement subsystem calibration, it does a null measurement /* Time Measurement subsystem calibration, it does a null measurement
and calculates the call overhead which is subtracted to real and calculates the call overhead which is subtracted to real
measurements.*/ measurements.*/
ch.measurement_offset = 0; ch.tm.offset = 0;
chTMObjectInit(&tm); chTMObjectInit(&tm);
chTMStartMeasurementX(&tm); chTMStartMeasurementX(&tm);
chTMStopMeasurementX(&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) { NOINLINE void chTMStopMeasurementX(time_measurement_t *tmp) {
tm_stop(tmp, chSysGetRealtimeCounterX(), ch.measurement_offset); tm_stop(tmp, chSysGetRealtimeCounterX(), ch.tm.offset);
} }
/** /**