QP/C++ 8.1.3
Real-Time Event Framework
Loading...
Searching...
No Matches
qp_port.hpp File Reference

Sample QP/C++ port. More...

#include <cstdint>
#include "qequeue.hpp"
#include "qmpool.hpp"
#include "qp.hpp"
#include "qk.hpp"

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).

Detailed Description

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.hpp.

Macro Definition Documentation

◆ Q_NORETURN

#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.

Note
If 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.

Backward Traceability

  • SSRS_QA_FDM_20: QP/C++ Application shall implement custom error handler such that it does not return.

Forward Traceability

  • SSM_QA_CSOU_21: Mandate: QP/C++ Application must ensure that the Q_onError() Custom Error Handler does not return.

Definition at line 26 of file qp_port.hpp.

◆ QACTIVE_EQUEUE_TYPE

#define QACTIVE_EQUEUE_TYPE   QEQueue

Port-specific ::QActive event queue type.

Forward Traceability

Definition at line 34 of file qp_port.hpp.

◆ QACTIVE_OS_OBJ_TYPE

#define QACTIVE_OS_OBJ_TYPE   void*

Port-specific ::QActive "OS-object" type.

Forward Traceability

Definition at line 41 of file qp_port.hpp.

◆ QACTIVE_THREAD_TYPE

#define QACTIVE_THREAD_TYPE   void const *

Port-specific ::QActive thread type.

Forward Traceability

Definition at line 48 of file qp_port.hpp.

◆ QF_INT_DISABLE

#define QF_INT_DISABLE ( )
Value:
intDisable()

Port-specific interrupt disable.

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 57 of file qp_port.hpp.

◆ QF_INT_ENABLE

#define QF_INT_ENABLE ( )
Value:
intEnable()

Port-specific interrupt enable.

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 65 of file qp_port.hpp.

◆ QF_CRIT_STAT

#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.

Note
This 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.

Forward Traceability

Definition at line 77 of file qp_port.hpp.

◆ QF_CRIT_ENTRY

#define QF_CRIT_ENTRY ( )
Value:
(crit_stat_ = critEntry())

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

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 87 of file qp_port.hpp.

◆ QF_CRIT_EXIT

#define QF_CRIT_EXIT ( )
Value:
critExit(crit_stat_)

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

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 97 of file qp_port.hpp.

◆ QF_CRIT_EXIT_NOP

#define QF_CRIT_EXIT_NOP ( )
Value:
__asm volatile ("isb" ::: "memory")

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

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 107 of file qp_port.hpp.

◆ QF_CRIT_EST

#define QF_CRIT_EST ( )
Value:
(static_cast<void>(critEntry()))

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

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 117 of file qp_port.hpp.

◆ QF_LOG2

#define QF_LOG2 ( bitmask_)
Value:
QF_qlog2(static_cast<std::uint32_t>(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.

Parameters
[in]bitmask_32-bit bitmask
Returns
1-based integer log-base-2 of the provided bitmask. Examples:
Note
This operation is performed frequently in time-critical parts of the code. Some CPUs provide such calculation in hardware (e.g., as a machine intruction). For example, ARMv7 and higher architectures support the related CLZ (count leading zeroes) instruction, with the following relationship: QF_LOG2(bitmask_) == 32U - CLZ(bitmask_).

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 141 of file qp_port.hpp.

◆ QV_CPU_SLEEP

#define QV_CPU_SLEEP ( )
Value:
do { \
__disable_interrupt(); \
QF_INT_ENABLE(); \
__WFI(); \
__enable_interrupt(); \
} while (false)

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

Definition at line 185 of file qp_port.hpp.

◆ QK_ISR_CONTEXT_

#define QK_ISR_CONTEXT_ ( )
Value:
(QK_priv_.intNest != 0U)

Port-specific method to check if the QK kernel executes in the ISR context (used internally in QK only).

Returns
true if the caller executes in the ISR context and false otherwise

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 202 of file qp_port.hpp.

◆ QK_ISR_ENTRY

#define QK_ISR_ENTRY ( )
Value:
do { \
QF_INT_DISABLE(); \
++QK::priv_.intNest; \
QF_QS_ISR_ENTRY(QK::priv_.intNest, QK_currPrio_);\
QF_INT_ENABLE(); \
} while (false)

Port-specific method to inform QK kernel about the ISR entry.

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 210 of file qp_port.hpp.

◆ QK_ISR_EXIT

#define QK_ISR_EXIT ( )
Value:
do { \
QF_INT_DISABLE(); \
--QP::QK::priv_.intNest; \
if (QP::QK::priv_.intNest == 0U) {\
if (QP::QK::sched_() != 0U) { \
QP::QK::activate_(); \
} \
} \
QF_INT_ENABLE(); \
} while (false)
static QK priv_
Definition qk.hpp:59
static std::uint_fast8_t sched_() noexcept
QK scheduler finds the highest-priority AO ready to run.
Definition qk.cpp:124

Port-specific method to inform QK kernel about the ISR exit.

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 224 of file qp_port.hpp.

◆ QXK_ISR_CONTEXT_

#define QXK_ISR_CONTEXT_ ( )
Value:
(QXK_get_IPSR() != 0U)

Port-specific method to check if the QXK kernel executes in the ISR context (used internally in QXK only).

Returns
true if the caller executes in the ISR context and false otherwise

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 244 of file qp_port.hpp.

◆ QXK_CONTEXT_SWITCH_

#define QXK_CONTEXT_SWITCH_ ( )
Value:
(trigPendSV())

Port-specific method to trigger context switch (used internally in QXK only).

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 252 of file qp_port.hpp.

◆ QXK_ISR_ENTRY

#define QXK_ISR_ENTRY ( )
Value:
((void)0)

Port-specific method to inform QXK kernel about the ISR entry.

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 260 of file qp_port.hpp.

◆ QXK_ISR_EXIT

#define QXK_ISR_EXIT ( )
Value:
do { \
QF_INT_DISABLE(); \
if (QP::QXK::sched_() != 0U) { \
*Q_UINT2PTR_CAST(uint32_t, 0xE000ED04U) = (1U << 28U);\
} \
QF_INT_ENABLE(); \
QXK_ARM_ERRATUM_838869(); \
} while (false)
static std::uint_fast8_t sched_() noexcept
QXK scheduler finds the highest-priority thread ready to run.
Definition qxk.cpp:186
#define Q_UINT2PTR_CAST(type_, uint_)
Perform cast from unsigned integer uint_ to pointer of type type_.
Definition qp.hpp:91

Port-specific method to inform QXK kernel about the ISR exit.

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 268 of file qp_port.hpp.

◆ QF_SCHED_STAT_

#define QF_SCHED_STAT_   QSchedStatus lockStat_;

Port-specific type of the scheduler lock status (for internal use in QF only).

Forward Traceability

Definition at line 283 of file qp_port.hpp.

◆ QF_SCHED_LOCK_

#define QF_SCHED_LOCK_ ( ceil_)
Value:
do { \
if (QK_ISR_CONTEXT_()) { \
lockStat_ = 0xFFU; \
} else { \
lockStat_ = QK::schedLock((ceil_)); \
} \
} while (false)
#define QK_ISR_CONTEXT_()
Port-specific method to check if the QK kernel executes in the ISR context (used internally in QK onl...
Definition qp_port.hpp:202

Port-specific method to lock the scheduler (for internal use in QF only).

Parameters
[in]ceil_priority-ceiling up to which the scheduler should be locked

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 292 of file qp_port.hpp.

◆ QF_SCHED_UNLOCK_

#define QF_SCHED_UNLOCK_ ( )
Value:
do { \
if (lockStat_ != 0xFFU) { \
QP::QK::schedUnlock(lockStat_); \
} \
} while (false)

Port-specific method to unlock the scheduler (for internal use in QF only).

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 306 of file qp_port.hpp.

◆ QACTIVE_EQUEUE_WAIT_

#define QACTIVE_EQUEUE_WAIT_ ( me_)
Value:
(static_cast<void>(0))

Port-specific method to wait on an empty Active Object event queue (for internal use only).

Parameters
[in,out]me_current instance pointer

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 321 of file qp_port.hpp.

◆ QACTIVE_EQUEUE_SIGNAL_

#define QACTIVE_EQUEUE_SIGNAL_ ( me_)
Value:
do { \
QP::QK::priv_.readySet.insert( \
static_cast<std::uint_fast8_t>((me_)->m_prio)); \
if (!QP::QK_ISR_CONTEXT_()) { \
if (QP::QK::sched_() != 0U) { \
QP::QK::activate_(); \
} \
} \
} while (false)

Port-specific method to signal Active Object event queue (for internal use only).

Parameters
[in,out]me_current instance pointer

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 330 of file qp_port.hpp.

◆ QXTHREAD_EQUEUE_SIGNAL_

#define QXTHREAD_EQUEUE_SIGNAL_ ( me_)
Value:
do { \
if ((me_)->m_temp.obj == QXK::qmstate_cast_(&(me_)->m_eQueue)) { \
static_cast<void>(static_cast<QP::QXThread *>(me_)->teDisarm_()); \
QXK_priv_.readySet.insert( \
static_cast<std::uint_fast8_t>((me_)->m_prio)); \
QXK_priv_.readySet.update_(&QXK_priv_.readySet_dis); \
if (!QXK_ISR_CONTEXT_()) { \
static_cast<void>(QXK::sched_()); \
} \
} \
} while (false)
void insert(std::uint_fast8_t const n) noexcept
Insert element n into the priority-set (n = 1..QF_MAX_ACTIVE).
Definition qf_qact.cpp:245
QPSet readySet
Set of active-objects/threads that are ready to run in the QXK kernel.
Definition qxk.hpp:51
eXtended (blocking) thread of the QXK preemptive kernel
Definition qxk.hpp:80
#define QXK_ISR_CONTEXT_()
Port-specific method to check if the QXK kernel executes in the ISR context (used internally in QXK o...
Definition qp_port.hpp:244

Port-specific method to signal eXtended thread event queue (for internal use only).

Parameters
[in,out]me_current instance pointer

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 347 of file qp_port.hpp.

◆ QF_EPOOL_TYPE_

#define QF_EPOOL_TYPE_   QMPool

Port-specific type of the event pool (for internal use in QF only).

Forward Traceability

Definition at line 365 of file qp_port.hpp.

◆ QF_EPOOL_INIT_

#define QF_EPOOL_INIT_ ( p_,
poolSto_,
poolSize_,
evtSize_ )
Value:
(p_).init((poolSto_), (poolSize_), (evtSize_))

Port-specific event pool initialization (for internal use in QF only).

Parameters
[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

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 377 of file qp_port.hpp.

◆ QF_EPOOL_EVENT_SIZE_

#define QF_EPOOL_EVENT_SIZE_ ( p_)
Value:
((p_).getBlockSize())

Port-specific event pool block-size() operation (for internal use in QF only).

Parameters
[in,out]p_event pool pointer

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 387 of file qp_port.hpp.

◆ QF_EPOOL_GET_

#define QF_EPOOL_GET_ ( p_,
e_,
m_,
qsId_ )
Value:
((e_) = static_cast<QEvt *>((p_).get((m_), (qsId_))))

Port-specific event pool get() operation (for internal use in QF only).

Parameters
[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

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 399 of file qp_port.hpp.

◆ QF_EPOOL_PUT_

#define QF_EPOOL_PUT_ ( p_,
e_,
qsId_ )
Value:
((p_).put((e_), (qsId_)))

Port-specific event pool put() operation (for internal use in QF only).

Parameters
[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

  • DVR_QP_MP2_R8_2_3: Rule 8.2.3(Required): A cast shall not remove any 'const' or 'volatile' qualification from the type pointer to by a pointer or by reference
  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 412 of file qp_port.hpp.

◆ QF_EPOOL_USE_

#define QF_EPOOL_USE_ ( ePool_)
Value:
((ePool_)->getUse())

Port-specific event pool # used events operation (for internal use in QF only).

Parameters
[in]ePool_event pool pointer
Returns
# used events in the pool at this moment (allocated and not returned yet)

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 422 of file qp_port.hpp.

◆ QF_EPOOL_FREE_

#define QF_EPOOL_FREE_ ( ePool_)
Value:
((ePool_)->getFree())

Port-specific event pool # free events operation (for internal use in QF only).

Parameters
[in]ePool_event pool pointer
Returns
# free events in the pool at this moment (available to allocate)

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 432 of file qp_port.hpp.

◆ QF_EPOOL_MIN_

#define QF_EPOOL_MIN_ ( ePool_)
Value:
((ePool_)->getMin())

Port-specific event pool minimum # events since initialization (for internal use in QF only).

Parameters
[in]ePool_event pool pointer
Returns
minimal # free events in the pool since initialization

Forward Traceability

  • DVR_QP_MP2_R19_0_2: Rule 19.0.2(Required): Function-like macros shall not be defined

Definition at line 442 of file qp_port.hpp.