diff --git a/3rd_party b/3rd_party index 8f7de642..536ed319 160000 --- a/3rd_party +++ b/3rd_party @@ -1 +1 @@ -Subproject commit 8f7de6422d4a48431417c2b5a0fb8217b55f346e +Subproject commit 536ed31958ca3abb7dcdae59f5439264a7838dac diff --git a/examples b/examples index b48dc902..0ee83367 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit b48dc902fbdfd4658d4cc4c2a41e8891e7c105fa +Subproject commit 0ee833670000465d2460431e646a0901a55eb771 diff --git a/include/qp.h b/include/qp.h index 6cbb95c9..355422f5 100644 --- a/include/qp.h +++ b/include/qp.h @@ -135,7 +135,7 @@ bool QEvt_verify_(QEvt const * const me); typedef struct { QEvt const *e; } QEvtPtr; -#endif +#endif // QEQUEUE_HPP_ #define QEVT_DYNAMIC ((uint8_t)0) #define Q_EVT_CAST(class_) ((class_ const *)(e)) @@ -691,7 +691,7 @@ void QF_onCleanup(void); #endif // def QF_ON_CONTEXT_SW static inline QPrioSpec Q_PRIO(uint8_t const prio, uint8_t const pthre) { - // combine the QF prio. preemption-threshld pthre in the upper byte + // combine the QF prio. preemption-threshold pthre in the upper byte return (QPrioSpec)((uint32_t)prio | ((uint32_t)pthre << 8U)); } diff --git a/ports/arm-cr/qk/gnu/qp_port.h b/ports/arm-cr/qk/gnu/qp_port.h index 81523ed3..2bbfa2d4 100644 --- a/ports/arm-cr/qk/gnu/qp_port.h +++ b/ports/arm-cr/qk/gnu/qp_port.h @@ -94,70 +94,63 @@ // QK-specific Interrupt Request handler BEGIN #ifdef __ARM_FP #define QK_IRQ_BEGIN(name_) \ - void name_(void) \ - __attribute__ ((interrupt ("irq"))); \ + void name_##_isr(void); \ __attribute__ ((naked)) void name_(void) { \ - __asm volatile (" SUB LR, LR, #4\n" \ + __asm volatile(" SUB LR, LR, #4\n" \ " SRSDB #31!\n" \ " CPS #31\n" \ " PUSH {R0-R3, R12}"); \ - __asm(" FMRX R12, FPSCR\n" \ + __asm(" VMRS R12, FPSCR\n" \ " STMFD SP!, {R12}\n" \ - " FMRX R12, FPEXC\n" \ + " VMRS R12, FPEXC\n" \ " STMFD SP!, {R12}\n" \ - " FSTMDBD SP!, {D0-D7}"); \ - __asm(" AND R3, SP, #4\n" \ + " VSTMDB SP!, {D0-D7}"); \ + __asm volatile(" AND R3, SP, #4\n" \ " SUB SP, SP, R3\n" \ - " PUSH {R3, LR}\n"); \ + " PUSH {R3, LR}\n" \ + " blx " #name_ "_isr \n" \ + " POP {R3, LR}\n" \ + " ADD SP, SP, R3"); \ + __asm(" VLDMIA SP!, {D0-D7}\n" \ + " LDMFD SP!, {R12}\n" \ + " VMSR FPEXC, R12 \n" \ + " LDMFD SP!, {R12} \n" \ + " VMSR FPSCR, R12"); \ + __asm volatile(" POP {R0-R3, R12}\n" \ + " RFEIA SP!"); \ + } \ + void name_ ## _isr(void) { \ ++QK_priv_.intNest; { #else #define QK_IRQ_BEGIN(name_) \ - void name_(void) \ - __attribute__ ((target ("arm"))); \ + void name_##_isr(void); \ __attribute__ ((naked)) void name_(void) { \ - __asm volatile (" SUB LR, LR, #4\n" \ + __asm volatile(" SUB LR, LR, #4\n" \ " SRSDB #31!\n" \ " CPS #31\n" \ " PUSH {R0-R3, R12}"); \ - __asm(" AND R3, SP, #4\n" \ + __asm volatile(" AND R3, SP, #4\n" \ " SUB SP, SP, R3\n" \ - " PUSH {R3, LR}\n"); \ + " PUSH {R3, LR}\n" \ + " blx " #name_ "_isr \n" \ + " POP {R3, LR}\n" \ + " ADD SP, SP, R3"); \ + __asm volatile(" POP {R0-R3, R12}\n" \ + " RFEIA SP!"); \ + } \ + void name_ ## _isr(void) { \ ++QK_priv_.intNest; { #endif // QK-specific Interrupt Request handler END -#ifdef __ARM_FP -#define QK_IRQ_END() \ - } --QK_priv_.intNest; \ - if (QK_priv_.intNest == 0U) { \ - if (QK_sched_() != 0U) { \ - QK_activate_(); \ - } \ - } \ - __asm volatile (" POP {R3, LR}\n" \ - " ADD SP, SP, R3"); \ - __asm(" FLDMIAD SP!, {D0-D7}\n" \ - " LDMFD SP!, {R12}\n" \ - " FMXR FPEXC, R12 \n" \ - " LDMFD SP!, {R12} \n" \ - " FMXR FPSCR, R12"); \ - __asm(" POP {R0-R3, R12}\n" \ - " RFEIA SP!"); \ -} -#else -#define QK_IRQ_END() \ - } --QK_priv_.intNest; \ - if (QK_priv_.intNest == 0U) { \ - if (QK_sched_() != 0U) { \ - QK_activate_(); \ - } \ - } \ - __asm volatile (" POP {R3, LR}\n" \ - " ADD SP, SP, R3"); \ - __asm volatile (" POP {R0-R3, R12}\n" \ - " RFEIA SP!"); \ +#define QK_IRQ_END() \ + } --QK_priv_.intNest; \ + if (QK_priv_.intNest == 0U) { \ + if (QK_sched_() != 0U) { \ + QK_activate_(); \ + } \ + } \ } -#endif // include files ------------------------------------------------------------- #include "qequeue.h" // QK kernel uses the native QP event queue diff --git a/ports/msp430/qutest/qp_port.h b/ports/msp430/qutest/qp_port.h index af91df7b..f27c1f98 100644 --- a/ports/msp430/qutest/qp_port.h +++ b/ports/msp430/qutest/qp_port.h @@ -44,8 +44,8 @@ // QActive event queue type #define QACTIVE_EQUEUE_TYPE QEQueue -// QACTIVE_OS_OBJ_TYPE not used in this port -// QACTIVE_THREAD_TYPE not used in this port +// QACTIVE_OS_OBJ_TYPE not used in this port +// QACTIVE_THREAD_TYPE not used in this port // QF critical section #define QF_CRIT_STAT QCritStatus critStat_; @@ -85,10 +85,10 @@ // QMPool operations #define QF_EPOOL_TYPE_ QMPool #define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \ - (QMPool_init(&(p_), (poolSto_), (poolSize_), (evtSize_))) + (QMPool_init(&(p_), (poolSto_), (poolSize_), (evtSize_))) #define QF_EPOOL_EVENT_SIZE_(p_) ((uint16_t)(p_).blockSize) #define QF_EPOOL_GET_(p_, e_, m_, qsId_) \ - ((e_) = (QEvt *)QMPool_get(&(p_), (m_), (qsId_))) + ((e_) = (QEvt *)QMPool_get(&(p_), (m_), (qsId_))) #define QF_EPOOL_PUT_(p_, e_, qsId_) (QMPool_put(&(p_), (e_), (qsId_))) #define QF_EPOOL_USE_(ePool_) (QMPool_getUse(ePool_)) #define QF_EPOOL_FREE_(ePool_) ((uint16_t)(ePool_)->nFree) diff --git a/ports/posix-qv/qf_port.c b/ports/posix-qv/qf_port.c index 2820e87e..33db915c 100644 --- a/ports/posix-qv/qf_port.c +++ b/ports/posix-qv/qf_port.c @@ -197,10 +197,6 @@ void QF_init(void) { //............................................................................ int QF_run(void) { - l_isRunning = true; // QF is running - - QF_onStartup(); // application-specific startup callback - QF_CRIT_STAT // system clock tick configured? if ((l_tick.tv_sec != 0) || (l_tick.tv_nsec != 0)) { @@ -243,13 +239,20 @@ int QF_run(void) { pthread_attr_destroy(&attr); } - // the combined event-loop and background-loop of the QV kernel QF_CRIT_ENTRY(); // produce the QS_QF_RUN trace record QS_BEGIN_PRE(QS_QF_RUN, 0U) QS_END_PRE() + l_isRunning = true; // QF is running + + // Application callback: configure and enable individual interrupts. + // NOTE: called within critical section and returns also in + // critical section. + QF_onStartup(); + + // the combined event-loop and background-loop of the QV kernel while (l_isRunning) { // find the maximum priority AO ready to run if (QPSet_notEmpty(&QF_readySet_)) { diff --git a/ports/posix/qf_port.c b/ports/posix/qf_port.c index 2fd53d06..693aea95 100644 --- a/ports/posix/qf_port.c +++ b/ports/posix/qf_port.c @@ -156,13 +156,15 @@ void QF_init(void) { //............................................................................ int QF_run(void) { - - QF_onStartup(); // application-specific startup callback - // produce the QS_QF_RUN trace record QS_BEGIN_PRE(QS_QF_RUN, 0U) QS_END_PRE() + // Application callback: configure and enable individual interrupts. + // NOTE: called within critical section and returns also in + // critical section. + QF_onStartup(); + // try to set the priority of the ticker thread, see NOTE01 struct sched_param sparam; sparam.sched_priority = l_tickPrio; diff --git a/ports/win32-qv/qf_port.c b/ports/win32-qv/qf_port.c index e0b3622b..395d4e81 100644 --- a/ports/win32-qv/qf_port.c +++ b/ports/win32-qv/qf_port.c @@ -105,16 +105,13 @@ void QF_init(void) { //............................................................................ int QF_run(void) { - l_isRunning = true; // QF is running - - QF_onStartup(); // application-specific startup callback + QF_CRIT_STAT if (l_tickMsec != 0U) { // system clock tick configured? // create the ticker thread... HANDLE ticker = CreateThread(NULL, 1024, &ticker_thread, (void *)0, 0U, NULL); #ifndef Q_UNSAFE - QF_CRIT_STAT QF_CRIT_ENTRY(); Q_ASSERT_INCRIT(310, ticker != 0); // thread must be created QF_CRIT_EXIT(); @@ -123,13 +120,20 @@ int QF_run(void) { #endif } - // the combined event-loop and background-loop of the QV kernel QF_CRIT_ENTRY(); // produce the QS_QF_RUN trace record QS_BEGIN_PRE(QS_QF_RUN, 0U) QS_END_PRE() + l_isRunning = true; // QF is running + + // Application callback: configure and enable individual interrupts. + // NOTE: called within critical section and returns also in + // critical section. + QF_onStartup(); + + // the combined event-loop and background-loop of the QV kernel while (l_isRunning) { // find the maximum priority AO ready to run if (QPSet_notEmpty(&QF_readySet_)) { diff --git a/ports/win32/qf_port.c b/ports/win32/qf_port.c index e32cf190..d2211bae 100644 --- a/ports/win32/qf_port.c +++ b/ports/win32/qf_port.c @@ -83,13 +83,15 @@ void QF_init(void) { //............................................................................ int QF_run(void) { - - QF_onStartup(); // application-specific startup callback - // produce the QS_QF_RUN trace record QS_BEGIN_PRE(QS_QF_RUN, 0U) QS_END_PRE() + // Application callback: configure and enable individual interrupts. + // NOTE: called within critical section and returns also in + // critical section. + QF_onStartup(); + // leave the startup critical section to unblock any active objects // started before calling QF_run() LeaveCriticalSection(&l_startupCritSect); diff --git a/qpc_8.1.4.sha1 b/qpc_8.1.4.sha1 index 23b23060..6f6b6cb8 100644 --- a/qpc_8.1.4.sha1 +++ b/qpc_8.1.4.sha1 @@ -1,10 +1,10 @@ 415c9497e960505621981cce10caa97f7f78b2f2 *include/qequeue.h 4f34d5d0731b1da95dd7ec39245e5488ab374ac7 *include/qk.h 58d7d73db5b4cef3e86dccd72172f28eb64b4a06 *include/qmpool.h -538d674e18bc76b558cb38a9a60ff98b8141af8e *include/qp.h +87ccac6a2b7157d085405b22e821fd4bd7145a56 *include/qp.h eaf730fa09118db437cd3caae1ecd0fb8c299cb3 *include/qp_pkg.h dd82e56b9e863b74bd172e03a6c560a72b02d74b *include/qpc.h -855b5bd933e283dd8992094209a4d51126ff5b02 *include/qs.h +6ab1db4443714cf586c104b2c94d999ddc8eb4eb *include/qs.h 4d9e6f4d3159115258df88542781b982334c82db *include/qs_dummy.h cea714eda1396e1df5044e7b4904db7d2b619419 *include/qs_pkg.h c905acdf025518fc0696cdc0e8299c92abce0afa *include/qsafe.h @@ -26,17 +26,17 @@ fac89d08e161dd10a803ed9536287f2e641c06b4 *src/qf/qf_qeq.c 8f5b2a0ed1cb810dabcd80d1b4b06d2a9e850cd1 *src/qf/qf_qmact.c 20ccb16d03792afcb0627c22f20406580db3f8aa *src/qf/qf_time.c 878a737efe234f40dc8c9374acc351e510b4da1e *src/qk/CMakeLists.txt -660262c0d790e2c7fa5c825a05b10c6429f94d80 *src/qk/qk.c +06b06ca8757da7172e0bde220fddc508775eb7a0 *src/qk/qk.c 68c99a2991d25df7486e57edadaa955b2bda396d *src/qs/CMakeLists.txt e631ac41a64d6443ce386793c116339fef9c4e8c *src/qs/qs.c b9682b2e5c73987ac777f10db5dd6a6fee2e59fd *src/qs/qs_64bit.c 8a96a1a0c2072cdbd49326893fdd7951e075c39e *src/qs/qs_fp.c 9360fe3708bbf71d2f5485934aec8ee718fc3e9d *src/qs/qs_rx.c d1dd4fc7efd0c7ef0fc85107a00dc822cb82bf44 *src/qs/qstamp.c -838b62c0c1504bb4924a5dff8af520693981c45e *src/qs/qutest.c +d4fa86b9da43b4b16fa914088b19660b285d9705 *src/qs/qutest.c b1d2def9b8f6cde464170af7682ab0f01f4f40f6 *src/qv/CMakeLists.txt -796fdf04d572ad8d5587ba2f1dbc4804c0a0af04 *src/qv/qv.c -05977989921b57261a7efc8f72be53e924794776 *src/qxk/qxk.c +bc75c839375eed8a8ab6493d304ee714480d631d *src/qv/qv.c +587594ef2bd224b9352c4e6c5d0429b22eeeeef5 *src/qxk/qxk.c 364d41c441cae7a61a9265c3c184c037f93d5b12 *src/qxk/qxk_mutex.c 3b1cf83b8cd92de9150fb0627420335e71c88287 *src/qxk/qxk_sema.c 186c95ebd095bc5a786a44d7e7b26a544de47a1d *src/qxk/qxk_xthr.c @@ -90,7 +90,7 @@ bca97bafbcf543d5f9a620817d6166828e0ccd09 *ports/msp430/qk/qp_port.h becde567ef7edc053a98b11f210d956505e30314 *ports/msp430/qk/qs_port.h fe088835c9143e4dbdf2b7df6743fadfeaf7abb9 *ports/msp430/qv/qp_port.h becde567ef7edc053a98b11f210d956505e30314 *ports/msp430/qv/qs_port.h -149bbb9052c87e8014aafd1c01df921120e4054b *ports/msp430/qutest/qp_port.h +29963f81986ea360830cf69e2c1addcf81c04656 *ports/msp430/qutest/qp_port.h becde567ef7edc053a98b11f210d956505e30314 *ports/msp430/qutest/qs_port.h 869086d28e651a579c7c6c5e15a9e2f340eaeb07 *ports/config/qp_config.h 2ee7f5594f6121705bbc57145175b5c5867e0070 *ports/embos/CMakeLists.txt @@ -119,14 +119,14 @@ cf5ae73fce95883254c01cd67e4fbebdc60f3323 *ports/qep-only/qp_port.h 5a58249c986a9fb10fba89f3de6021603027cc2c *ports/qep-only/qs_port.h 5c9f762b06e3324a581cbc0aab002dadfa22990a *ports/qep-only/safe_std.h 5d7914dfaf44a9c2552afdd5d8de4cfc3ebbc22a *ports/posix/CMakeLists.txt -d00d22d47891feab1da478f6a7b2360a3278db9b *ports/posix/qf_port.c +9c89901be1f42f280ed98ae1368294eb96860e49 *ports/posix/qf_port.c b867bc161b8c6a48d94f223b74773058fb16364e *ports/posix/qp_port.h 2c2758d24a79590fa52b858e231912a8112d5805 *ports/posix/qs_port.c 88b29cc261241229a3918aa05538f96dfce167c9 *ports/posix/qs_port.h 6e33b2e5092d117f58c47b632c59420f382ac39f *ports/posix/README.md 5c9f762b06e3324a581cbc0aab002dadfa22990a *ports/posix/safe_std.h 039b1e4066eb7eeac3233070ad6aa2cd9f6d1c69 *ports/posix-qv/CMakeLists.txt -5c4cdfe7334ee8a6ec7e3f1214f3131aa6507a4b *ports/posix-qv/qf_port.c +565565e29efe1987ec27c5acea9b0c8822a6230a *ports/posix-qv/qf_port.c 391cd7a75b2e5627a8587ecffc7891a6450cc74c *ports/posix-qv/qp_port.h 2c2758d24a79590fa52b858e231912a8112d5805 *ports/posix-qv/qs_port.c 88b29cc261241229a3918aa05538f96dfce167c9 *ports/posix-qv/qs_port.h @@ -138,7 +138,7 @@ d2f71922e2d31e7b8fee9dab1e4a3f49b5edbf98 *ports/posix-qutest/qp_port.h 60ed43cb4719c232a696258ce35b09def076cf9d *ports/posix-qutest/qutest_port.c 5c9f762b06e3324a581cbc0aab002dadfa22990a *ports/posix-qutest/safe_std.h cfea17ea9ab718e9e4f506e90c4b2fc8c1fea858 *ports/win32/CMakeLists.txt -01da77b0bc844561fc6e9882af6124028e9ca693 *ports/win32/qf_port.c +f2c4d531e9c7127d28b80d25e5acb0697c784666 *ports/win32/qf_port.c b2ea286d532aec4161461e1247fab19d8a417ec3 *ports/win32/qp_port.h b2f357a5878acc5150557bfc15fc822bb8f8281d *ports/win32/qs_port.c 5a58249c986a9fb10fba89f3de6021603027cc2c *ports/win32/qs_port.h @@ -147,7 +147,7 @@ a49f284a53d6dd128390ae9eb536ef5756cc577d *ports/win32/qwin_gui.h 3781ccdce31dea9d08493a801926eb278950786f *ports/win32/README.md 5c9f762b06e3324a581cbc0aab002dadfa22990a *ports/win32/safe_std.h 8d589868e287ceb185b4837064c80d4eed8e1a44 *ports/win32-qv/CMakeLists.txt -be8de97bfdb7151b15c77fa02553789af79c5eb0 *ports/win32-qv/qf_port.c +b518c527308292e24e8a5200fae38c6f90dd49a3 *ports/win32-qv/qf_port.c 61528fe45f7dfe1f2276e0a6dff60f8f34bb0122 *ports/win32-qv/qp_port.h b2f357a5878acc5150557bfc15fc822bb8f8281d *ports/win32-qv/qs_port.c 5a58249c986a9fb10fba89f3de6021603027cc2c *ports/win32-qv/qs_port.h @@ -156,7 +156,7 @@ a49f284a53d6dd128390ae9eb536ef5756cc577d *ports/win32-qv/qwin_gui.h b57cec85e2fe5c261270f68acc3ae440802a62bd *ports/win32-qv/README.md 5c9f762b06e3324a581cbc0aab002dadfa22990a *ports/win32-qv/safe_std.h a04f13d2d9f24ef71d95f997d87f8a3ba9862e45 *ports/win32-qutest/CMakeLists.txt -33c65a7b736cb95e390932e39debee0f43f0b2d3 *ports/win32-qutest/qp_port.h +84548e22a1a1c2e9bff55be9489619a498eb9066 *ports/win32-qutest/qp_port.h 5a58249c986a9fb10fba89f3de6021603027cc2c *ports/win32-qutest/qs_port.h 9e557325d08cfd94f541372b0de2bab6d379d3e5 *ports/win32-qutest/qutest_port.c 5c9f762b06e3324a581cbc0aab002dadfa22990a *ports/win32-qutest/safe_std.h diff --git a/src/qk/qk.c b/src/qk/qk.c index 854546b3..b34d80fa 100644 --- a/src/qk/qk.c +++ b/src/qk/qk.c @@ -327,10 +327,12 @@ int_t QF_run(void) { QK_activate_(); } - QF_INT_ENABLE(); - - QF_onStartup(); // app. callback: configure and enable interrupts + // Application callback: configure and enable individual interrupts. + // NOTE: called with interrupts disabled and returns also with + // interrupts disabled + QF_onStartup(); + QF_INT_ENABLE(); for (;;) { // QK idle loop... QK_onIdle(); // application-specific QK idle callback } diff --git a/src/qv/qv.c b/src/qv/qv.c index e72672fc..75a6dbf4 100644 --- a/src/qv/qv.c +++ b/src/qv/qv.c @@ -129,11 +129,11 @@ int_t QF_run(void) { #endif // (defined QF_ON_CONTEXT_SW) || (defined Q_SPY) - QF_INT_ENABLE(); + // Application callback: configure and enable individual interrupts. + // NOTE: called with interrupts disabled and returns also + // with interrupts disabled + QF_onStartup(); - QF_onStartup(); // app. callback: configure and enable interrupts - - QF_INT_DISABLE(); for (;;) { // QV event-loop... // find the maximum prio. AO ready to run uint_fast8_t const p = (QPSet_notEmpty(&QV_priv_.readySet)