QP/C  8.0.0
Real-Time Embedded Framework
Loading...
Searching...
No Matches
qk.h
Go to the documentation of this file.
1//$file${include::qk.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2//
3// Model: qpc.qm
4// File: ${include::qk.h}
5//
6// This code has been generated by QM 7.0.0 <www.state-machine.com/qm>.
7// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
8//
9// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
10//
11// Q u a n t u m L e a P s
12// ------------------------
13// Modern Embedded Software
14//
15// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
16//
17// The QP/C software is dual-licensed under the terms of the open-source GNU
18// General Public License (GPL) or under the terms of one of the closed-
19// source Quantum Leaps commercial licenses.
20//
21// Redistributions in source code must retain this top-level comment block.
22// Plagiarizing this software to sidestep the license obligations is illegal.
23//
24// NOTE:
25// The GPL does NOT permit the incorporation of this code into proprietary
26// programs. Please contact Quantum Leaps for commercial licensing options,
27// which expressly supersede the GPL and are designed explicitly for
28// closed-source distribution.
29//
30// Quantum Leaps contact information:
31// <www.state-machine.com/licensing>
32// <info@state-machine.com>
33//
34//$endhead${include::qk.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35#ifndef QK_H_
36#define QK_H_
37
38//$declare${QK::QK} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
39
40//${QK::QK} ..................................................................
41//! @class QK
42typedef struct QK {
43 //! @cond INTERNAL
44 uint8_t dummy;
45 //! @endcond
46} QK;
47//$enddecl${QK::QK} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48
49//$declare${QK::QSchedStatus} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
50
51//${QK::QSchedStatus} ........................................................
52typedef uint_fast8_t QSchedStatus;
53//$enddecl${QK::QSchedStatus} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54
55//$declare${QK::QK-base} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
56
57//${QK::QK-base::Attr} .......................................................
58//! @class QK_Attr
59typedef struct {
60// private:
61
62 //! @memberof QK_Attr
64
65 //! @memberof QK_Attr
66 uint_fast8_t actPrio;
67
68 //! @memberof QK_Attr
69 uint_fast8_t nextPrio;
70
71 //! @memberof QK_Attr
72 uint_fast8_t actThre;
73
74 //! @memberof QK_Attr
75 uint_fast8_t lockCeil;
76
77 //! @memberof QK_Attr
78 uint_fast8_t intNest;
79
80#ifndef Q_UNSAFE
81 //! @memberof QK_Attr
83#endif // ndef Q_UNSAFE
84
85#ifndef Q_UNSAFE
86 //! @memberof QK_Attr
87 uint_fast8_t actPrio_dis;
88#endif // ndef Q_UNSAFE
89
90#ifndef Q_UNSAFE
91 //! @memberof QK_Attr
92 uint_fast8_t nextPrio_dis;
93#endif // ndef Q_UNSAFE
94
95#ifndef Q_UNSAFE
96 //! @memberof QK_Attr
97 uint_fast8_t actThre_dis;
98#endif // ndef Q_UNSAFE
99
100#ifndef Q_UNSAFE
101 //! @memberof QK_Attr
102 uint_fast8_t lockCeil_dis;
103#endif // ndef Q_UNSAFE
104} QK_Attr;
105
106//${QK::QK-base::priv_} ......................................................
107//! @static @private @memberof QK
109
110//${QK::QK-base::schedLock} ..................................................
111//! @static @public @memberof QK
112QSchedStatus QK_schedLock(uint_fast8_t const ceiling);
113
114//${QK::QK-base::schedUnlock} ................................................
115//! @static @public @memberof QK
116void QK_schedUnlock(QSchedStatus const prevCeil);
117
118//${QK::QK-base::onIdle} .....................................................
119//! @static @public @memberof QK
120void QK_onIdle(void);
121
122//${QK::QK-base::sched_} .....................................................
123//! @static @private @memberof QK
124uint_fast8_t QK_sched_(void);
125
126//${QK::QK-base::activate_} ..................................................
127//! @static @private @memberof QK
128void QK_activate_(void);
129//$enddecl${QK::QK-base} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
130
131//============================================================================
132// interface used only for internal implementation, but not in applications
133#ifdef QP_IMPL
134
135//$declare${QK-impl} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
136
137//${QK-impl::QF_SCHED_STAT_} .................................................
138#define QF_SCHED_STAT_ QSchedStatus lockStat_;
139
140//${QK-impl::QF_SCHED_LOCK_} .................................................
141#define QF_SCHED_LOCK_(ceil_) do { \
142 if (QK_ISR_CONTEXT_()) { \
143 lockStat_ = 0xFFU; \
144 } else { \
145 lockStat_ = QK_schedLock((ceil_)); \
146 } \
147} while (false)
148
149//${QK-impl::QF_SCHED_UNLOCK_} ...............................................
150#define QF_SCHED_UNLOCK_() do { \
151 if (lockStat_ != 0xFFU) { \
152 QK_schedUnlock(lockStat_); \
153 } \
154} while (false)
155
156//${QK-impl::QACTIVE_EQUEUE_WAIT_} ...........................................
157#define QACTIVE_EQUEUE_WAIT_(me_) ((void)0)
158
159//${QK-impl::QACTIVE_EQUEUE_SIGNAL_} .........................................
160#ifndef Q_UNSAFE
161#define QACTIVE_EQUEUE_SIGNAL_(me_) do { \
162 QPSet_insert(&QK_priv_.readySet, (uint_fast8_t)(me_)->prio); \
163 QPSet_update_(&QK_priv_.readySet, &QK_priv_.readySet_dis); \
164 if (!QK_ISR_CONTEXT_()) { \
165 if (QK_sched_() != 0U) { \
166 QK_activate_(); \
167 } \
168 } \
169} while (false)
170#endif // ndef Q_UNSAFE
171
172//${QK-impl::QACTIVE_EQUEUE_SIGNAL_} .........................................
173#ifdef Q_UNSAFE
174#define QACTIVE_EQUEUE_SIGNAL_(me_) do { \
175 QPSet_insert(&QK_priv_.readySet, (uint_fast8_t)(me_)->prio); \
176 if (!QK_ISR_CONTEXT_()) { \
177 if (QK_sched_() != 0U) { \
178 QK_activate_(); \
179 } \
180 } \
181} while (false)
182#endif // def Q_UNSAFE
183//$enddecl${QK-impl} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
184
185//$declare${QF_EPOOL-impl} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
186
187//${QF_EPOOL-impl::QF_EPOOL_TYPE_} ...........................................
188#define QF_EPOOL_TYPE_ QMPool
189
190//${QF_EPOOL-impl::QF_EPOOL_INIT_} ...........................................
191#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \
192 (QMPool_init(&(p_), (poolSto_), (poolSize_), (evtSize_)))
193
194//${QF_EPOOL-impl::QF_EPOOL_EVENT_SIZE_} .....................................
195#define QF_EPOOL_EVENT_SIZE_(p_) ((uint_fast16_t)(p_).blockSize)
196
197//${QF_EPOOL-impl::QF_EPOOL_GET_} ............................................
198#define QF_EPOOL_GET_(p_, e_, m_, qsId_) \
199 ((e_) = (QEvt *)QMPool_get(&(p_), (m_), (qsId_)))
200
201//${QF_EPOOL-impl::QF_EPOOL_PUT_} ............................................
202#define QF_EPOOL_PUT_(p_, e_, qsId_) \
203 (QMPool_put(&(p_), (e_), (qsId_)))
204//$enddecl${QF_EPOOL-impl} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
205
206#endif // QP_IMPL
207
208#endif // QK_H_
uint_fast8_t QSchedStatus
Definition qk.h:52
Private attributes of the QK kernel.
Definition qk.h:59
QPSet readySet_dis
Definition qk.h:82
QPSet readySet
Definition qk.h:63
uint_fast8_t actPrio_dis
Definition qk.h:87
uint_fast8_t actThre_dis
Definition qk.h:97
uint_fast8_t actThre
Definition qk.h:72
uint_fast8_t actPrio
Definition qk.h:66
uint_fast8_t nextPrio_dis
Definition qk.h:92
uint_fast8_t lockCeil
Definition qk.h:75
uint_fast8_t intNest
Definition qk.h:78
uint_fast8_t nextPrio
Definition qk.h:69
uint_fast8_t lockCeil_dis
Definition qk.h:102
QK preemptive non-blocking kernel (QK namespace emulated as a "class" in C)
Definition qk.h:42
void QK_onIdle(void)
QSchedStatus QK_schedLock(uint_fast8_t const ceiling)
QK_Attr QK_priv_
Definition qk.h:108
Set of Active Objects of up to QF_MAX_ACTIVE elements.
Definition qp.h:634