QP/C  8.0.3
Real-Time Event Framework
Loading...
Searching...
No Matches
qk.h
Go to the documentation of this file.
1//============================================================================
2// QP/C Real-Time Event Framework (RTEF)
3//
4// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
5//
6// Q u a n t u m L e a P s
7// ------------------------
8// Modern Embedded Software
9//
10// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
11//
12// This software is dual-licensed under the terms of the open-source GNU
13// General Public License (GPL) or under the terms of one of the closed-
14// source Quantum Leaps commercial licenses.
15//
16// Redistributions in source code must retain this top-level comment block.
17// Plagiarizing this software to sidestep the license obligations is illegal.
18//
19// NOTE:
20// The GPL does NOT permit the incorporation of this code into proprietary
21// programs. Please contact Quantum Leaps for commercial licensing options,
22// which expressly supersede the GPL and are designed explicitly for
23// closed-source distribution.
24//
25// Quantum Leaps contact information:
26// <www.state-machine.com/licensing>
27// <info@state-machine.com>
28//============================================================================
29#ifndef QK_H_
30#define QK_H_
31
32//============================================================================
33//! @class QK
34typedef struct QK {
35 //! @cond INTERNAL
36 uint8_t dummy;
37 //! @endcond
38} QK;
39
40typedef uint_fast8_t QSchedStatus;
41
42//============================================================================
43//! @class QK_Attr
44typedef struct {
45 QPSet readySet; //!< @memberof QK_Attr
46 uint_fast8_t actPrio; //!< @memberof QK_Attr
47 uint_fast8_t nextPrio; //!< @memberof QK_Attr
48 uint_fast8_t actThre; //!< @memberof QK_Attr
49 uint_fast8_t lockCeil; //!< @memberof QK_Attr
50 uint_fast8_t intNest; //!< @memberof QK_Attr
51} QK_Attr;
52
53//! @static @private @memberof QK
55
56//! @static @private @memberof QK
57uint_fast8_t QK_sched_(void);
58
59//! @static @private @memberof QK
60uint_fast8_t QK_sched_act_(
61 QActive const * const act,
62 uint_fast8_t const pthre_in);
63
64//! @static @private @memberof QK
65void QK_activate_(void);
66
67//! @static @public @memberof QK
68QSchedStatus QK_schedLock(uint_fast8_t const ceiling);
69
70//! @static @public @memberof QK
71void QK_schedUnlock(QSchedStatus const prevCeil);
72
73//! @static @public @memberof QK
74void QK_onIdle(void);
75
76//============================================================================
77// interface used only for internal implementation, but not in applications
78#ifdef QP_IMPL
79
80// scheduler locking for QK...
81#define QF_SCHED_STAT_ QSchedStatus lockStat_;
82#define QF_SCHED_LOCK_(ceil_) do { \
83 if (QK_ISR_CONTEXT_()) { \
84 lockStat_ = 0xFFU; \
85 } else { \
86 lockStat_ = QK_schedLock((ceil_)); \
87 } \
88} while (false)
89
90#define QF_SCHED_UNLOCK_() do { \
91 if (lockStat_ != 0xFFU) { \
92 QK_schedUnlock(lockStat_); \
93 } \
94} while (false)
95
96// QActive event queue customization for QK...
97#define QACTIVE_EQUEUE_WAIT_(me_) ((void)0)
98#define QACTIVE_EQUEUE_SIGNAL_(me_) do { \
99 QPSet_insert(&QK_priv_.readySet, (uint_fast8_t)(me_)->prio); \
100 if (!QK_ISR_CONTEXT_()) { \
101 if (QK_sched_() != 0U) { \
102 QK_activate_(); \
103 } \
104 } \
105} while (false)
106
107// QF event pool customization for QK...
108#define QF_EPOOL_TYPE_ QMPool
109#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \
110 (QMPool_init(&(p_), (poolSto_), (poolSize_), (evtSize_)))
111#define QF_EPOOL_EVENT_SIZE_(p_) ((uint_fast16_t)(p_).blockSize)
112#define QF_EPOOL_GET_(p_, e_, m_, qsId_) \
113 ((e_) = (QEvt *)QMPool_get(&(p_), (m_), (qsId_)))
114#define QF_EPOOL_PUT_(p_, e_, qsId_) \
115 (QMPool_put(&(p_), (e_), (qsId_)))
116
117#endif // QP_IMPL
118
119#endif // QK_H_
uint_fast8_t QSchedStatus
Definition qk.h:40
Active object class (based on the QHsm implementation strategy)
Definition qp.h:504
Private attributes of the QK kernel.
Definition qk.h:44
QPSet readySet
Definition qk.h:45
uint_fast8_t actThre
Definition qk.h:48
uint_fast8_t actPrio
Definition qk.h:46
uint_fast8_t lockCeil
Definition qk.h:49
uint_fast8_t intNest
Definition qk.h:50
uint_fast8_t nextPrio
Definition qk.h:47
QK preemptive non-blocking kernel (QK namespace emulated as a "class" in C)
Definition qk.h:34
uint_fast8_t QK_sched_(void)
Definition qk.c:108
void QK_activate_(void)
Definition qk.c:172
uint_fast8_t QK_sched_act_(QActive const *const act, uint_fast8_t const pthre_in)
Definition qk.c:136
void QK_onIdle(void)
QSchedStatus QK_schedLock(uint_fast8_t const ceiling)
QK_Attr QK_priv_
Definition qk.h:54
void QK_schedUnlock(QSchedStatus const prevCeil)
Definition qk.c:80
Set of Active Objects of up to QF_MAX_ACTIVE elements.
Definition qp.h:406