QP/C Real-Time Event Framework 8.1.5
Loading...
Searching...
No Matches
qp_port.h
Go to the documentation of this file.
1/*! @file
2@code_uid{qp_port.h, Sample @QPX port}
3@code_litem{Details}
4This is just an example of a QF port for a generic C11 compiler. Other specific QF ports will define the QF facilities differently.
5@endcode_uid
6*/
7#ifndef QP_PORT_H_
8#define QP_PORT_H_
9
10#include <stdint.h> // Exact-width types. WG14/N843 C99-C11 Standard
11#include <stdbool.h> // Boolean type. WG14/N843 C99-C11 Standard
12
13/*!
14@code_uid{#Q_NORETURN, No-return specifier for the Q_onError() callback function.}
15@code_litem{Details}
16Per the Software Safety Requirement @ref SREQ_QP_FDM_00, the Q_onError() handler should never return. Starting with the C99 Standard, the no-return specification can be provided at the language level, which may allow the compiler to apply optimizations (e.g., for impossible code paths downstream of Q_onError()). Also, the no-return specification is immensely valuable for static analysis tools. Unfortunately, MISRA-C:2025 still considers the specifier `_Noreturn` as an "emergent language feature", which should not be used (MISRA-C:2025 Rule 1.4, Required). The #Q_NORETURN macro encapsulates this deviation.
17@note
18If the `Q_NORETURN` macro is not defined in the QP port (`qf_port.h`), the default will be the C99 specifier `_Noreturn` applied in `qsafe.h`.
19@code_bw_trace{brief}
20- @tr{SAS_QP_FUSA_00}: <i>Architectural view: @QPX Functional Safety Subsystem (fault management).</i>
21@code_fw_trace
22@endcode_uid
23*/
24#define Q_NORETURN _Noreturn void
25
26// QF configuration for the data members of the QActive class ----------------
27/*!
28@code_uid{QACTIVE_EQUEUE_TYPE, Port-specific ::QActive event queue type.}
29@code_fw_trace
30@endcode_uid
31*/
32#define QACTIVE_EQUEUE_TYPE QEQueue
33
34/*!
35@code_uid{QACTIVE_OS_OBJ_TYPE, Port-specific ::QActive "OS-object" type.}
36@code_fw_trace
37@endcode_uid
38*/
39#define QACTIVE_OS_OBJ_TYPE void*
40
41/*!
42@code_uid{QACTIVE_THREAD_TYPE, Port-specific ::QActive thread type.}
43@code_fw_trace
44@endcode_uid
45*/
46#define QACTIVE_THREAD_TYPE void const *
47
48// interrupt disabling mechanism ---------------------------------------------
49/*!
50@code_uid{QF_INT_DISABLE(), Port-specific interrupt disable}
51@code_fw_trace
52- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
53@endcode_uid
54*/
55#define QF_INT_DISABLE() intDisable()
56
57/*!
58@code_uid{QF_INT_ENABLE(), Port-specific interrupt enable}
59@code_fw_trace
60- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
61@endcode_uid
62*/
63#define QF_INT_ENABLE() intEnable()
64
65// QF critical section mechanism ---------------------------------------------
66/*!
67@code_uid{#QF_CRIT_STAT, Define the critical section status that was present before entering the critical section.}
68@code_litem{Details}
69For critical sections that are allowed to nest, the critical section status must be saved and restored at the end. This macro provides the storage for saving the status.
70@note
71This macro might be empty, in which case, the critical section status is not saved or restored. Such critical sections won't be able to nest. Also, note that the macro should be invoked without the closing semicolon.
72@code_fw_trace
73@endcode_uid
74*/
75#define QF_CRIT_STAT crit_stat_t crit_stat_;
76
77/*!
78@code_uid{QF_CRIT_ENTRY(), Port-specific critical section entry}
79@code_litem{Details}
80If the critical section status is provided, the macro saves the critical section status from before entering the critical section. Otherwise, the macro just unconditionally enters the critical section without saving the status.
81@code_fw_trace
82- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
83@endcode_uid
84*/
85#define QF_CRIT_ENTRY() (crit_stat_ = critEntry())
86
87/*!
88@code_uid{QF_CRIT_EXIT(), Port-specific critical section exit}
89@code_litem{Details}
90If the critical section status is provided, the macro restores the critical section status saved by QF_CRIT_ENTRY(). Otherwise, the macro just unconditionally exits the critical section.
91@code_fw_trace
92- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
93@endcode_uid
94*/
95#define QF_CRIT_EXIT() critExit(crit_stat_)
96
97/*!
98@code_uid{QF_CRIT_EXIT_NOP(), No-operation for exiting a critical section}
99@code_litem{Details}
100In some QF ports, the critical section exit takes effect only on the next machine instruction. If this next instruction is another entry to a critical section, the critical section won't be exited, but rather the two adjacent critical sections would be _merged_. The QF_CRIT_EXIT_NOP() macro contains minimal code required to prevent such merging of critical sections in QF ports.
101@code_fw_trace
102- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
103@endcode_uid
104*/
105#define QF_CRIT_EXIT_NOP() __asm volatile ("isb" ::: "memory")
106
107/*!
108@code_uid{QF_CRIT_EST(), Port-specific establishing a critical section (without saving the status)}
109@code_litem{Details}
110This port-specific macro only establishes a critical section (to later call Q_onError() error handler), but since Q_onError() never returns, there is no need to exit such established critical section.
111@code_fw_trace
112- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
113@endcode_uid
114*/
115#define QF_CRIT_EST() ((void)critEntry())
116
117/*!
118@code_uid{QF_LOG2(), Port-specific integer log-base-2 of a 32-bit bitmask}
119@code_litem{Details}
120Calculate integer log-base-2 of a given bitmask (1-based) used to quickly determine the highest-number 1-bit in the bitmask. This operation is used frequently during task scheduling and publish-subscribe.
121@param[in] bitmask_ 32-bit bitmask
122@returns 1-based integer log-base-2 of the provided bitmask. Examples:
123- QF_LOG2(0x00000000U) == 0U
124- QF_LOG2(0x00000001U) == 1U
125- QF_LOG2(0x00000002U) == 2U
126- QF_LOG2(0x00000004U) == 3U
127- QF_LOG2(0x00000008U) == 4U
128- QF_LOG2(0x00000010U) == 5U
129...
130- QF_LOG2(0x80000010U) == 32U
131
132@note
133This operation is performed frequently in time-critical parts of the code. Some CPUs provide such calculation in hardware (e.g., as a machine instruction). For example, ARMv7 and higher architectures support the related CLZ (count leading zeroes) instruction, with the following relationship:
134QF_LOG2(bitmask_) == 32U - CLZ(bitmask_).
135@code_fw_trace
136- @tr{DVR_QP_MC5_D4_9B}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (CORRECT diagnostics)</i>
137@endcode_uid
138*/
139#define QF_LOG2(bitmask_) QF_qlog2((uint32_t)(bitmask_))
140
141//typedef unsigned int crit_stat_t;
142//crit_stat_t critEntry(void);
143//void critExit(crit_stat_t stat);
144
145#ifdef QF_MEM_ISOLATE
146 /*!
147 @code_uid{QF_ON_CONTEXT_SW, Enable memory isolation requires the context-switch}
148 @code_bw_trace{brief}
149 - @tr{SAS_QP_FFI_PM}: <i>Architectural view: Memory isolation programming model.</i>
150 - @tr{AOU_QA_MI_00}: <i>@QPX Application should apply <u>memory isolation mechanisms</u> provided in @QPX Framework.</i>
151 @code_fw_trace
152 @endcode_uid
153 */
154 #define QF_ON_CONTEXT_SW 1U
155
156 /*!
157 @code_uid{QF_MEM_SYS(), Port-specific establishing _System Context_ for memory protection}
158 @code_bw_trace{brief}
159 - @tr{SAS_QP_FFI_PM}: <i>Architectural view: Memory isolation programming model.</i>
160 - @tr{AOU_QA_MI_00}: <i>@QPX Application should apply <u>memory isolation mechanisms</u> provided in @QPX Framework.</i>
161 @code_fw_trace
162 - @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
163 @endcode_uid
164 */
165 #define QF_MEM_SYS() QF_onMemSys()
166
167 /*!
168 @code_uid{QF_MEM_APP(), Port-specific establishing _Application Context_ for memory protection}
169 @code_bw_trace{brief}
170 - @tr{SAS_QP_FFI_PM}: <i>Architectural view: Memory isolation programming model.</i>
171 - @tr{AOU_QA_MI_00}: <i>@QPX Application should apply <u>memory isolation mechanisms</u> provided in @QPX Framework.</i>
172 @code_fw_trace
173 - @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
174 @endcode_uid
175 */
176 #define QF_MEM_APP() QF_onMemApp()
177
178#ifdef Q_SPY
179 /*!
180 @code_uid{QS_MEM_SYS(), Port-specific establishing _System Context_ for memory protection in conditional QS software tracing code.}
181 @code_bw_trace{brief}
182 - @tr{SAS_QP_FFI_PM}: <i>Architectural view: Memory isolation programming model.</i>
183 - @tr{AOU_QA_MI_00}: <i>@QPX Application should apply <u>memory isolation mechanisms</u> provided in @QPX Framework.</i>
184 @code_fw_trace
185 - @tr{DVR_QS_MC5_D4_9A}: <i>Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnosis)</i>
186 @endcode_uid
187 */
188 #define QS_MEM_SYS() QF_MEM_SYS()
189
190 /*!
191 @code_uid{QS_MEM_APP(), Port-specific establishing _Application Context_ for memory protection in conditional QS software tracing code.}
192 @code_bw_trace{brief}
193 - @tr{SAS_QP_FFI_PM}: <i>Architectural view: Memory isolation programming model.</i>
194 - @tr{AOU_QA_MI_00}: <i>@QPX Application should apply <u>memory isolation mechanisms</u> provided in @QPX Framework.</i>
195 @code_fw_trace
196 - @tr{DVR_QS_MC5_D4_9A}: <i>Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnosis)</i>
197 @endcode_uid
198 */
199 #define QS_MEM_APP() QF_MEM_APP()
200#endif
201
202#endif // QF_MEM_ISOLATE
203
204// QV-specific ---------------------------------------------------------------
205/*!
206@code_uid{QV_CPU_SLEEP(), Port-specific method to put the CPU to sleep __safely__ in the non-preemptive QV kernel (to be called from QV::QV_onIdle()).}
207@code_fw_trace
208- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
209@endcode_uid
210*/
211#define QV_CPU_SLEEP() \
212do { \
213 __disable_interrupt(); \
214 QF_INT_ENABLE(); \
215 __WFI(); \
216 __enable_interrupt(); \
217} while (false)
218
219
220// QK-specific ---------------------------------------------------------------
221/*!
222@code_uid{QK_ISR_CONTEXT_(), Port-specific method to check if the QK kernel executes in the ISR context (used internally in QK only).}
223@returns `true` if the caller executes in the ISR context and `false` otherwise
224@code_fw_trace
225- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
226@endcode_uid
227*/
228#define QK_ISR_CONTEXT_() (QK_priv_.intNest != 0U)
229
230/*!
231@code_uid{QK_ISR_ENTRY(), Port-specific method to inform QK kernel about the ISR entry.}
232@code_fw_trace
233- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
234@endcode_uid
235*/
236#define QK_ISR_ENTRY() \
237do { \
238 QF_INT_DISABLE(); \
239 ++QK_priv_.intNest; \
240 QF_QS_ISR_ENTRY(QK_priv_.intNest, QK_currPrio_); \
241 QF_INT_ENABLE(); \
242} while (false)
243
244/*!
245@code_uid{QK_ISR_EXIT(), Port-specific method to inform QK kernel about the ISR exit.}
246@code_fw_trace
247- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
248@endcode_uid
249*/
250#define QK_ISR_EXIT() \
251do { \
252 QF_INT_DISABLE(); \
253 --QK_priv_.intNest; \
254 if (QK_priv_.intNest == 0U) { \
255 if (QK_sched_() != 0U) { \
256 QK_activate_(); \
257 } \
258 } \
259 QF_INT_ENABLE(); \
260} while (false)
261
262// QXK-specific --------------------------------------------------------------
263/*!
264@code_uid{QXK_ISR_CONTEXT_(), Port-specific method to check if the QXK kernel executes in the ISR context (used internally in QXK only).}
265@returns `true` if the caller executes in the ISR context and `false` otherwise
266@code_fw_trace
267- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
268@endcode_uid
269*/
270#define QXK_ISR_CONTEXT_() (QXK_get_IPSR() != 0U)
271
272/*!
273@code_uid{QXK_CONTEXT_SWITCH_(), Port-specific method to trigger context switch (used internally in QXK only).}
274@code_fw_trace
275- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
276@endcode_uid
277*/
278#define QXK_CONTEXT_SWITCH_() (trigPendSV())
279
280/*!
281@code_uid{QXK_ISR_ENTRY(), Port-specific method to inform QXK kernel about the ISR entry.}
282@code_fw_trace
283- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
284@endcode_uid
285*/
286#define QXK_ISR_ENTRY() ((void)0)
287
288/*!
289@code_uid{QXK_ISR_EXIT(), Port-specific method to inform QXK kernel about the ISR exit.}
290@code_fw_trace
291- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
292@endcode_uid
293*/
294#define QXK_ISR_EXIT() do { \
295 QF_INT_DISABLE(); \
296 if (QXK_sched_() != 0U) { \
297 *Q_UINT2PTR_CAST(uint32_t, 0xE000ED04U) = (1U << 28U);\
298 } \
299 QF_INT_ENABLE(); \
300 QXK_ARM_ERRATUM_838869(); \
301} while (false)
302
303// Scheduling locking port interface (example) -------------------------------
304/*!
305@code_uid{QF_SCHED_STAT_, Port-specific type of the scheduler lock status (for internal use in QF only).}
306@code_fw_trace
307@endcode_uid
308*/
309#define QF_SCHED_STAT_ QSchedStatus lockStat_;
310
311/*!
312@code_uid{QF_SCHED_LOCK_(), Port-specific method to lock the scheduler (for internal use in QF only).}
313@param[in] ceil_ priority-ceiling up to which the scheduler should be locked
314@code_fw_trace
315- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
316@endcode_uid
317*/
318#define QF_SCHED_LOCK_(ceil_) do { \
319 if (QK_ISR_CONTEXT_()) { \
320 lockStat_ = 0xFFU; \
321 } else { \
322 lockStat_ = QK_schedLock((ceil_)); \
323 } \
324} while (false)
325
326/*!
327@code_uid{QF_SCHED_UNLOCK_(), Port-specific method to unlock the scheduler (for internal use in QF only).}
328@code_fw_trace
329- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
330@endcode_uid
331*/
332#define QF_SCHED_UNLOCK_() do { \
333 if (lockStat_ != 0xFFU) { \
334 QK_schedUnlock(lockStat_); \
335 } \
336} while (false)
337
338// Event-Queue port interface (example) --------------------------------------
339// QActive event queue customization...
340/*!
341@code_uid{QACTIVE_EQUEUE_WAIT_(), Port-specific method to wait on an empty Active Object event queue (for internal use only).}
342@param[in,out] me_ current instance pointer (see @ref SAS_QP_OOA)
343@code_fw_trace
344- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
345@endcode_uid
346*/
347#define QACTIVE_EQUEUE_WAIT_(me_) ((void)0)
348
349/*!
350@code_uid{QACTIVE_EQUEUE_SIGNAL_(), Port-specific method to signal Active Object event queue (for internal use only).}
351@param[in,out] me_ current instance pointer (see @ref SAS_QP_OOA)
352@code_fw_trace
353- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
354@endcode_uid
355*/
356#define QACTIVE_EQUEUE_SIGNAL_(me_) do { \
357 QPSet_insert(&QK_priv_.readySet, (uint_fast8_t)(me_)->prio); \
358 QPSet_update_(&QK_priv_.readySet, &QK_priv_.readySet_dis); \
359 if (!QK_ISR_CONTEXT_()) { \
360 if (QK_sched_() != 0U) { \
361 QK_activate_(); \
362 } \
363 } \
364} while (false)
365
366/*!
367@code_uid{QXTHREAD_EQUEUE_SIGNAL_(), Port-specific method to signal eXtended thread event queue (for internal use only).}
368@param[in,out] me_ current instance pointer (see @ref SAS_QP_OOA)
369@code_fw_trace
370- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
371@endcode_uid
372*/
373#define QXTHREAD_EQUEUE_SIGNAL_(me_) do { \
374 if (me->super.temp.obj == QXK_PTR_CAST_(QMState*, &me->eQueue)) { \
375 (void)QXThread_teDisarm_(QXTHREAD_CAST_(me)); \
376 QPSet_insert(&QXK_priv_.readySet, (uint_fast8_t)me->prio); \
377 QPSet_update_(&QXK_priv_.readySet, &QXK_priv_.readySet_dis); \
378 if (!QXK_ISR_CONTEXT_()) { \
379 (void)QXK_sched_(); \
380 } \
381 } \
382} while (false)
383
384// Event-Pool port interface (example) ---------------------------------------
385/*!
386@code_uid{QF_EPOOL_TYPE_, Port-specific type of the event pool (for internal use in QF only).}
387@code_fw_trace
388@endcode_uid
389*/
390#define QF_EPOOL_TYPE_ QMPool
391
392/*!
393@code_uid{QF_EPOOL_INIT_(), Port-specific event pool initialization (for internal use in QF only).}
394@param[in,out] p_ event pool pointer
395@param[in] poolSto_ storage for the pool (pointer to the pool buffer)
396@param[in] poolSize_ size of the pool storage in [bytes]
397@param[in] evtSize_ event size of this pool in [bytes]
398@code_fw_trace
399- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
400@endcode_uid
401*/
402#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \
403 (QMPool_init(&(p_), (poolSto_), (poolSize_), (evtSize_)))
404
405/*!
406@code_uid{QF_EPOOL_EVENT_SIZE_(), Port-specific event pool block-size() operation (for internal use in QF only).}
407@param[in,out] p_ event pool pointer
408@code_fw_trace
409- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
410@endcode_uid
411*/
412#define QF_EPOOL_EVENT_SIZE_(p_) ((uint16_t)(p_).blockSize)
413
414/*!
415@code_uid{QF_EPOOL_GET_(), Port-specific event pool get() operation (for internal use in QF only).}
416@param[in,out] p_ event pool pointer
417@param[out] e_ event pointer to be assigned the obtained event
418@param[in] m_ margin (# free events that must still remain in the pool)
419@param[in] qsId_ QS ID for the QS local filter
420@code_fw_trace
421- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
422- @tr{DVR_QP_MC5_R11_5}: <i>MISRA-C:2025 Rule 11.5(Advisory): A conversion should not be performed from pointer to void into pointer to object</i>
423@endcode_uid
424*/
425#define QF_EPOOL_GET_(p_, e_, m_, qsId_) \
426 ((e_) = (QEvt *)QMPool_get(&(p_), (m_), (qsId_)))
427
428/*!
429@code_uid{QF_EPOOL_PUT_(), Port-specific event pool put() operation (for internal use in QF only).}
430@param[in,out] p_ event pool pointer
431@param[out] e_ event pointer to return to the pool
432@param[in] qsId_ QS ID for the QS local filter
433@code_fw_trace
434- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
435@endcode_uid
436*/
437#define QF_EPOOL_PUT_(p_, e_, qsId_) (QMPool_put(&(p_), (e_), (qsId_)))
438
439/*!
440@code_uid{QF_EPOOL_USE_(), Port-specific event pool # used events operation (for internal use in QF only).}
441@param[in] ePool_ event pool pointer
442@returns # used events in the pool at this moment (allocated and not returned yet)
443@code_fw_trace
444- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
445@endcode_uid
446*/
447#define QF_EPOOL_USE_(ePool_) (QMPool_getUse(ePool_))
448
449/*!
450@code_uid{QF_EPOOL_FREE_(), Port-specific event pool # free events operation (for internal use in QF only).}
451@param[in] ePool_ event pool pointer
452@returns # free events in the pool at this moment (available to allocate)
453@code_fw_trace
454- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
455@endcode_uid
456*/
457#define QF_EPOOL_FREE_(ePool_) ((uint16_t)(ePool_)->nFree)
458
459/*!
460@code_uid{QF_EPOOL_MIN_(), Port-specific event pool minimum # events since initialization (for internal use in QF only).}
461@param[in] ePool_ event pool pointer
462@returns minimal # free events in the pool since initialization
463@code_fw_trace
464- @tr{DVR_QP_MC5_D4_9A}: <i>MISRA-C:2025 Directive 4.9(Advisory): A function should be used in preference to a function-like macro where they are interchangeable (FALSE-POSITIVE diagnostics)</i>
465@endcode_uid
466*/
467#define QF_EPOOL_MIN_(ePool_) ((uint16_t)(ePool_)->nMin)
468
469#ifdef QF_MEM_ISOLATE
470
471/*! @static @public @memberof QF
472@code_uid{QF::QF_onMemSys(), Port-specific callback to establish the <u>System</u> Memory Protection Mode.}
473@qualifier crit-sect
474@code_litem{Usage}
475This callback is enabled by defining the macro #QF_MEM_ISOLATE.
476
477@attention
478QF_onMemSys() is invoked with interrupts **disabled** and must also return with interrupts **disabled**.
479
480@code{c}
481#ifdef QF_MEM_ISOLATE
482void QF_onMemSys(void) {
483 // Enable MPU with background region (SYS mode)
484 MPU->CTRL = MPU_CTRL_PRIVDEFENA_Msk | MPU_CTRL_ENABLE_Msk;
485 __DSB();
486 __ISB();
487}
488#endif // QF_MEM_ISOLATE
489@endcode
490@code_fw_trace
491@endcode_uid
492*/
493void QF_onMemSys(void);
494
495/*! @static @public @memberof QF
496@code_uid{QF::QF_onMemApp(), Port-specific callback to establish the <u>Application</u> Memory Protection Mode.}
497@qualifier crit-sect
498@code_litem{Usage}
499This callback is enabled by defining the macro #QF_MEM_ISOLATE.
500
501@attention
502QF_onMemApp() is invoked with interrupts **disabled** and must also return with interrupts **disabled**.
503
504@code{c}
505#ifdef QF_MEM_ISOLATE
506void QF_onMemApp(void) {
507 // Enable MPU WITHOUT background region (APP mode)
508 MPU->CTRL = MPU_CTRL_ENABLE_Msk;
509 __DSB();
510 __ISB();
511}
512#endif // QF_MEM_ISOLATE
513@endcode
514@code_fw_trace
515@endcode_uid
516*/
517void QF_onMemApp(void);
518
519#endif // QF_MEM_ISOLATE
520
521// include files -------------------------------------------------------------
522#include "queue.h" // QK kernel uses the native QP event queue
523#include "qmpool.h" // QK kernel uses the native QP memory pool
524#include "qp.h" // QP framework
525#include "qk.h" // QK kernel
526
527#endif // QP_PORT_H_
QK (preemptive non-blocking kernel) platform-independent public interface.
QP/C native platform-independent memory pool QMPool interface.
QP/C Framework platform-independent public interface.