48 #error "Source file included in a project NOT based on the QK kernel"
51Q_DEFINE_THIS_MODULE(
"qk")
55#if (QP_VERSION < 730U) || (QP_VERSION != ((QP_RELEASE^4294967295U)%0x2710U))
56#error qpc version 7.3.0 or higher required
73 == (uint_fast8_t)(~QK_priv_.lockCeil_dis));
77 if (ceiling > QK_priv_.lockCeil) {
81 QS_2U8_PRE((uint8_t)QK_priv_.lockCeil, (uint8_t)ceiling);
88 QK_priv_.lockCeil = ceiling;
90 QK_priv_.lockCeil_dis = (uint_fast8_t)(~ceiling);
107 if (prevCeil != 0xFFU) {
113 == (uint_fast8_t)(~QK_priv_.lockCeil_dis));
115 && (QK_priv_.lockCeil > prevCeil));
120 QS_2U8_PRE((uint8_t)QK_priv_.lockCeil, (uint8_t)prevCeil);
124 QK_priv_.lockCeil = prevCeil;
126 QK_priv_.lockCeil_dis = (uint_fast8_t)(~prevCeil);
130 if (QK_sched_() != 0U) {
141uint_fast8_t QK_sched_(
void) {
145 &QK_priv_.readySet_dis));
147 if (QPSet_isEmpty(&QK_priv_.readySet)) {
152 p = QPSet_findMax(&QK_priv_.readySet);
155 QK_priv_.actThre == (uint_fast8_t)(~QK_priv_.actThre_dis));
158 if (p <= QK_priv_.actThre) {
163 == (uint_fast8_t)(~QK_priv_.lockCeil_dis));
166 if (p <= QK_priv_.lockCeil) {
171 == (uint_fast8_t)(~QK_priv_.nextPrio_dis));
172 QK_priv_.nextPrio = p;
174 QK_priv_.nextPrio_dis = (uint_fast8_t)(~QK_priv_.nextPrio);
185void QK_activate_(
void) {
188 uint_fast8_t
const prio_in = QK_priv_.actPrio;
189 uint_fast8_t p = QK_priv_.nextPrio;
192 (prio_in == (uint_fast8_t)(~QK_priv_.actPrio_dis))
193 && (p == (uint_fast8_t)(~QK_priv_.nextPrio_dis)));
197 #if (defined QF_ON_CONTEXT_SW) || (defined Q_SPY)
198 uint_fast8_t pprev = prio_in;
201 QK_priv_.nextPrio = 0U;
203 QK_priv_.nextPrio_dis = (uint_fast8_t)(~0U);
206 uint_fast8_t pthre_in;
212 a = QActive_registry_[prio_in];
215 pthre_in = (uint_fast8_t)a->
pthre;
217 (uint_fast8_t)(~(uint_fast8_t)a->
pthre_dis & 0xFFU));
222 a = QActive_registry_[p];
224 uint_fast8_t
const pthre = (uint_fast8_t)a->
pthre;
226 (uint_fast8_t)(~(uint_fast8_t)a->
pthre_dis & 0xFFU));
229 QK_priv_.actPrio = p;
230 QK_priv_.actThre = pthre;
232 QK_priv_.actPrio_dis = (uint_fast8_t)(~p);
233 QK_priv_.actThre_dis = (uint_fast8_t)(~pthre);
236 #if (defined QF_ON_CONTEXT_SW) || (defined Q_SPY)
245 #ifdef QF_ON_CONTEXT_SW
246 QF_onContextSw(QActive_registry_[pprev], a);
256 QEvt const *
const e = QActive_get_(a);
261 #if (QF_MAX_EPOOL > 0U)
271 &QK_priv_.readySet_dis));
274 QPSet_remove(&QK_priv_.readySet, p);
276 QPSet_update_(&QK_priv_.readySet, &QK_priv_.readySet_dis);
280 if (QPSet_isEmpty(&QK_priv_.readySet)) {
285 p = QPSet_findMax(&QK_priv_.readySet);
293 == (uint_fast8_t)(~QK_priv_.lockCeil_dis));
296 if (p <= QK_priv_.lockCeil) {
307 QK_priv_.actPrio = prio_in;
308 QK_priv_.actThre = pthre_in;
310 QK_priv_.actPrio_dis = (uint_fast8_t)(~QK_priv_.actPrio);
311 QK_priv_.actThre_dis = (uint_fast8_t)(~QK_priv_.actThre);
314 #if (defined QF_ON_CONTEXT_SW) || (defined Q_SPY)
316 a = QActive_registry_[prio_in];
333 #ifdef QF_ON_CONTEXT_SW
334 QF_onContextSw(QActive_registry_[pprev], a);
347 QF_bzero_(&QK_priv_,
sizeof(QK_priv_));
348 QF_bzero_(&QActive_registry_[0],
sizeof(QActive_registry_));
354 QPSet_update_(&QK_priv_.readySet, &QK_priv_.readySet_dis);
355 QK_priv_.actPrio_dis = (uint_fast8_t)(~0U);
356 QK_priv_.nextPrio_dis = (uint_fast8_t)(~0U);
357 QK_priv_.actThre_dis = (uint_fast8_t)(~0U);
358 QK_priv_.lockCeil_dis = (uint_fast8_t)(~QK_priv_.lockCeil);
382 QS_beginRec_((uint_fast8_t)QS_QF_RUN);
397 QK_priv_.lockCeil = 0U;
399 QK_priv_.lockCeil_dis = (uint_fast8_t)(~0U);
402 #ifdef QF_ON_CONTEXT_SW
404 QF_onContextSw((
QActive *)0, QActive_registry_[QK_priv_.nextPrio]);
408 if (QK_sched_() != 0U) {
431void QActive_start(
QActive *
const me,
434 uint_fast16_t
const qLen,
436 uint_fast16_t
const stkSize,
437 void const *
const par)
447 && (stkSto == (
void *)0));
451 me->
prio = (uint8_t)(prioSpec & 0xFFU);
452 me->
pthre = (uint8_t)(prioSpec >> 8U);
453 QActive_register_(me);
455 QEQueue_init(&me->
eQueue, qSto, qLen);
464 if (QK_sched_() != 0U) {
uint_fast8_t QSchedStatus
#define Q_UNUSED_PAR(par_)
Helper macro to clearly mark unused parameters of functions.
QEvt const * QEvtPtr
Pointer to const event instances passed around in QP Framework.
int int_t
Alias for assertion-ID numbers in QP assertions and return from QF_run()
uint16_t QPrioSpec
Priority specification for Active Objects in QP.
#define QF_MAX_ACTIVE
Maximum # Active Objects in the system (1..64)
Internal (package scope) QP/C interface.
#define QK_ISR_CONTEXT_()
#define QF_INT_DISABLE()
Disable interrupts.
#define QF_INT_ENABLE()
Enable interrupts.
#define QS_2U8_PRE(data1_, data2_)
#define QS_BEGIN_PRE(rec_, qsId_)
QP Functional Safety (FuSa) Subsystem.
#define Q_ASSERT_INCRIT(id_, expr_)
#define Q_INVARIANT_INCRIT(id_, expr_)
#define Q_REQUIRE_INCRIT(id_, expr_)
Active object class (based on the QHsm implementation strategy)
QACTIVE_EQUEUE_TYPE eQueue
Port-dependent event-queue type (often QEQueue)
uint8_t prio
QF-priority [1..QF_MAX_ACTIVE] of this AO.
uint8_t pthre
Preemption-threshold [1..QF_MAX_ACTIVE] of this AO.
struct QAsmVtable const * vptr
Virtual pointer inherited by all QAsm subclasses (see also Object Orientation)
void(* init)(QAsm *const me, void const *const e, uint_fast8_t const qsId)
Virtual function to take the top-most initial transition in the state machine.
void(* dispatch)(QAsm *const me, QEvt const *const e, uint_fast8_t const qsId)
Virtual function to dispatch an event to the state machine.
Private attributes of the QK kernel.