git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2235 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
2891f7d645
commit
d5853de4bd
|
@ -74,6 +74,7 @@
|
||||||
#include "chvt.h"
|
#include "chvt.h"
|
||||||
#include "chschd.h"
|
#include "chschd.h"
|
||||||
#include "chsem.h"
|
#include "chsem.h"
|
||||||
|
#include "chbsem.h"
|
||||||
#include "chmtx.h"
|
#include "chmtx.h"
|
||||||
#include "chcond.h"
|
#include "chcond.h"
|
||||||
#include "chevents.h"
|
#include "chevents.h"
|
||||||
|
|
|
@ -94,7 +94,7 @@ typedef struct {
|
||||||
*
|
*
|
||||||
* @init
|
* @init
|
||||||
*/
|
*/
|
||||||
#define chBSemInit(bsp, taken) chSemInit(&bsp->bs_sem, taken ? 0 : 1)
|
#define chBSemInit(bsp, taken) chSemInit(&(bsp)->bs_sem, (taken) ? 0 : 1)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Wait operation on the binary semaphore.
|
* @brief Wait operation on the binary semaphore.
|
||||||
|
@ -108,7 +108,7 @@ typedef struct {
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
#define chBSemWait(bsp) chSemWait(&bsp->bs_sem)
|
#define chBSemWait(bsp) chSemWait(&(bsp)->bs_sem)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Wait operation on the binary semaphore.
|
* @brief Wait operation on the binary semaphore.
|
||||||
|
@ -122,7 +122,7 @@ typedef struct {
|
||||||
*
|
*
|
||||||
* @sclass
|
* @sclass
|
||||||
*/
|
*/
|
||||||
#define chBSemWaitS(bsp) chSemWaitS(&bsp->bs_sem)
|
#define chBSemWaitS(bsp) chSemWaitS(&(bsp)->bs_sem)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Wait operation on the binary semaphore.
|
* @brief Wait operation on the binary semaphore.
|
||||||
|
@ -143,7 +143,7 @@ typedef struct {
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
#define chBSemWaitTimeout(bsp, time) chSemWaitTimeout(&bsp->bs_sem, time)
|
#define chBSemWaitTimeout(bsp, time) chSemWaitTimeout(&(bsp)->bs_sem, (time))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Wait operation on the binary semaphore.
|
* @brief Wait operation on the binary semaphore.
|
||||||
|
@ -164,7 +164,7 @@ typedef struct {
|
||||||
*
|
*
|
||||||
* @sclass
|
* @sclass
|
||||||
*/
|
*/
|
||||||
#define chBSemWaitTimeoutS(bsp, time) chSemWaitTimeoutS(&bsp->bs_sem, time)
|
#define chBSemWaitTimeoutS(bsp, time) chSemWaitTimeoutS(&(bsp)->bs_sem, (time))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reset operation on the binary semaphore.
|
* @brief Reset operation on the binary semaphore.
|
||||||
|
@ -180,7 +180,7 @@ typedef struct {
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
#define chBSemReset(bsp, taken) chSemReset(&bsp->bs_sem, taken ? 0 : 1)
|
#define chBSemReset(bsp, taken) chSemReset(&(bsp)->bs_sem, (taken) ? 0 : 1)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reset operation on the binary semaphore.
|
* @brief Reset operation on the binary semaphore.
|
||||||
|
@ -197,7 +197,7 @@ typedef struct {
|
||||||
*
|
*
|
||||||
* @iclass
|
* @iclass
|
||||||
*/
|
*/
|
||||||
#define chBSemResetI(bsp, taken) chSemResetI(&bsp->bs_sem, taken ? 0 : 1)
|
#define chBSemResetI(bsp, taken) chSemResetI(&(bsp)->bs_sem, (taken) ? 0 : 1)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Performs a signal operation on a binary semaphore.
|
* @brief Performs a signal operation on a binary semaphore.
|
||||||
|
@ -208,7 +208,7 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
#define chBSemSignal(bsp) { \
|
#define chBSemSignal(bsp) { \
|
||||||
chSysLock(); \
|
chSysLock(); \
|
||||||
chBSemSignalI(bsp); \
|
chBSemSignalI((bsp)); \
|
||||||
chSchRescheduleS(); \
|
chSchRescheduleS(); \
|
||||||
chSysUnlock(); \
|
chSysUnlock(); \
|
||||||
}
|
}
|
||||||
|
@ -222,8 +222,8 @@ typedef struct {
|
||||||
* @iclass
|
* @iclass
|
||||||
*/
|
*/
|
||||||
#define chBSemSignalI(bsp) { \
|
#define chBSemSignalI(bsp) { \
|
||||||
if (bsp->bs_sem.s_cnt < 1) \
|
if ((bsp)->bs_sem.s_cnt < 1) \
|
||||||
chSemSignalI(&bsp->bs_sem); \
|
chSemSignalI(&(bsp)->bs_sem); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -236,7 +236,7 @@ typedef struct {
|
||||||
*
|
*
|
||||||
* @iclass
|
* @iclass
|
||||||
*/
|
*/
|
||||||
#define chBSemGetStateI(bsp) ((bsp)->bs_sem.s_cnt > 0 ? 0 : 1)
|
#define chBSemGetStateI(bsp) ((bsp)->bs_sem.s_cnt > 0 ? FALSE : TRUE)
|
||||||
|
|
||||||
#endif /* CH_USE_SEMAPHORES */
|
#endif /* CH_USE_SEMAPHORES */
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,20 @@
|
||||||
* stack where all the interrupts and exceptions are processed.
|
* stack where all the interrupts and exceptions are processed.
|
||||||
* - The threads are started in thread-privileged mode.
|
* - The threads are started in thread-privileged mode.
|
||||||
* - Interrupt nesting and the other advanced core/NVIC features are supported.
|
* - Interrupt nesting and the other advanced core/NVIC features are supported.
|
||||||
|
* - When using an STM32 one of the following macros must be defined on the
|
||||||
|
* compiler command line or in a file named <tt>board.h</tt>:
|
||||||
|
* - @p STM32F10X_LD
|
||||||
|
* - @p STM32F10X_MD
|
||||||
|
* - @p STM32F10X_HD
|
||||||
|
* - @p STM32F10X_CL
|
||||||
|
* .
|
||||||
|
* This is required in order to include a vectors table with the correct
|
||||||
|
* length for the STM32 model, see the file
|
||||||
|
* <tt>./os/ports/GCC/ARMCMx/STM32F10x/vectors.s</tt>.
|
||||||
|
* - The Cortex-Mx port is perfectly generic, support for more devices can be
|
||||||
|
* easily added by adding a subdirectory under <tt>./os/ports/GCC/ARMCMx</tt>
|
||||||
|
* and giving it the name of the new device, then copy the files from another
|
||||||
|
* device into the new directory and customize them for the new device.
|
||||||
* .
|
* .
|
||||||
* @ingroup gcc
|
* @ingroup gcc
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
|
|
||||||
*** 2.1.2 ***
|
*** 2.1.2 ***
|
||||||
- FIX: Fixed wrong macro check in STM32 serial support (but 3078891)(backported
|
- FIX: Fixed wrong macro check in STM32 serial support (bug 3078891)(backported
|
||||||
to 2.0.6).
|
to 2.0.6).
|
||||||
- FIX: Fixed non functioning option CH_USE_NESTED_LOCKS (bug 3075544)
|
- FIX: Fixed non functioning option CH_USE_NESTED_LOCKS (bug 3075544)
|
||||||
(backported to 2.0.6).
|
(backported to 2.0.6).
|
||||||
|
@ -117,11 +117,15 @@
|
||||||
change).
|
change).
|
||||||
- NEW: Added to the documentation more notes about interrupt handlers in
|
- NEW: Added to the documentation more notes about interrupt handlers in
|
||||||
the ARM7 port.
|
the ARM7 port.
|
||||||
|
- NEW: Modified some tests in order to bring back code coverage to 100%
|
||||||
|
in all modules except chdebug.c. Added a test case covering binary
|
||||||
|
semaphores.
|
||||||
- OPT: The fix to the bug 3075544 considerably improved the threads creation
|
- OPT: The fix to the bug 3075544 considerably improved the threads creation
|
||||||
benchmarks score.
|
benchmarks score.
|
||||||
- OPT: Speed optimizations of the STM32 SPI driver, improved latency.
|
- OPT: Speed optimizations of the STM32 SPI driver, improved latency.
|
||||||
- OPT: Speed optimizations of the STM32 ADC driver.
|
- OPT: Speed optimizations of the STM32 ADC driver.
|
||||||
- CHANGE: The API chThdInit() has been renamed to chThdCreateI().
|
- CHANGE: The API chThdInit() has been renamed to chThdCreateI() in order to
|
||||||
|
make clear it is useable from interrupt handlers.
|
||||||
- CHANGE: The mailboxes macros chMBSize(), chMBGetEmpty(), chMBGetFull(),
|
- CHANGE: The mailboxes macros chMBSize(), chMBGetEmpty(), chMBGetFull(),
|
||||||
chMBPeek() have been renamed to chMBSizeI(), chMBGetEmptyI(),
|
chMBPeek() have been renamed to chMBSizeI(), chMBGetEmptyI(),
|
||||||
chMBGetFullI(), chMBPeekI().
|
chMBGetFullI(), chMBPeekI().
|
||||||
|
|
|
@ -452,6 +452,11 @@ static void mtx5_execute(void) {
|
||||||
test_assert(3, isempty(&m1.m_queue), "queue not empty");
|
test_assert(3, isempty(&m1.m_queue), "queue not empty");
|
||||||
test_assert(4, m1.m_owner == NULL, "still owned");
|
test_assert(4, m1.m_owner == NULL, "still owned");
|
||||||
test_assert(5, chThdGetPriority() == prio, "wrong priority level");
|
test_assert(5, chThdGetPriority() == prio, "wrong priority level");
|
||||||
|
|
||||||
|
chMtxLock(&m1);
|
||||||
|
chMtxUnlockAll();
|
||||||
|
test_assert(6, isempty(&m1.m_queue), "queue not empty");
|
||||||
|
test_assert(7, m1.m_owner == NULL, "still owned");
|
||||||
}
|
}
|
||||||
|
|
||||||
ROMCONST struct testcase testmtx5 = {
|
ROMCONST struct testcase testmtx5 = {
|
||||||
|
|
|
@ -189,7 +189,7 @@ ROMCONST struct testcase testsem2 = {
|
||||||
* @page test_sem_003 Atomic signal-wait test
|
* @page test_sem_003 Atomic signal-wait test
|
||||||
*
|
*
|
||||||
* <h2>Description</h2>
|
* <h2>Description</h2>
|
||||||
* This test case explicitly address the @p chSemWaitSignal() function. A
|
* This test case explicitly addresses the @p chSemWaitSignal() function. A
|
||||||
* thread is created that performs a wait and a signal operations.
|
* thread is created that performs a wait and a signal operations.
|
||||||
* The tester thread is awakened from an atomic wait/signal operation.<br>
|
* The tester thread is awakened from an atomic wait/signal operation.<br>
|
||||||
* The test expects that the semaphore wait function returns the correct value
|
* The test expects that the semaphore wait function returns the correct value
|
||||||
|
@ -229,6 +229,57 @@ ROMCONST struct testcase testsem3 = {
|
||||||
sem3_execute
|
sem3_execute
|
||||||
};
|
};
|
||||||
#endif /* CH_USE_SEMSW */
|
#endif /* CH_USE_SEMSW */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @page test_sem_004 Binary Wait and Signal
|
||||||
|
*
|
||||||
|
* <h2>Description</h2>
|
||||||
|
* This test case tests the binary semaphores functionality. The test both
|
||||||
|
* checks the binary semaphore status and the expected status of the underlying
|
||||||
|
* counting semaphore.
|
||||||
|
*/
|
||||||
|
static msg_t thread4(void *p) {
|
||||||
|
|
||||||
|
chBSemSignal((BinarySemaphore *)p);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sem4_execute(void) {
|
||||||
|
BinarySemaphore bsem;
|
||||||
|
|
||||||
|
/* Creates a taken binary semaphore.*/
|
||||||
|
chBSemInit(&bsem, TRUE);
|
||||||
|
chBSemReset(&bsem, TRUE);
|
||||||
|
test_assert(1, chBSemGetStateI(&bsem) == TRUE, "not taken");
|
||||||
|
|
||||||
|
/* Starts a signaler thread at a lower priority.*/
|
||||||
|
threads[0] = chThdCreateStatic(wa[0], WA_SIZE,
|
||||||
|
chThdGetPriority()-1, thread4, &bsem);
|
||||||
|
|
||||||
|
/* Waits to be signaled.*/
|
||||||
|
chBSemWait(&bsem);
|
||||||
|
|
||||||
|
/* The binary semaphore is expected to be taken.*/
|
||||||
|
test_assert(2, chBSemGetStateI(&bsem) == TRUE, "not taken");
|
||||||
|
|
||||||
|
/* Releasing it, check both the binary semaphore state and the underlying
|
||||||
|
counter semaphore state..*/
|
||||||
|
chBSemSignal(&bsem);
|
||||||
|
test_assert(3, chBSemGetStateI(&bsem) == FALSE, "still taken");
|
||||||
|
test_assert(4, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter");
|
||||||
|
|
||||||
|
/* Checking signaling overflow, the counter must not go beyond 1.*/
|
||||||
|
chBSemSignal(&bsem);
|
||||||
|
test_assert(3, chBSemGetStateI(&bsem) == FALSE, "taken");
|
||||||
|
test_assert(5, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter");
|
||||||
|
}
|
||||||
|
|
||||||
|
ROMCONST struct testcase testsem4 = {
|
||||||
|
"Binary Semaphores, functionality",
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
sem4_execute
|
||||||
|
};
|
||||||
#endif /* CH_USE_SEMAPHORES */
|
#endif /* CH_USE_SEMAPHORES */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -241,6 +292,7 @@ ROMCONST struct testcase * ROMCONST patternsem[] = {
|
||||||
#if CH_USE_SEMSW
|
#if CH_USE_SEMSW
|
||||||
&testsem3,
|
&testsem3,
|
||||||
#endif
|
#endif
|
||||||
|
&testsem4,
|
||||||
#endif
|
#endif
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
|
@ -100,7 +100,11 @@ static void thd2_execute(void) {
|
||||||
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E");
|
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E");
|
||||||
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A");
|
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A");
|
||||||
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B");
|
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B");
|
||||||
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C");
|
/* Done this way for coverage of chThdCreateI() and chThdResume().*/
|
||||||
|
chSysLock();
|
||||||
|
threads[2] = chThdCreateI(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C");
|
||||||
|
chSysUnlock();
|
||||||
|
chThdResume(threads[2]);
|
||||||
test_wait_threads();
|
test_wait_threads();
|
||||||
test_assert_sequence(1, "ABCDE");
|
test_assert_sequence(1, "ABCDE");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue