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

This commit is contained in:
gdisirio 2013-08-17 11:52:50 +00:00
parent 120b97e070
commit 155ef8ed75
25 changed files with 180 additions and 210 deletions

View File

@ -357,7 +357,7 @@
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_STATISTICS) || defined(__DOXYGEN__)
#define CH_DBG_STATISTICS FALSE
#define CH_DBG_STATISTICS TRUE
#endif
/**
@ -391,7 +391,7 @@
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_ASSERTS FALSE
#define CH_DBG_ENABLE_ASSERTS TRUE
#endif
/**
@ -402,7 +402,7 @@
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_TRACE FALSE
#define CH_DBG_ENABLE_TRACE TRUE
#endif
/**
@ -416,7 +416,7 @@
* @p panic_msg variable set to @p NULL.
*/
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_STACK_CHECK FALSE
#define CH_DBG_ENABLE_STACK_CHECK TRUE
#endif
/**
@ -428,7 +428,7 @@
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
#define CH_DBG_FILL_THREADS FALSE
#define CH_DBG_FILL_THREADS TRUE
#endif
/**
@ -548,7 +548,7 @@
* the system is halted.
*/
#if !defined(CH_CFG_SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
#define CH_CFG_SYSTEM_HALT_HOOK() { \
#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
/* System halt code here.*/ \
}
#endif

View File

@ -187,7 +187,7 @@
#define STM32_SPI_SPI1_IRQ_PRIORITY 10
#define STM32_SPI_SPI2_IRQ_PRIORITY 10
#define STM32_SPI_SPI3_IRQ_PRIORITY 10
#define STM32_SPI_DMA_ERROR_HOOK(spip) chSysHalt()
#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
/*
* UART driver system settings.
@ -201,7 +201,7 @@
#define STM32_UART_USART1_DMA_PRIORITY 0
#define STM32_UART_USART2_DMA_PRIORITY 0
#define STM32_UART_USART3_DMA_PRIORITY 0
#define STM32_UART_DMA_ERROR_HOOK(uartp) chSysHalt()
#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
/*
* USB driver system settings.

View File

@ -36,13 +36,6 @@
/* Module exported variables. */
/*===========================================================================*/
/**
* @brief Pointer to a halt error message.
* @note The message is meant to be retrieved by the debugger after the
* system halt caused by an unexpected error.
*/
const char *osal_halt_msg;
/*===========================================================================*/
/* Module local types. */
/*===========================================================================*/
@ -59,26 +52,4 @@ const char *osal_halt_msg;
/* Module exported functions. */
/*===========================================================================*/
/**
* @brief OSAL module initialization.
*
* @api
*/
void osalInit(void) {
}
/**
* @brief System halt with error message.
*
* @param[in] reason the halt message pointer
*
* @api
*/
void osalSysHalt(const char *reason) {
osal_halt_msg = reason;
chSysHalt();
}
/** @} */

View File

@ -55,6 +55,7 @@
#define OSAL_FAILED TRUE
/** @} */
#if 0
/**
* @name Messages
* @{
@ -63,6 +64,7 @@
#define MSG_RESET RDY_RESET
#define MSG_TIMEOUT RDY_TIMEOUT
/** @} */
#endif
#if 0
/**
@ -257,8 +259,7 @@ typedef struct {
#ifdef __cplusplus
extern "C" {
#endif
void osalInit(void);
void osalSysHalt(const char *reason);
#ifdef __cplusplus
}
#endif
@ -267,6 +268,27 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
/**
* @brief OSAL module initialization.
*
* @api
*/
static inline void osalInit(void) {
}
/**
* @brief System halt with error message.
*
* @param[in] reason the halt message pointer
*
* @api
*/
static inline void osalSysHalt(const char *reason) {
chSysHalt(reason);
}
/**
* @brief Enters a critical zone from thread context.
* @note This function cannot be used for reentrant critical zones.

View File

@ -121,7 +121,7 @@
* @brief SPI DMA error hook.
*/
#if !defined(STM32_SPI_DMA_ERROR_HOOK) || defined(__DOXYGEN__)
#define STM32_SPI_DMA_ERROR_HOOK(spip) chSysHalt()
#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
#endif
#if STM32_ADVANCED_DMA || defined(__DOXYGEN__)

View File

@ -123,7 +123,7 @@
* error can only happen because programming errors.
*/
#if !defined(STM32_UART_DMA_ERROR_HOOK) || defined(__DOXYGEN__)
#define STM32_UART_DMA_ERROR_HOOK(uartp) chSysHalt()
#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
#endif
#if STM32_ADVANCED_DMA || defined(__DOXYGEN__)

View File

@ -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. */
/*===========================================================================*/
@ -159,12 +152,6 @@ typedef struct {
#define _dbg_trace(otp)
#endif
/* When the debug features are disabled this function is replaced by an empty
macro.*/
#if !CH_DBG_ENABLED
#define chDbgPanic(msg) {}
#endif
/**
* @name Macro Functions
* @{
@ -183,7 +170,7 @@ typedef struct {
#if !defined(chDbgCheck)
#define chDbgCheck(c) { \
if (!(c)) \
chDbgPanic("C:"__QUOTE_THIS(__FUNCTION__)":"__QUOTE_THIS(__LINE__)); \
chSysHalt("C:"__QUOTE_THIS(__FUNCTION__)":"__QUOTE_THIS(__LINE__)); \
}
#endif /* !defined(chDbgCheck) */
@ -209,7 +196,7 @@ typedef struct {
#if !defined(chDbgAssert)
#define chDbgAssert(c, r) { \
if (!(c)) \
chDbgPanic("A:"__QUOTE_THIS(__FUNCTION__)":"__QUOTE_THIS(__LINE__)); \
chSysHalt("A:"__QUOTE_THIS(__FUNCTION__)":"__QUOTE_THIS(__LINE__)); \
}
#endif /* !defined(chDbgAssert) */
#else /* !CH_DBG_ENABLE_ASSERTS */
@ -241,9 +228,6 @@ extern "C" {
void _trace_init(void);
void _dbg_trace(thread_t *otp);
#endif
#if CH_DBG_ENABLED
void chDbgPanic(const char *msg);
#endif
#ifdef __cplusplus
}
#endif

View File

@ -39,9 +39,9 @@
* @name Queue functions returned status value
* @{
*/
#define Q_OK RDY_OK /**< @brief Operation successful. */
#define Q_TIMEOUT RDY_TIMEOUT /**< @brief Timeout condition. */
#define Q_RESET RDY_RESET /**< @brief Queue has been reset. */
#define Q_OK MSG_OK /**< @brief Operation successful. */
#define Q_TIMEOUT MSG_TIMEOUT /**< @brief Timeout condition. */
#define Q_RESET MSG_RESET /**< @brief Queue has been reset. */
#define Q_EMPTY -3 /**< @brief Queue empty. */
#define Q_FULL -4 /**< @brief Queue full, */
/** @} */

View File

@ -37,10 +37,10 @@
* @name Wakeup status codes
* @{
*/
#define RDY_OK 0 /**< @brief Normal wakeup message. */
#define RDY_TIMEOUT -1 /**< @brief Wakeup caused by a timeout
#define MSG_OK 0 /**< @brief Normal wakeup message. */
#define MSG_TIMEOUT -1 /**< @brief Wakeup caused by a timeout
condition. */
#define RDY_RESET -2 /**< @brief Wakeup caused by a reset
#define MSG_RESET -2 /**< @brief Wakeup caused by a reset
condition. */
/** @} */

View File

@ -216,7 +216,7 @@
extern "C" {
#endif
void chSysInit(void);
void chSysHalt(void);
void chSysHalt(const char *reason);
void chSysTimerHandlerI(void);
syssts_t chSysGetAndLockX(void);
void chSysRestoreLockX(syssts_t sts);

View File

@ -373,7 +373,7 @@ struct context {
#define port_switch(ntp, otp) { \
struct intctx *r13 = (struct intctx *)__get_PSP(); \
if ((stkalign_t *)(r13 - 1) < otp->p_stklimit) \
chDbgPanic("stack overflow"); \
chSysHalt("stack overflow"); \
_port_switch(ntp, otp); \
}
#endif

View File

@ -93,7 +93,7 @@ void chCondSignal(condition_variable_t *cp) {
chSysLock();
if (queue_notempty(&cp->c_queue))
chSchWakeupS(queue_fifo_remove(&cp->c_queue), RDY_OK);
chSchWakeupS(queue_fifo_remove(&cp->c_queue), MSG_OK);
chSysUnlock();
}
@ -115,7 +115,7 @@ void chCondSignalI(condition_variable_t *cp) {
if (queue_notempty(&cp->c_queue)) {
thread_t *tp = queue_fifo_remove(&cp->c_queue);
tp->p_u.rdymsg = RDY_OK;
tp->p_u.rdymsg = MSG_OK;
chSchReadyI(tp);
}
}
@ -152,10 +152,10 @@ void chCondBroadcastI(condition_variable_t *cp) {
chDbgCheck(cp != NULL);
/* Empties the condition variable queue and inserts all the threads into the
ready list in FIFO order. The wakeup message is set to @p RDY_RESET in
ready list in FIFO order. The wakeup message is set to @p MSG_RESET in
order to make a chCondBroadcast() detectable from a chCondSignal().*/
while (cp->c_queue.p_next != (void *)&cp->c_queue)
chSchReadyI(queue_fifo_remove(&cp->c_queue))->p_u.rdymsg = RDY_RESET;
chSchReadyI(queue_fifo_remove(&cp->c_queue))->p_u.rdymsg = MSG_RESET;
}
/**
@ -168,9 +168,9 @@ void chCondBroadcastI(condition_variable_t *cp) {
* @param[in] cp pointer to the @p condition_variable_t structure
* @return A message specifying how the invoking thread has been
* released from the condition variable.
* @retval RDY_OK if the condition variable has been signaled using
* @retval MSG_OK if the condition variable has been signaled using
* @p chCondSignal().
* @retval RDY_RESET if the condition variable has been signaled using
* @retval MSG_RESET if the condition variable has been signaled using
* @p chCondBroadcast().
*
* @api
@ -194,9 +194,9 @@ msg_t chCondWait(condition_variable_t *cp) {
* @param[in] cp pointer to the @p condition_variable_t structure
* @return A message specifying how the invoking thread has been
* released from the condition variable.
* @retval RDY_OK if the condition variable has been signaled using
* @retval MSG_OK if the condition variable has been signaled using
* @p chCondSignal().
* @retval RDY_RESET if the condition variable has been signaled using
* @retval MSG_RESET if the condition variable has been signaled using
* @p chCondBroadcast().
*
* @sclass
@ -239,11 +239,11 @@ msg_t chCondWaitS(condition_variable_t *cp) {
* .
* @return A message specifying how the invoking thread has been
* released from the condition variable.
* @retval RDY_OK if the condition variable has been signaled using
* @retval MSG_OK if the condition variable has been signaled using
* @p chCondSignal().
* @retval RDY_RESET if the condition variable has been signaled using
* @retval MSG_RESET if the condition variable has been signaled using
* @p chCondBroadcast().
* @retval RDY_TIMEOUT if the condition variable has not been signaled within
* @retval MSG_TIMEOUT if the condition variable has not been signaled within
* the specified timeout.
*
* @api
@ -276,11 +276,11 @@ msg_t chCondWaitTimeout(condition_variable_t *cp, systime_t time) {
* .
* @return A message specifying how the invoking thread has been
* released from the condition variable.
* @retval RDY_OK if the condition variable has been signaled using
* @retval MSG_OK if the condition variable has been signaled using
* @p chCondSignal().
* @retval RDY_RESET if the condition variable has been signaled using
* @retval MSG_RESET if the condition variable has been signaled using
* @p chCondBroadcast().
* @retval RDY_TIMEOUT if the condition variable has not been signaled within
* @retval MSG_TIMEOUT if the condition variable has not been signaled within
* the specified timeout.
*
* @sclass
@ -297,7 +297,7 @@ msg_t chCondWaitTimeoutS(condition_variable_t *cp, systime_t time) {
currp->p_u.wtobjp = cp;
queue_prio_insert(currp, &cp->c_queue);
msg = chSchGoSleepTimeoutS(CH_STATE_WTCOND, time);
if (msg != RDY_TIMEOUT)
if (msg != MSG_TIMEOUT)
chMtxLockS(mp);
return msg;
}

View File

@ -83,7 +83,7 @@
void _dbg_check_disable(void) {
if ((ch.dbg_isr_cnt != 0) || (ch.dbg_lock_cnt != 0))
chDbgPanic("SV#1");
chSysHalt("SV#1");
}
/**
@ -94,7 +94,7 @@ void _dbg_check_disable(void) {
void _dbg_check_suspend(void) {
if ((ch.dbg_isr_cnt != 0) || (ch.dbg_lock_cnt != 0))
chDbgPanic("SV#2");
chSysHalt("SV#2");
}
/**
@ -105,7 +105,7 @@ void _dbg_check_suspend(void) {
void _dbg_check_enable(void) {
if ((ch.dbg_isr_cnt != 0) || (ch.dbg_lock_cnt != 0))
chDbgPanic("SV#3");
chSysHalt("SV#3");
}
/**
@ -116,7 +116,7 @@ void _dbg_check_enable(void) {
void _dbg_check_lock(void) {
if ((ch.dbg_isr_cnt != 0) || (ch.dbg_lock_cnt != 0))
chDbgPanic("SV#4");
chSysHalt("SV#4");
_dbg_enter_lock();
}
@ -128,7 +128,7 @@ void _dbg_check_lock(void) {
void _dbg_check_unlock(void) {
if ((ch.dbg_isr_cnt != 0) || (ch.dbg_lock_cnt <= 0))
chDbgPanic("SV#5");
chSysHalt("SV#5");
_dbg_leave_lock();
}
@ -140,7 +140,7 @@ void _dbg_check_unlock(void) {
void _dbg_check_lock_from_isr(void) {
if ((ch.dbg_isr_cnt <= 0) || (ch.dbg_lock_cnt != 0))
chDbgPanic("SV#6");
chSysHalt("SV#6");
_dbg_enter_lock();
}
@ -152,7 +152,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))
chDbgPanic("SV#7");
chSysHalt("SV#7");
_dbg_leave_lock();
}
@ -165,7 +165,7 @@ void _dbg_check_enter_isr(void) {
port_lock_from_isr();
if ((ch.dbg_isr_cnt < 0) || (ch.dbg_lock_cnt != 0))
chDbgPanic("SV#8");
chSysHalt("SV#8");
ch.dbg_isr_cnt++;
port_unlock_from_isr();
}
@ -179,7 +179,7 @@ void _dbg_check_leave_isr(void) {
port_lock_from_isr();
if ((ch.dbg_isr_cnt <= 0) || (ch.dbg_lock_cnt != 0))
chDbgPanic("SV#9");
chSysHalt("SV#9");
ch.dbg_isr_cnt--;
port_unlock_from_isr();
}
@ -195,7 +195,7 @@ void _dbg_check_leave_isr(void) {
void chDbgCheckClassI(void) {
if ((ch.dbg_isr_cnt < 0) || (ch.dbg_lock_cnt <= 0))
chDbgPanic("SV#10");
chSysHalt("SV#10");
}
/**
@ -209,7 +209,7 @@ void chDbgCheckClassI(void) {
void chDbgCheckClassS(void) {
if ((ch.dbg_isr_cnt != 0) || (ch.dbg_lock_cnt <= 0))
chDbgPanic("SV#11");
chSysHalt("SV#11");
}
#endif /* CH_DBG_SYSTEM_STATE_CHECK */
@ -244,17 +244,4 @@ void _dbg_trace(thread_t *otp) {
}
#endif /* CH_DBG_ENABLE_TRACE */
#if CH_DBG_ENABLED || defined(__DOXYGEN__)
/**
* @brief Prints a panic message on the console and then halts the system.
*
* @param[in] msg the pointer to the panic message string
*/
void chDbgPanic(const char *msg) {
ch.dbg_panic_msg = msg;
chSysHalt();
}
#endif /* CH_DBG_ENABLED */
/** @} */

View File

@ -165,7 +165,7 @@ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size,
chSysLock();
tp = chThdCreateI(wsp, size, prio, pf, arg);
tp->p_flags = CH_FLAG_MODE_HEAP;
chSchWakeupS(tp, RDY_OK);
chSchWakeupS(tp, MSG_OK);
chSysUnlock();
return tp;
}
@ -217,7 +217,7 @@ thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio,
tp = chThdCreateI(wsp, mp->mp_object_size, prio, pf, arg);
tp->p_flags = CH_FLAG_MODE_MEMPOOL;
tp->p_mpool = mp;
chSchWakeupS(tp, RDY_OK);
chSchWakeupS(tp, MSG_OK);
chSysUnlock();
return tp;
}

View File

@ -279,7 +279,7 @@ void chEvtSignalI(thread_t *tp, eventmask_t mask) {
((tp->p_epending & tp->p_u.ewmask) != 0)) ||
((tp->p_state == CH_STATE_WTANDEVT) &&
((tp->p_epending & tp->p_u.ewmask) == tp->p_u.ewmask))) {
tp->p_u.rdymsg = RDY_OK;
tp->p_u.rdymsg = MSG_OK;
chSchReadyI(tp);
}
}
@ -475,7 +475,7 @@ eventmask_t chEvtWaitOneTimeout(eventmask_t mask, systime_t time) {
return (eventmask_t)0;
}
ctp->p_u.ewmask = mask;
if (chSchGoSleepTimeoutS(CH_STATE_WTOREVT, time) < RDY_OK) {
if (chSchGoSleepTimeoutS(CH_STATE_WTOREVT, time) < MSG_OK) {
chSysUnlock();
return (eventmask_t)0;
}
@ -518,7 +518,7 @@ eventmask_t chEvtWaitAnyTimeout(eventmask_t mask, systime_t time) {
return (eventmask_t)0;
}
ctp->p_u.ewmask = mask;
if (chSchGoSleepTimeoutS(CH_STATE_WTOREVT, time) < RDY_OK) {
if (chSchGoSleepTimeoutS(CH_STATE_WTOREVT, time) < MSG_OK) {
chSysUnlock();
return (eventmask_t)0;
}
@ -558,7 +558,7 @@ eventmask_t chEvtWaitAllTimeout(eventmask_t mask, systime_t time) {
return (eventmask_t)0;
}
ctp->p_u.ewmask = mask;
if (chSchGoSleepTimeoutS(CH_STATE_WTANDEVT, time) < RDY_OK) {
if (chSchGoSleepTimeoutS(CH_STATE_WTANDEVT, time) < MSG_OK) {
chSysUnlock();
return (eventmask_t)0;
}

View File

@ -67,7 +67,7 @@
* .
* @return The message from @p osalQueueWakeupOneI() or
* @p osalQueueWakeupAllI() functions.
* @retval RDY_TIMEOUT if the thread has not been dequeued within the
* @retval MSG_TIMEOUT if the thread has not been dequeued within the
* specified timeout or if the function has been
* invoked with @p TIME_IMMEDIATE as timeout
* specification.
@ -77,7 +77,7 @@
msg_t chQueueGoSleepTimeoutS(threads_queue_t *tqp, systime_t time) {
if (TIME_IMMEDIATE == time)
return RDY_TIMEOUT;
return MSG_TIMEOUT;
queue_insert(currp, tqp);
return chSchGoSleepTimeoutS(CH_STATE_QUEUED, time);

View File

@ -96,7 +96,7 @@ void chMBObjectInit(mailbox_t *mbp, msg_t *buf, cnt_t n) {
/**
* @brief Resets a @p mailbox_t object.
* @details All the waiting threads are resumed with status @p RDY_RESET and
* @details All the waiting threads are resumed with status @p MSG_RESET and
* the queued messages are lost.
*
* @param[in] mbp the pointer to an initialized @p mailbox_t object
@ -128,9 +128,9 @@ void chMBReset(mailbox_t *mbp) {
* - @a TIME_INFINITE no timeout.
* .
* @return The operation status.
* @retval RDY_OK if a message has been correctly posted.
* @retval RDY_RESET if the mailbox has been reset while waiting.
* @retval RDY_TIMEOUT if the operation has timed out.
* @retval MSG_OK if a message has been correctly posted.
* @retval MSG_RESET if the mailbox has been reset while waiting.
* @retval MSG_TIMEOUT if the operation has timed out.
*
* @api
*/
@ -156,9 +156,9 @@ msg_t chMBPost(mailbox_t *mbp, msg_t msg, systime_t time) {
* - @a TIME_INFINITE no timeout.
* .
* @return The operation status.
* @retval RDY_OK if a message has been correctly posted.
* @retval RDY_RESET if the mailbox has been reset while waiting.
* @retval RDY_TIMEOUT if the operation has timed out.
* @retval MSG_OK if a message has been correctly posted.
* @retval MSG_RESET if the mailbox has been reset while waiting.
* @retval MSG_TIMEOUT if the operation has timed out.
*
* @sclass
*/
@ -169,7 +169,7 @@ msg_t chMBPostS(mailbox_t *mbp, msg_t msg, systime_t time) {
chDbgCheck(mbp != NULL);
rdymsg = chSemWaitTimeoutS(&mbp->mb_emptysem, time);
if (rdymsg == RDY_OK) {
if (rdymsg == MSG_OK) {
*mbp->mb_wrptr++ = msg;
if (mbp->mb_wrptr >= mbp->mb_top)
mbp->mb_wrptr = mbp->mb_buffer;
@ -187,8 +187,8 @@ msg_t chMBPostS(mailbox_t *mbp, msg_t msg, systime_t time) {
* @param[in] mbp the pointer to an initialized @p mailbox_t object
* @param[in] msg the message to be posted on the mailbox
* @return The operation status.
* @retval RDY_OK if a message has been correctly posted.
* @retval RDY_TIMEOUT if the mailbox is full and the message cannot be
* @retval MSG_OK if a message has been correctly posted.
* @retval MSG_TIMEOUT if the mailbox is full and the message cannot be
* posted.
*
* @iclass
@ -199,13 +199,13 @@ msg_t chMBPostI(mailbox_t *mbp, msg_t msg) {
chDbgCheck(mbp != NULL);
if (chSemGetCounterI(&mbp->mb_emptysem) <= 0)
return RDY_TIMEOUT;
return MSG_TIMEOUT;
chSemFastWaitI(&mbp->mb_emptysem);
*mbp->mb_wrptr++ = msg;
if (mbp->mb_wrptr >= mbp->mb_top)
mbp->mb_wrptr = mbp->mb_buffer;
chSemSignalI(&mbp->mb_fullsem);
return RDY_OK;
return MSG_OK;
}
/**
@ -221,9 +221,9 @@ msg_t chMBPostI(mailbox_t *mbp, msg_t msg) {
* - @a TIME_INFINITE no timeout.
* .
* @return The operation status.
* @retval RDY_OK if a message has been correctly posted.
* @retval RDY_RESET if the mailbox has been reset while waiting.
* @retval RDY_TIMEOUT if the operation has timed out.
* @retval MSG_OK if a message has been correctly posted.
* @retval MSG_RESET if the mailbox has been reset while waiting.
* @retval MSG_TIMEOUT if the operation has timed out.
*
* @api
*/
@ -249,9 +249,9 @@ msg_t chMBPostAhead(mailbox_t *mbp, msg_t msg, systime_t time) {
* - @a TIME_INFINITE no timeout.
* .
* @return The operation status.
* @retval RDY_OK if a message has been correctly posted.
* @retval RDY_RESET if the mailbox has been reset while waiting.
* @retval RDY_TIMEOUT if the operation has timed out.
* @retval MSG_OK if a message has been correctly posted.
* @retval MSG_RESET if the mailbox has been reset while waiting.
* @retval MSG_TIMEOUT if the operation has timed out.
*
* @sclass
*/
@ -262,7 +262,7 @@ msg_t chMBPostAheadS(mailbox_t *mbp, msg_t msg, systime_t time) {
chDbgCheck(mbp != NULL);
rdymsg = chSemWaitTimeoutS(&mbp->mb_emptysem, time);
if (rdymsg == RDY_OK) {
if (rdymsg == MSG_OK) {
if (--mbp->mb_rdptr < mbp->mb_buffer)
mbp->mb_rdptr = mbp->mb_top - 1;
*mbp->mb_rdptr = msg;
@ -280,8 +280,8 @@ msg_t chMBPostAheadS(mailbox_t *mbp, msg_t msg, systime_t time) {
* @param[in] mbp the pointer to an initialized @p mailbox_t object
* @param[in] msg the message to be posted on the mailbox
* @return The operation status.
* @retval RDY_OK if a message has been correctly posted.
* @retval RDY_TIMEOUT if the mailbox is full and the message cannot be
* @retval MSG_OK if a message has been correctly posted.
* @retval MSG_TIMEOUT if the mailbox is full and the message cannot be
* posted.
*
* @iclass
@ -292,13 +292,13 @@ msg_t chMBPostAheadI(mailbox_t *mbp, msg_t msg) {
chDbgCheck(mbp != NULL);
if (chSemGetCounterI(&mbp->mb_emptysem) <= 0)
return RDY_TIMEOUT;
return MSG_TIMEOUT;
chSemFastWaitI(&mbp->mb_emptysem);
if (--mbp->mb_rdptr < mbp->mb_buffer)
mbp->mb_rdptr = mbp->mb_top - 1;
*mbp->mb_rdptr = msg;
chSemSignalI(&mbp->mb_fullsem);
return RDY_OK;
return MSG_OK;
}
/**
@ -314,9 +314,9 @@ msg_t chMBPostAheadI(mailbox_t *mbp, msg_t msg) {
* - @a TIME_INFINITE no timeout.
* .
* @return The operation status.
* @retval RDY_OK if a message has been correctly fetched.
* @retval RDY_RESET if the mailbox has been reset while waiting.
* @retval RDY_TIMEOUT if the operation has timed out.
* @retval MSG_OK if a message has been correctly fetched.
* @retval MSG_RESET if the mailbox has been reset while waiting.
* @retval MSG_TIMEOUT if the operation has timed out.
*
* @api
*/
@ -342,9 +342,9 @@ msg_t chMBFetch(mailbox_t *mbp, msg_t *msgp, systime_t time) {
* - @a TIME_INFINITE no timeout.
* .
* @return The operation status.
* @retval RDY_OK if a message has been correctly fetched.
* @retval RDY_RESET if the mailbox has been reset while waiting.
* @retval RDY_TIMEOUT if the operation has timed out.
* @retval MSG_OK if a message has been correctly fetched.
* @retval MSG_RESET if the mailbox has been reset while waiting.
* @retval MSG_TIMEOUT if the operation has timed out.
*
* @sclass
*/
@ -355,7 +355,7 @@ msg_t chMBFetchS(mailbox_t *mbp, msg_t *msgp, systime_t time) {
chDbgCheck((mbp != NULL) && (msgp != NULL));
rdymsg = chSemWaitTimeoutS(&mbp->mb_fullsem, time);
if (rdymsg == RDY_OK) {
if (rdymsg == MSG_OK) {
*msgp = *mbp->mb_rdptr++;
if (mbp->mb_rdptr >= mbp->mb_top)
mbp->mb_rdptr = mbp->mb_buffer;
@ -373,8 +373,8 @@ msg_t chMBFetchS(mailbox_t *mbp, msg_t *msgp, systime_t time) {
* @param[in] mbp the pointer to an initialized @p mailbox_t object
* @param[out] msgp pointer to a message variable for the received message
* @return The operation status.
* @retval RDY_OK if a message has been correctly fetched.
* @retval RDY_TIMEOUT if the mailbox is empty and a message cannot be
* @retval MSG_OK if a message has been correctly fetched.
* @retval MSG_TIMEOUT if the mailbox is empty and a message cannot be
* fetched.
*
* @iclass
@ -385,13 +385,13 @@ msg_t chMBFetchI(mailbox_t *mbp, msg_t *msgp) {
chDbgCheck((mbp != NULL) && (msgp != NULL));
if (chSemGetCounterI(&mbp->mb_fullsem) <= 0)
return RDY_TIMEOUT;
return MSG_TIMEOUT;
chSemFastWaitI(&mbp->mb_fullsem);
*msgp = *mbp->mb_rdptr++;
if (mbp->mb_rdptr >= mbp->mb_top)
mbp->mb_rdptr = mbp->mb_buffer;
chSemSignalI(&mbp->mb_emptysem);
return RDY_OK;
return MSG_OK;
}
#endif /* CH_CFG_USE_MAILBOXES */

View File

@ -315,7 +315,7 @@ mutex_t *chMtxUnlock(void) {
ump->m_owner = tp;
ump->m_next = tp->p_mtxlist;
tp->p_mtxlist = ump;
chSchWakeupS(tp, RDY_OK);
chSchWakeupS(tp, MSG_OK);
}
else
ump->m_owner = NULL;

View File

@ -159,7 +159,7 @@ static void wakeup(void *p) {
/* States requiring dequeuing.*/
queue_dequeue(tp);
}
tp->p_u.rdymsg = RDY_TIMEOUT;
tp->p_u.rdymsg = MSG_TIMEOUT;
chSchReadyI(tp);
chSysUnlockFromISR();
}
@ -169,7 +169,7 @@ static void wakeup(void *p) {
* timeout specification.
* @details The thread goes into a sleeping state, if it is not awakened
* explicitly within the specified timeout then it is forcibly
* awakened with a @p RDY_TIMEOUT low level message. The possible
* awakened with a @p MSG_TIMEOUT low level message. The possible
* @ref thread_states are defined into @p threads.h.
*
* @param[in] newstate the new thread state
@ -181,7 +181,7 @@ static void wakeup(void *p) {
* - @a TIME_IMMEDIATE this value is not allowed.
* .
* @return The wakeup message.
* @retval RDY_TIMEOUT if a timeout occurs.
* @retval MSG_TIMEOUT if a timeout occurs.
*
* @sclass
*/

View File

@ -111,7 +111,7 @@ void chSemObjectInit(semaphore_t *sp, cnt_t n) {
* to the specified, non negative, value.
* @note The released threads can recognize they were waked up by a reset
* rather than a signal because the @p chSemWait() will return
* @p RDY_RESET instead of @p RDY_OK.
* @p MSG_RESET instead of @p MSG_OK.
*
* @param[in] sp pointer to a @p semaphore_t structure
* @param[in] n the new value of the semaphore counter. The value must
@ -138,7 +138,7 @@ void chSemReset(semaphore_t *sp, cnt_t n) {
* reschedule must not be performed in ISRs.
* @note The released threads can recognize they were waked up by a reset
* rather than a signal because the @p chSemWait() will return
* @p RDY_RESET instead of @p RDY_OK.
* @p MSG_RESET instead of @p MSG_OK.
*
* @param[in] sp pointer to a @p semaphore_t structure
* @param[in] n the new value of the semaphore counter. The value must
@ -158,7 +158,7 @@ void chSemResetI(semaphore_t *sp, cnt_t n) {
cnt = sp->s_cnt;
sp->s_cnt = n;
while (++cnt <= 0)
chSchReadyI(queue_lifo_remove(&sp->s_queue))->p_u.rdymsg = RDY_RESET;
chSchReadyI(queue_lifo_remove(&sp->s_queue))->p_u.rdymsg = MSG_RESET;
}
/**
@ -167,9 +167,9 @@ void chSemResetI(semaphore_t *sp, cnt_t n) {
* @param[in] sp pointer to a @p semaphore_t structure
* @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the thread has not stopped on the semaphore or the
* @retval MSG_OK if the thread has not stopped on the semaphore or the
* semaphore has been signaled.
* @retval RDY_RESET if the semaphore has been reset using @p chSemReset().
* @retval MSG_RESET if the semaphore has been reset using @p chSemReset().
*
* @api
*/
@ -188,9 +188,9 @@ msg_t chSemWait(semaphore_t *sp) {
* @param[in] sp pointer to a @p semaphore_t structure
* @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the thread has not stopped on the semaphore or the
* @retval MSG_OK if the thread has not stopped on the semaphore or the
* semaphore has been signaled.
* @retval RDY_RESET if the semaphore has been reset using @p chSemReset().
* @retval MSG_RESET if the semaphore has been reset using @p chSemReset().
*
* @sclass
*/
@ -208,7 +208,7 @@ msg_t chSemWaitS(semaphore_t *sp) {
chSchGoSleepS(CH_STATE_WTSEM);
return currp->p_u.rdymsg;
}
return RDY_OK;
return MSG_OK;
}
/**
@ -222,10 +222,10 @@ msg_t chSemWaitS(semaphore_t *sp) {
* .
* @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the thread has not stopped on the semaphore or the
* @retval MSG_OK if the thread has not stopped on the semaphore or the
* semaphore has been signaled.
* @retval RDY_RESET if the semaphore has been reset using @p chSemReset().
* @retval RDY_TIMEOUT if the semaphore has not been signaled or reset within
* @retval MSG_RESET if the semaphore has been reset using @p chSemReset().
* @retval MSG_TIMEOUT if the semaphore has not been signaled or reset within
* the specified timeout.
*
* @api
@ -250,10 +250,10 @@ msg_t chSemWaitTimeout(semaphore_t *sp, systime_t time) {
* .
* @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the thread has not stopped on the semaphore or the
* @retval MSG_OK if the thread has not stopped on the semaphore or the
* semaphore has been signaled.
* @retval RDY_RESET if the semaphore has been reset using @p chSemReset().
* @retval RDY_TIMEOUT if the semaphore has not been signaled or reset within
* @retval MSG_RESET if the semaphore has been reset using @p chSemReset().
* @retval MSG_TIMEOUT if the semaphore has not been signaled or reset within
* the specified timeout.
*
* @sclass
@ -269,13 +269,13 @@ msg_t chSemWaitTimeoutS(semaphore_t *sp, systime_t time) {
if (--sp->s_cnt < 0) {
if (TIME_IMMEDIATE == time) {
sp->s_cnt++;
return RDY_TIMEOUT;
return MSG_TIMEOUT;
}
currp->p_u.wtobjp = sp;
sem_insert(currp, &sp->s_queue);
return chSchGoSleepTimeoutS(CH_STATE_WTSEM, time);
}
return RDY_OK;
return MSG_OK;
}
/**
@ -294,7 +294,7 @@ void chSemSignal(semaphore_t *sp) {
chSysLock();
if (++sp->s_cnt <= 0)
chSchWakeupS(queue_fifo_remove(&sp->s_queue), RDY_OK);
chSchWakeupS(queue_fifo_remove(&sp->s_queue), MSG_OK);
chSysUnlock();
}
@ -321,7 +321,7 @@ void chSemSignalI(semaphore_t *sp) {
/* Note, it is done this way in order to allow a tail call on
chSchReadyI().*/
thread_t *tp = queue_fifo_remove(&sp->s_queue);
tp->p_u.rdymsg = RDY_OK;
tp->p_u.rdymsg = MSG_OK;
chSchReadyI(tp);
}
}
@ -349,7 +349,7 @@ void chSemAddCounterI(semaphore_t *sp, cnt_t n) {
while (n > 0) {
if (++sp->s_cnt <= 0)
chSchReadyI(queue_fifo_remove(&sp->s_queue))->p_u.rdymsg = RDY_OK;
chSchReadyI(queue_fifo_remove(&sp->s_queue))->p_u.rdymsg = MSG_OK;
n--;
}
}
@ -361,9 +361,9 @@ void chSemAddCounterI(semaphore_t *sp, cnt_t n) {
* @param[in] spw pointer to a @p semaphore_t structure to wait on
* @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the thread has not stopped on the semaphore or the
* @retval MSG_OK if the thread has not stopped on the semaphore or the
* semaphore has been signaled.
* @retval RDY_RESET if the semaphore has been reset using @p chSemReset().
* @retval MSG_RESET if the semaphore has been reset using @p chSemReset().
*
* @api
*/
@ -380,7 +380,7 @@ msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw) {
chSysLock();
if (++sps->s_cnt <= 0)
chSchReadyI(queue_fifo_remove(&sps->s_queue))->p_u.rdymsg = RDY_OK;
chSchReadyI(queue_fifo_remove(&sps->s_queue))->p_u.rdymsg = MSG_OK;
if (--spw->s_cnt < 0) {
thread_t *ctp = currp;
sem_insert(ctp, &spw->s_queue);
@ -390,7 +390,7 @@ msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw) {
}
else {
chSchRescheduleS();
msg = RDY_OK;
msg = MSG_OK;
}
chSysUnlock();
return msg;

View File

@ -166,12 +166,18 @@ void chSysInit(void) {
*
* @special
*/
void chSysHalt(void) {
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();
CH_CFG_SYSTEM_HALT_HOOK(reason);
#endif
/* Harmless infinite loop.*/

View File

@ -217,7 +217,7 @@ thread_t *chThdCreateStatic(void *wsp, size_t size,
CH_DBG_STACK_FILL_VALUE);
#endif
chSysLock();
chSchWakeupS(tp = chThdCreateI(wsp, size, prio, pf, arg), RDY_OK);
chSchWakeupS(tp = chThdCreateI(wsp, size, prio, pf, arg), MSG_OK);
chSysUnlock();
return tp;
}

View File

@ -209,7 +209,7 @@ msg_t thread4(void *p) {
do {
chSchGoSleepS(CH_STATE_SUSPENDED);
msg = self->p_u.rdymsg;
} while (msg == RDY_OK);
} while (msg == MSG_OK);
chSysUnlock();
return 0;
}
@ -225,10 +225,10 @@ static void bmk4_execute(void) {
test_start_timer(1000);
do {
chSysLock();
chSchWakeupS(tp, RDY_OK);
chSchWakeupS(tp, RDY_OK);
chSchWakeupS(tp, RDY_OK);
chSchWakeupS(tp, RDY_OK);
chSchWakeupS(tp, MSG_OK);
chSchWakeupS(tp, MSG_OK);
chSchWakeupS(tp, MSG_OK);
chSchWakeupS(tp, MSG_OK);
chSysUnlock();
n += 4;
#if defined(SIMULATOR)
@ -236,7 +236,7 @@ static void bmk4_execute(void) {
#endif
} while (!test_timer_done);
chSysLock();
chSchWakeupS(tp, RDY_TIMEOUT);
chSchWakeupS(tp, MSG_TIMEOUT);
chSysUnlock();
test_wait_threads();

View File

@ -87,26 +87,26 @@ static void mbox1_execute(void) {
*/
for (i = 0; i < MB_SIZE - 1; i++) {
msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE);
test_assert(2, msg1 == RDY_OK, "wrong wake-up message");
test_assert(2, msg1 == MSG_OK, "wrong wake-up message");
}
msg1 = chMBPostAhead(&mb1, 'A', TIME_INFINITE);
test_assert(3, msg1 == RDY_OK, "wrong wake-up message");
test_assert(3, msg1 == MSG_OK, "wrong wake-up message");
/*
* Testing post timeout.
*/
msg1 = chMBPost(&mb1, 'X', 1);
test_assert(4, msg1 == RDY_TIMEOUT, "wrong wake-up message");
test_assert(4, msg1 == MSG_TIMEOUT, "wrong wake-up message");
chSysLock();
msg1 = chMBPostI(&mb1, 'X');
chSysUnlock();
test_assert(5, msg1 == RDY_TIMEOUT, "wrong wake-up message");
test_assert(5, msg1 == MSG_TIMEOUT, "wrong wake-up message");
msg1 = chMBPostAhead(&mb1, 'X', 1);
test_assert(6, msg1 == RDY_TIMEOUT, "wrong wake-up message");
test_assert(6, msg1 == MSG_TIMEOUT, "wrong wake-up message");
chSysLock();
msg1 = chMBPostAheadI(&mb1, 'X');
chSysUnlock();
test_assert(7, msg1 == RDY_TIMEOUT, "wrong wake-up message");
test_assert(7, msg1 == MSG_TIMEOUT, "wrong wake-up message");
/*
* Testing final conditions.
@ -120,7 +120,7 @@ static void mbox1_execute(void) {
*/
for (i = 0; i < MB_SIZE; i++) {
msg1 = chMBFetch(&mb1, &msg2, TIME_INFINITE);
test_assert(11, msg1 == RDY_OK, "wrong wake-up message");
test_assert(11, msg1 == MSG_OK, "wrong wake-up message");
test_emit_token(msg2);
}
test_assert_sequence(12, "ABCDE");
@ -129,9 +129,9 @@ static void mbox1_execute(void) {
* Testing buffer circularity.
*/
msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE);
test_assert(13, msg1 == RDY_OK, "wrong wake-up message");
test_assert(13, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBFetch(&mb1, &msg2, TIME_INFINITE);
test_assert(14, msg1 == RDY_OK, "wrong wake-up message");
test_assert(14, msg1 == MSG_OK, "wrong wake-up message");
test_assert(15, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base");
test_assert(16, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base");
@ -139,11 +139,11 @@ static void mbox1_execute(void) {
* Testing fetch timeout.
*/
msg1 = chMBFetch(&mb1, &msg2, 1);
test_assert(17, msg1 == RDY_TIMEOUT, "wrong wake-up message");
test_assert(17, msg1 == MSG_TIMEOUT, "wrong wake-up message");
chSysLock();
msg1 = chMBFetchI(&mb1, &msg2);
chSysUnlock();
test_assert(18, msg1 == RDY_TIMEOUT, "wrong wake-up message");
test_assert(18, msg1 == MSG_TIMEOUT, "wrong wake-up message");
/*
* Testing final conditions.
@ -157,22 +157,22 @@ static void mbox1_execute(void) {
*/
chSysLock();
msg1 = chMBPostI(&mb1, 'A');
test_assert(22, msg1 == RDY_OK, "wrong wake-up message");
test_assert(22, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostI(&mb1, 'B');
test_assert(23, msg1 == RDY_OK, "wrong wake-up message");
test_assert(23, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostI(&mb1, 'C');
test_assert(24, msg1 == RDY_OK, "wrong wake-up message");
test_assert(24, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostI(&mb1, 'D');
test_assert(25, msg1 == RDY_OK, "wrong wake-up message");
test_assert(25, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostI(&mb1, 'E');
chSysUnlock();
test_assert(26, msg1 == RDY_OK, "wrong wake-up message");
test_assert(26, msg1 == MSG_OK, "wrong wake-up message");
test_assert(27, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
for (i = 0; i < MB_SIZE; i++) {
chSysLock();
msg1 = chMBFetchI(&mb1, &msg2);
chSysUnlock();
test_assert(28, msg1 == RDY_OK, "wrong wake-up message");
test_assert(28, msg1 == MSG_OK, "wrong wake-up message");
test_emit_token(msg2);
}
test_assert_sequence(29, "ABCDE");
@ -182,22 +182,22 @@ static void mbox1_execute(void) {
chSysLock();
msg1 = chMBPostAheadI(&mb1, 'E');
test_assert(33, msg1 == RDY_OK, "wrong wake-up message");
test_assert(33, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'D');
test_assert(34, msg1 == RDY_OK, "wrong wake-up message");
test_assert(34, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'C');
test_assert(35, msg1 == RDY_OK, "wrong wake-up message");
test_assert(35, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'B');
test_assert(36, msg1 == RDY_OK, "wrong wake-up message");
test_assert(36, msg1 == MSG_OK, "wrong wake-up message");
msg1 = chMBPostAheadI(&mb1, 'A');
chSysUnlock();
test_assert(37, msg1 == RDY_OK, "wrong wake-up message");
test_assert(37, msg1 == MSG_OK, "wrong wake-up message");
test_assert(38, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
for (i = 0; i < MB_SIZE; i++) {
chSysLock();
msg1 = chMBFetchI(&mb1, &msg2);
chSysUnlock();
test_assert(39, msg1 == RDY_OK, "wrong wake-up message");
test_assert(39, msg1 == MSG_OK, "wrong wake-up message");
test_emit_token(msg2);
}
test_assert_sequence(40, "ABCDE");

View File

@ -150,7 +150,7 @@ static void sem2_execute(void) {
* Testing special case TIME_IMMEDIATE.
*/
msg = chSemWaitTimeout(&sem1, TIME_IMMEDIATE);
test_assert(1, msg == RDY_TIMEOUT, "wrong wake-up message");
test_assert(1, msg == MSG_TIMEOUT, "wrong wake-up message");
test_assert(2, queue_isempty(&sem1.s_queue), "queue not empty");
test_assert(3, sem1.s_cnt == 0, "counter not zero");
@ -161,7 +161,7 @@ static void sem2_execute(void) {
thread2, 0);
msg = chSemWaitTimeout(&sem1, MS2ST(500));
test_wait_threads();
test_assert(4, msg == RDY_OK, "wrong wake-up message");
test_assert(4, msg == MSG_OK, "wrong wake-up message");
test_assert(5, queue_isempty(&sem1.s_queue), "queue not empty");
test_assert(6, sem1.s_cnt == 0, "counter not zero");
@ -173,7 +173,7 @@ static void sem2_execute(void) {
for (i = 0; i < 5; i++) {
test_emit_token('A' + i);
msg = chSemWaitTimeout(&sem1, MS2ST(500));
test_assert(7, msg == RDY_TIMEOUT, "wrong wake-up message");
test_assert(7, msg == MSG_TIMEOUT, "wrong wake-up message");
test_assert(8, queue_isempty(&sem1.s_queue), "queue not empty");
test_assert(9, sem1.s_cnt == 0, "counter not zero");
}