QP/C  6.5.1
qf_pkg.h
Go to the documentation of this file.
1 
40 #ifndef qf_pkg_h
41 #define qf_pkg_h
42 
43 /****************************************************************************/
44 /* QF-specific critical section */
45 #ifndef QF_CRIT_STAT_TYPE
46 
57  #define QF_CRIT_STAT_
58 
69  #define QF_CRIT_ENTRY_() QF_CRIT_ENTRY(dummy)
70 
81  #define QF_CRIT_EXIT_() QF_CRIT_EXIT(dummy)
82 
83 #else
84  #define QF_CRIT_STAT_ QF_CRIT_STAT_TYPE critStat_;
85  #define QF_CRIT_ENTRY_() QF_CRIT_ENTRY(critStat_)
86  #define QF_CRIT_EXIT_() QF_CRIT_EXIT(critStat_)
87 #endif
88 
89 /****************************************************************************/
90 /* Assertions inside the crticial section */
91 #ifdef Q_NASSERT /* Q_NASSERT defined--assertion checking disabled */
92 
93  #define Q_ASSERT_CRIT_(id_, test_) ((void)0)
94  #define Q_REQUIRE_CRIT_(id_, test_) ((void)0)
95  #define Q_ERROR_CRIT_(id_) ((void)0)
96 
97 #else /* Q_NASSERT not defined--assertion checking enabled */
98 
99  #define Q_ASSERT_CRIT_(id_, test_) do {\
100  if ((test_)) {} else { \
101  QF_CRIT_EXIT_(); \
102  Q_onAssert(&Q_this_module_[0], (int_t)(id_)); \
103  } \
104  } while (0)
105 
106  #define Q_REQUIRE_CRIT_(id_, test_) Q_ASSERT_CRIT_((id_), (test_))
107 
108  #define Q_ERROR_CRIT_(id_) do { \
109  QF_CRIT_EXIT_(); \
110  Q_onAssert(&Q_this_module_[0], (int_t)(id_)); \
111  } while (0)
112 
113 #endif /* Q_NASSERT */
114 
115 /****************************************************************************/
116 /* internal implementation (should be used via vtbl only) */
117 
119 void QActive_start_(QActive * const me, uint_fast8_t prio,
120  QEvt const *qSto[], uint_fast16_t qLen,
121  void *stkSto, uint_fast16_t stkSize,
122  QEvt const *ie);
123 
125 QEvt const *QActive_get_(QActive *const me);
126 
127 #ifdef Q_SPY
128 
129  bool QActive_post_(QActive * const me, QEvt const * const e,
130  uint_fast16_t const margin,
131  void const * const sender);
132 #else
133  bool QActive_post_(QActive * const me, QEvt const * const e,
134  uint_fast16_t const margin);
135 #endif
136 
138 void QActive_postLIFO_(QActive * const me, QEvt const * const e);
139 
140 
141 /****************************************************************************/
144 
145 /* The following flags and bitmasks are for the fields of the @c refCtr_
146 * attribute of the QTimeEvt struct (inherited from QEvt). This attribute
147 * is NOT used for reference counting in time events, because the @c poolId_
148 * attribute is zero ("static events").
149 */
150 enum {
151  TE_IS_LINKED = (uint8_t)(1U << 7), /* flag */
152  TE_WAS_DISARMED = (uint8_t)(1U << 6), /* flag */
153  TE_TICK_RATE = (uint8_t)0x0F /* bitmask */
154 };
155 
157 extern uint_fast8_t QF_maxPool_;
158 extern QSubscrList *QF_subscrList_;
159 extern enum_t QF_maxPubSignal_;
162 typedef struct QFreeBlock {
163  struct QFreeBlock * volatile next;
164 } QFreeBlock;
165 
166 /* internal helper macros ***************************************************/
167 
169 #define QF_EVT_REF_CTR_INC_(e_) (++((QEvt *)(e_))->refCtr_)
170 
172 #define QF_EVT_REF_CTR_DEC_(e_) (--((QEvt *)(e_))->refCtr_)
173 
175 #define QF_PTR_AT_(base_, i_) ((base_)[(i_)])
176 
185 #define QF_PTR_RANGE_(x_, min_, max_) (((min_) <= (x_)) && ((x_) <= (max_)))
186 
187 /****************************************************************************/
188 #ifdef Q_SPY /* QS software tracing enabled? */
189 
190  #if (QF_EQUEUE_CTR_SIZE == 1)
191 
197  #define QS_EQC_(ctr_) QS_u8_((uint8_t)(ctr_))
198  #elif (QF_EQUEUE_CTR_SIZE == 2)
199  #define QS_EQC_(ctr_) QS_u16_((uint16_t)(ctr_))
200  #elif (QF_EQUEUE_CTR_SIZE == 4)
201  #define QS_EQC_(ctr_) QS_u32_((uint32_t)(ctr_))
202  #else
203  #error "QF_EQUEUE_CTR_SIZE not defined"
204  #endif
205 
206 
207  #if (QF_EVENT_SIZ_SIZE == 1)
208 
214  #define QS_EVS_(size_) QS_u8_((uint8_t)(size_))
215  #elif (QF_EVENT_SIZ_SIZE == 2)
216  #define QS_EVS_(size_) QS_u16_((uint16_t)(size_))
217  #elif (QF_EVENT_SIZ_SIZE == 4)
218  #define QS_EVS_(size_) QS_u32_((uint32_t)(size_))
219  #endif
220 
221 
222  #if (QF_MPOOL_SIZ_SIZE == 1)
223 
229  #define QS_MPS_(size_) QS_u8_((uint8_t)(size_))
230  #elif (QF_MPOOL_SIZ_SIZE == 2)
231  #define QS_MPS_(size_) QS_u16_((uint16_t)(size_))
232  #elif (QF_MPOOL_SIZ_SIZE == 4)
233  #define QS_MPS_(size_) QS_u32_((uint32_t)(size_))
234  #endif
235 
236  #if (QF_MPOOL_CTR_SIZE == 1)
237 
243  #define QS_MPC_(ctr_) QS_u8_((uint8_t)(ctr_))
244  #elif (QF_MPOOL_CTR_SIZE == 2)
245  #define QS_MPC_(ctr_) QS_u16_((uint16_t)(ctr_))
246  #elif (QF_MPOOL_CTR_SIZE == 4)
247  #define QS_MPC_(ctr_) QS_u32_((uint16_t)(ctr_))
248  #endif
249 
250 
251  #if (QF_TIMEEVT_CTR_SIZE == 1)
252 
258  #define QS_TEC_(ctr_) QS_u8_((uint8_t)(ctr_))
259  #elif (QF_TIMEEVT_CTR_SIZE == 2)
260  #define QS_TEC_(ctr_) QS_u16_((uint16_t)(ctr_))
261  #elif (QF_TIMEEVT_CTR_SIZE == 4)
262  #define QS_TEC_(ctr_) QS_u32_((uint32_t)(ctr_))
263  #endif
264 
265 #endif /* Q_SPY */
266 
267 #endif /* qf_pkg_h */
Time Event structure.
Definition: qf.h:442
#define QF_EPOOL_TYPE_
This macro defines the type of the event pool used in the QK kernel.
Definition: macros.h:109
unsigned char uint8_t
exact-width 8-bit unsigned int
Definition: stdint.h:29
enum_t QF_maxPubSignal_
the maximum published signal
Definition: qf_ps.c:55
QTimeEvt QF_timeEvtHead_[QF_MAX_TICK_RATE]
heads of linked lists of time events, one for every clock tick rate
Definition: qf_time.c:53
unsigned int uint_fast8_t
fast at-least 8-bit unsigned int
Definition: stdint.h:36
int enum_t
typedef for enumerations used for event signals
Definition: qep.h:76
uint_fast8_t QF_maxPool_
Definition: qf_dyn.c:55
Event structure.
Definition: qep.h:153
unsigned int uint_fast16_t
fast at-least 16-bit unsigned int
Definition: stdint.h:38
void QActive_postLIFO_(QActive *const me, QEvt const *const e)
Implementation of the active object post LIFO operation.
Definition: qf_actq.c:237
Priority Set of up to 32 elements.
Definition: qpset.h:63
#define QF_MAX_EPOOL
Default value of the macro configurable value in qf_port.h.
Definition: qf.h:70
#define QF_MAX_TICK_RATE
Default value of the macro configurable value in qf_port.h.
Definition: qf.h:77
structure representing a free block in the Native QF Memory Pool
Definition: qf_pkg.h:162
QEvt const * QActive_get_(QActive *const me)
Get an event from the event queue of an active object.
Definition: qf_actq.c:329
QSubscrList * QF_subscrList_
the subscriber list array
Definition: qf_ps.c:54
struct QFreeBlock *volatile next
Definition: qf_pkg.h:163
Active Object (based on QHsm implementation)
Definition: qf.h:114
bool QActive_post_(QActive *const me, QEvt const *const e, uint_fast16_t const margin, void const *const sender)
Implementation of the active object post (FIFO) operation.
Definition: qf_actq.c:93
void QActive_start_(QActive *const me, uint_fast8_t prio, QEvt const *qSto[], uint_fast16_t qLen, void *stkSto, uint_fast16_t stkSize, QEvt const *ie)
Implementation of the active object start operation.
Definition: qutest.c:82
QF_EPOOL_TYPE_ QF_pool_[QF_MAX_EPOOL]
allocate event pools
Definition: qf_dyn.c:54