QP/C  7.0.1
Real-Time Embedded Framework
qf_pkg.h
Go to the documentation of this file.
1/*============================================================================
2*
3* Q u a n t u m L e a P s
4* ------------------------
5* Modern Embedded Software
6*
7* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
8*
9* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
10*
11* This software is dual-licensed under the terms of open-source GPL 3.0
12* (or any later version), or alternatively, under the terms of one of the
13* closed-source Quantum Leaps commercial licenses.
14*
15* The terms of the open source GPL 3.0 license can be found at:
16* <www.gnu.org/licenses/gpl-3.0.txt>
17*
18* The terms of the closed-source Quantum Leaps commercial licenses
19* can be found at:
20* <www.state-machine.com/licensing>
21*
22* NOTE: Please do NOT plagiarize this software to sidestep the license
23* obligations. This is both unfair and illegal.
24*
25* Contact information:
26* <www.state-machine.com>
27* <info@state-machine.com>
28============================================================================*/
36#ifndef QF_PKG_H
37#define QF_PKG_H
38
39/*==========================================================================*/
40
41/* QF-specific critical section */
42#ifndef QF_CRIT_STAT_TYPE
54 #define QF_CRIT_STAT_
55
66 #define QF_CRIT_E_() QF_CRIT_ENTRY(dummy)
67
78 #define QF_CRIT_X_() QF_CRIT_EXIT(dummy)
79
80#elif (!defined QF_CRIT_STAT_)
81 #define QF_CRIT_STAT_ QF_CRIT_STAT_TYPE critStat_;
82 #define QF_CRIT_E_() QF_CRIT_ENTRY(critStat_)
83 #define QF_CRIT_X_() QF_CRIT_EXIT(critStat_)
84#endif
85
86/*==========================================================================*/
87
88/* Assertions inside the critical section */
89#ifdef Q_NASSERT /* Q_NASSERT defined--assertion checking disabled */
90
91 #define Q_ASSERT_CRIT_(id_, test_) ((void)0)
92 #define Q_REQUIRE_CRIT_(id_, test_) ((void)0)
93 #define Q_ERROR_CRIT_(id_) ((void)0)
94
95#else /* Q_NASSERT not defined--assertion checking enabled */
96
97 #define Q_ASSERT_CRIT_(id_, test_) do { \
98 if ((test_)) {} else { \
99 QF_CRIT_X_(); \
100 Q_onAssert(&Q_this_module_[0], (int_t)(id_)); \
101 } \
102 } while (false)
103
104 #define Q_REQUIRE_CRIT_(id_, test_) Q_ASSERT_CRIT_((id_), (test_))
105
106 #define Q_ERROR_CRIT_(id_) do { \
107 QF_CRIT_X_(); \
108 Q_onAssert(&Q_this_module_[0], (int_t)(id_)); \
109 } while (false)
110
111#endif /* Q_NASSERT */
112
113/*==========================================================================*/
114
115/* internal prototypes (should be used via vtable only) */
116
140void QActive_start_(QActive * const me, uint_fast8_t prio,
141 QEvt const * * const qSto, uint_fast16_t const qLen,
142 void * const stkSto, uint_fast16_t const stkSize,
143 void const * const par);
144
168QEvt const *QActive_get_(QActive *const me);
169
170#ifdef Q_SPY
206 bool QActive_post_(QActive * const me, QEvt const * const e,
207 uint_fast16_t const margin,
208 void const * const sender);
209#else
210 bool QActive_post_(QActive * const me, QEvt const * const e,
211 uint_fast16_t const margin);
212#endif
213
233void QActive_postLIFO_(QActive * const me, QEvt const * const e);
234
235/*==========================================================================*/
236
241
242/* The following bitmasks are for the fields of the @c refCtr_ attribute
243* of the QTimeEvt struct (inherited from QEvt). This attribute is NOT used
244* for reference counting in time events, because the @c poolId_ attribute
245* is zero ("immutable events").
246*/
247#define QTE_IS_LINKED (1U << 7U)
248#define QTE_WAS_DISARMED (1U << 6U)
249#define QTE_TICK_RATE 0x0FU
250
251extern QF_EPOOL_TYPE_ QF_pool_[QF_MAX_EPOOL];
252extern uint_fast8_t QF_maxPool_;
257typedef struct QFreeBlock {
258 struct QFreeBlock * volatile next;
259} QFreeBlock;
260
261/* internal helper macros ***************************************************/
262
264#define QF_EVT_CONST_CAST_(e_) ((QEvt *)(e_))
265
267#define QF_EVT_REF_CTR_INC_(e_) (++QF_EVT_CONST_CAST_(e_)->refCtr_)
268
270#define QF_EVT_REF_CTR_DEC_(e_) (--QF_EVT_CONST_CAST_(e_)->refCtr_)
271
273#define QF_PTR_AT_(base_, i_) ((base_)[(i_)])
274
283#define QF_PTR_RANGE_(x_, min_, max_) (((min_) <= (x_)) && ((x_) <= (max_)))
284
285#endif /* QF_PKG_H */
#define QF_EPOOL_TYPE_
Definition: macros.h:116
signed int enum_t
Definition: qep.h:60
struct QFreeBlock *volatile next
Definition: qf_pkg.h:258
uint_fast8_t QF_maxPool_
Definition: qf_dyn.c:48
QF_EPOOL_TYPE_ QF_pool_[QF_MAX_EPOOL]
Definition: qf_dyn.c:47
structure representing a free block in the Native QF Memory Pool
Definition: qf_pkg.h:257
Priority Set of up to 64 elements.
Definition: qpset.h:120
#define QF_MAX_TICK_RATE
Active Object base class (based on QHsm implementation)
Definition: qf.h:106
bool QActive_post_(QActive *const me, QEvt const *const e, uint_fast16_t const margin, void const *const sender)
Definition: qf_actq.c:51
QEvt const * QActive_get_(QActive *const me)
Definition: qf_actq.c:238
void QActive_postLIFO_(QActive *const me, QEvt const *const e)
Definition: qf_actq.c:171
void QActive_start_(QActive *const me, uint_fast8_t prio, QEvt const **const qSto, uint_fast16_t const qLen, void *const stkSto, uint_fast16_t const stkSize, void const *const par)
Definition: qk.c:111
Event class.
Definition: qep.h:121
enum_t QF_maxPubSignal_
Definition: qf_ps.c:51
QSubscrList * QF_subscrList_
Definition: qf_ps.c:48
QTimeEvt QF_timeEvtHead_[QF_MAX_TICK_RATE]
Definition: qf_pkg.h:240
Time Event class.
Definition: qf.h:598