Sample QP/C port. More...
#include <stdint.h>#include <stdbool.h>#include "queue.h"#include "qmpool.h"#include "qp.h"#include "qk.h"Go to the source code of this file.
Macros | |
| #define | Q_NORETURN _Noreturn void |
| No-return specifier for the Q_onError() callback function. | |
| #define | QACTIVE_EQUEUE_TYPE QEQueue |
| Port-specific QActive event queue type. | |
| #define | QACTIVE_OS_OBJ_TYPE void* |
| Port-specific QActive "OS-object" type. | |
| #define | QACTIVE_THREAD_TYPE void const * |
| Port-specific QActive thread type. | |
| #define | QF_INT_DISABLE() |
| Port-specific interrupt disable. | |
| #define | QF_INT_ENABLE() |
| Port-specific interrupt enable. | |
| #define | QF_CRIT_STAT crit_stat_t crit_stat_; |
| Define the critical section status that was present before entering the critical section. | |
| #define | QF_CRIT_ENTRY() |
| Port-specific critical section entry. | |
| #define | QF_CRIT_EXIT() |
| Port-specific critical section exit. | |
| #define | QF_CRIT_EXIT_NOP() |
| No-operation for exiting a critical section. | |
| #define | QF_CRIT_EST() |
| Port-specific establishing a critical section (without saving the status). | |
| #define | QF_LOG2(bitmask_) |
| Port-specific integer log-base-2 of a 32-bit bitmask. | |
| #define | 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()). | |
| #define | QK_ISR_CONTEXT_() |
| Port-specific method to check if the QK kernel executes in the ISR context (used internally in QK only). | |
| #define | QK_ISR_ENTRY() |
| Port-specific method to inform QK kernel about the ISR entry. | |
| #define | QK_ISR_EXIT() |
| Port-specific method to inform QK kernel about the ISR exit. | |
| #define | QXK_ISR_CONTEXT_() |
| Port-specific method to check if the QXK kernel executes in the ISR context (used internally in QXK only). | |
| #define | QXK_CONTEXT_SWITCH_() |
| Port-specific method to trigger context switch (used internally in QXK only). | |
| #define | QXK_ISR_ENTRY() |
| Port-specific method to inform QXK kernel about the ISR entry. | |
| #define | QXK_ISR_EXIT() |
| Port-specific method to inform QXK kernel about the ISR exit. | |
| #define | QF_SCHED_STAT_ QSchedStatus lockStat_; |
| Port-specific type of the scheduler lock status (for internal use in QF only). | |
| #define | QF_SCHED_LOCK_(ceil_) |
| Port-specific method to lock the scheduler (for internal use in QF only). | |
| #define | QF_SCHED_UNLOCK_() |
| Port-specific method to unlock the scheduler (for internal use in QF only). | |
| #define | QACTIVE_EQUEUE_WAIT_(me_) |
| Port-specific method to wait on an empty Active Object event queue (for internal use only). | |
| #define | QACTIVE_EQUEUE_SIGNAL_(me_) |
| Port-specific method to signal Active Object event queue (for internal use only). | |
| #define | QXTHREAD_EQUEUE_SIGNAL_(me_) |
| Port-specific method to signal eXtended thread event queue (for internal use only). | |
| #define | QF_EPOOL_TYPE_ QMPool |
| Port-specific type of the event pool (for internal use in QF only). | |
| #define | QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) |
| Port-specific event pool initialization (for internal use in QF only). | |
| #define | QF_EPOOL_EVENT_SIZE_(p_) |
| Port-specific event pool block-size() operation (for internal use in QF only). | |
| #define | QF_EPOOL_GET_(p_, e_, m_, qsId_) |
| Port-specific event pool get() operation (for internal use in QF only). | |
| #define | QF_EPOOL_PUT_(p_, e_, qsId_) |
| Port-specific event pool put() operation (for internal use in QF only). | |
| #define | QF_EPOOL_USE_(ePool_) |
| Port-specific event pool # used events operation (for internal use in QF only). | |
| #define | QF_EPOOL_FREE_(ePool_) |
| Port-specific event pool # free events operation (for internal use in QF only). | |
| #define | QF_EPOOL_MIN_(ePool_) |
| Port-specific event pool minimum # events since initialization (for internal use in QF only). | |
Sample QP/C port.
Details
This is just an example of a QF port for a generic C11 compiler. Other specific QF ports will define the QF facilities differently.
Definition in file qp_port.h.
| #define Q_NORETURN _Noreturn void |
No-return specifier for the Q_onError() callback function.
Details
Per the Software Safety Requirement SSRS_QA_FDM_20, 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.
Backward Traceability
Forward Traceability
| #define QACTIVE_EQUEUE_TYPE QEQueue |
| #define QACTIVE_OS_OBJ_TYPE void* |
| #define QACTIVE_THREAD_TYPE void const * |
| #define QF_INT_DISABLE | ( | ) |
| #define QF_INT_ENABLE | ( | ) |
| #define QF_CRIT_STAT crit_stat_t crit_stat_; |
Define the critical section status that was present before entering the critical section.
Details
For 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.
Forward Traceability
| #define QF_CRIT_ENTRY | ( | ) |
Port-specific critical section entry.
Details
If 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.
Forward Traceability
| #define QF_CRIT_EXIT | ( | ) |
Port-specific critical section exit.
Details
If 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.
Forward Traceability
| #define QF_CRIT_EXIT_NOP | ( | ) |
No-operation for exiting a critical section.
Details
In 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.
Forward Traceability
| #define QF_CRIT_EST | ( | ) |
Port-specific establishing a critical section (without saving the status).
Details
This 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.
Forward Traceability
| #define QF_LOG2 | ( | bitmask_ | ) |
Port-specific integer log-base-2 of a 32-bit bitmask.
Details
Calculate integer log-base-2 of a given bitmask (1-based) used to quickly determine the higest-number 1-bit in the bitmask. This operation is used frequently during task scheduling and publish-subscribe.
| [in] | bitmask_ | 32-bit bitmask |
Forward Traceability
| #define 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()).
Forward Traceability
| #define QK_ISR_CONTEXT_ | ( | ) |
Port-specific method to check if the QK kernel executes in the ISR context (used internally in QK only).
Forward Traceability
| #define QK_ISR_ENTRY | ( | ) |
Port-specific method to inform QK kernel about the ISR entry.
Forward Traceability
| #define QK_ISR_EXIT | ( | ) |
Port-specific method to inform QK kernel about the ISR exit.
Forward Traceability
| #define QXK_ISR_CONTEXT_ | ( | ) |
Port-specific method to check if the QXK kernel executes in the ISR context (used internally in QXK only).
Forward Traceability
| #define QXK_CONTEXT_SWITCH_ | ( | ) |
Port-specific method to trigger context switch (used internally in QXK only).
Forward Traceability
| #define QXK_ISR_ENTRY | ( | ) |
Port-specific method to inform QXK kernel about the ISR entry.
Forward Traceability
| #define QXK_ISR_EXIT | ( | ) |
Port-specific method to inform QXK kernel about the ISR exit.
Forward Traceability
| #define QF_SCHED_STAT_ QSchedStatus lockStat_; |
| #define QF_SCHED_LOCK_ | ( | ceil_ | ) |
Port-specific method to lock the scheduler (for internal use in QF only).
| [in] | ceil_ | priority-ceiling up to which the scheduler should be locked |
Forward Traceability
| #define QF_SCHED_UNLOCK_ | ( | ) |
Port-specific method to unlock the scheduler (for internal use in QF only).
Forward Traceability
| #define QACTIVE_EQUEUE_WAIT_ | ( | me_ | ) |
Port-specific method to wait on an empty Active Object event queue (for internal use only).
| [in,out] | me_ | current instance pointer (see SAS_QP_OOA) |
Forward Traceability
| #define QACTIVE_EQUEUE_SIGNAL_ | ( | me_ | ) |
Port-specific method to signal Active Object event queue (for internal use only).
| [in,out] | me_ | current instance pointer (see SAS_QP_OOA) |
Forward Traceability
| #define QXTHREAD_EQUEUE_SIGNAL_ | ( | me_ | ) |
Port-specific method to signal eXtended thread event queue (for internal use only).
| [in,out] | me_ | current instance pointer (see SAS_QP_OOA) |
Forward Traceability
| #define QF_EPOOL_TYPE_ QMPool |
| #define QF_EPOOL_INIT_ | ( | p_, | |
| poolSto_, | |||
| poolSize_, | |||
| evtSize_ ) |
Port-specific event pool initialization (for internal use in QF only).
| [in,out] | p_ | event pool pointer |
| [in] | poolSto_ | storage for the pool (pointer to the pool buffer) |
| [in] | poolSize_ | size of the pool storage in [bytes] |
| [in] | evtSize_ | event size of this pool in [bytes] |
Forward Traceability
| #define QF_EPOOL_EVENT_SIZE_ | ( | p_ | ) |
Port-specific event pool block-size() operation (for internal use in QF only).
| [in,out] | p_ | event pool pointer |
Forward Traceability
| #define QF_EPOOL_GET_ | ( | p_, | |
| e_, | |||
| m_, | |||
| qsId_ ) |
Port-specific event pool get() operation (for internal use in QF only).
Macro encapsulating the port-specific operation to get event pool.
| [in,out] | p_ | event pool pointer |
| [out] | e_ | event pointer to be assigned the obtained event |
| [in] | m_ | marign (# free events that must still remain in the pool) |
| [in] | qsId_ | QS ID for the QS local filter |
Forward Traceability
Details
| p_ | event pool object |
| #define QF_EPOOL_PUT_ | ( | p_, | |
| e_, | |||
| qsId_ ) |
Port-specific event pool put() operation (for internal use in QF only).
| [in,out] | p_ | event pool pointer |
| [out] | e_ | event pointer to return to the pool |
| [in] | qsId_ | QS ID for the QS local filter |
Forward Traceability
| #define QF_EPOOL_USE_ | ( | ePool_ | ) |
Port-specific event pool # used events operation (for internal use in QF only).
| [in] | ePool_ | event pool pointer |
Forward Traceability
| #define QF_EPOOL_FREE_ | ( | ePool_ | ) |
Port-specific event pool # free events operation (for internal use in QF only).
| [in] | ePool_ | event pool pointer |
Forward Traceability
| #define QF_EPOOL_MIN_ | ( | ePool_ | ) |
Port-specific event pool minimum # events since initialization (for internal use in QF only).
| [in] | ePool_ | event pool pointer |
Forward Traceability