QP/C  6.3.7
qf_pkg.h File Reference

Internal (package scope) QF/C interface. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  QFreeBlock
 structure representing a free block in the Native QF Memory Pool More...
 

Macros

#define QF_CRIT_STAT_
 This is an internal macro for defining the critical section status type. More...
 
#define QF_CRIT_ENTRY_()   QF_CRIT_ENTRY(dummy)
 This is an internal macro for entering a critical section. More...
 
#define QF_CRIT_EXIT_()   QF_CRIT_EXIT(dummy)
 This is an internal macro for exiting a critical section. More...
 
#define Q_ASSERT_CRIT_(id_, test_)
 
#define Q_REQUIRE_CRIT_(id_, test_)   Q_ASSERT_CRIT_((id_), (test_))
 
#define Q_ERROR_CRIT_(id_)
 
#define QF_EVT_REF_CTR_INC_(e_)   (++((QEvt *)(e_))->refCtr_)
 increment the refCtr of an event e_ casting const away More...
 
#define QF_EVT_REF_CTR_DEC_(e_)   (--((QEvt *)(e_))->refCtr_)
 decrement the refCtr of an event e_ casting const away More...
 
#define QF_PTR_AT_(base_, i_)   ((base_)[(i_)])
 access element at index i_ from the base pointer base_ More...
 
#define QF_PTR_RANGE_(x_, min_, max_)   (((min_) <= (x_)) && ((x_) <= (max_)))
 

Enumerations

enum  { TE_IS_LINKED = (uint8_t)(1U << 7), TE_WAS_DISARMED = (uint8_t)(1U << 6), TE_TICK_RATE = (uint8_t)0x0F }
 

Functions

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. More...
 
QEvt const * QActive_get_ (QActive *const me)
 Get an event from the event queue of an active object. More...
 
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. More...
 
void QActive_postLIFO_ (QActive *const me, QEvt const *const e)
 Implementation of the active object post LIFO operation. More...
 

Variables

QTimeEvt QF_timeEvtHead_ [QF_MAX_TICK_RATE]
 heads of linked lists of time events, one for every clock tick rate More...
 
QF_EPOOL_TYPE_ QF_pool_ [QF_MAX_EPOOL]
 allocate event pools More...
 
uint_fast8_t QF_maxPool_
 

of initialized event pools

More...
 
QSubscrListQF_subscrList_
 the subscriber list array More...
 
enum_t QF_maxPubSignal_
 the maximum published signal More...
 

Detailed Description

Internal (package scope) QF/C interface.

Definition in file qf_pkg.h.


Data Structure Documentation

◆ QFreeBlock

struct QFreeBlock

structure representing a free block in the Native QF Memory Pool

Definition at line 162 of file qf_pkg.h.

Collaboration diagram for QFreeBlock:
Collaboration graph
Data Fields
struct QFreeBlock *volatile next

Macro Definition Documentation

◆ QF_CRIT_STAT_

#define QF_CRIT_STAT_

This is an internal macro for defining the critical section status type.

Description
The purpose of this macro is to enable writing the same code for the case when critical section status type is defined and when it is not. If the macro QF_CRIT_STAT_TYPE is defined, this internal macro provides the definition of the critical section status variable. Otherwise this macro is empty.
See also
QF_CRIT_STAT_TYPE

Definition at line 57 of file qf_pkg.h.

◆ QF_CRIT_ENTRY_

#define QF_CRIT_ENTRY_ ( )    QF_CRIT_ENTRY(dummy)

This is an internal macro for entering a critical section.

Description
The purpose of this macro is to enable writing the same code for the case when critical section status type is defined and when it is not. If the macro QF_CRIT_STAT_TYPE is defined, this internal macro invokes QF_CRIT_ENTRY passing the key variable as the parameter. Otherwise QF_CRIT_ENTRY is invoked with a dummy parameter.
See also
QF_CRIT_ENTRY

Definition at line 69 of file qf_pkg.h.

◆ QF_CRIT_EXIT_

#define QF_CRIT_EXIT_ ( )    QF_CRIT_EXIT(dummy)

This is an internal macro for exiting a critical section.

Description
The purpose of this macro is to enable writing the same code for the case when critical section status type is defined and when it is not. If the macro QF_CRIT_STAT_TYPE is defined, this internal macro invokes QF_CRIT_EXIT passing the key variable as the parameter. Otherwise QF_CRIT_EXIT is invoked with a dummy parameter.
See also
QF_CRIT_EXIT

Definition at line 81 of file qf_pkg.h.

◆ Q_ASSERT_CRIT_

#define Q_ASSERT_CRIT_ (   id_,
  test_ 
)
Value:
do {\
if ((test_)) {} else { \
QF_CRIT_EXIT_(); \
Q_onAssert(&Q_this_module_[0], (int_t)(id_)); \
} \
} while (0)
int int_t
typedef for assertions-ids and line numbers in assertions.
Definition: qassert.h:92

Definition at line 99 of file qf_pkg.h.

◆ Q_REQUIRE_CRIT_

#define Q_REQUIRE_CRIT_ (   id_,
  test_ 
)    Q_ASSERT_CRIT_((id_), (test_))

Definition at line 106 of file qf_pkg.h.

◆ Q_ERROR_CRIT_

#define Q_ERROR_CRIT_ (   id_)
Value:
do { \
QF_CRIT_EXIT_(); \
Q_onAssert(&Q_this_module_[0], (int_t)(id_)); \
} while (0)
int int_t
typedef for assertions-ids and line numbers in assertions.
Definition: qassert.h:92

Definition at line 108 of file qf_pkg.h.

◆ QF_EVT_REF_CTR_INC_

#define QF_EVT_REF_CTR_INC_ (   e_)    (++((QEvt *)(e_))->refCtr_)

increment the refCtr of an event e_ casting const away

Definition at line 169 of file qf_pkg.h.

◆ QF_EVT_REF_CTR_DEC_

#define QF_EVT_REF_CTR_DEC_ (   e_)    (--((QEvt *)(e_))->refCtr_)

decrement the refCtr of an event e_ casting const away

Definition at line 172 of file qf_pkg.h.

◆ QF_PTR_AT_

#define QF_PTR_AT_ (   base_,
  i_ 
)    ((base_)[(i_)])

access element at index i_ from the base pointer base_

Definition at line 175 of file qf_pkg.h.

◆ QF_PTR_RANGE_

#define QF_PTR_RANGE_ (   x_,
  min_,
  max_ 
)    (((min_) <= (x_)) && ((x_) <= (max_)))
Description
This macro is specifically and exclusively used for checking the range of a block pointer returned to the pool. Such a check must rely on the pointer arithmetic not compliant with the MISRA-C 2004 rules 17.2(req) and 17.3(req). Defining a specific macro for this purpose allows to selectively disable the warnings for this particular case.

Definition at line 185 of file qf_pkg.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TE_IS_LINKED 
TE_WAS_DISARMED 
TE_TICK_RATE 

Definition at line 150 of file qf_pkg.h.

Function Documentation

◆ QActive_start_()

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.

Description
Starts execution of the AO and registers the AO with the framework. Also takes the top-most initial transition in the AO's state machine. This initial transition is taken in the callee's thread of execution.
Parameters
[in,out]mepointer (see Object Orientation)
[in]priopriority at which to start the active object
[in]qStopointer to the storage for the ring buffer of the event queue (used only with the built-in QEQueue)
[in]qLenlength of the event queue [events]
[in]stkStopointer to the stack storage (must be NULL in QV)
[in]stkSizestack size [bytes]
[in]iepointer to the initial event (might be NULL).
Note
This function should be called via the macro QACTIVE_START().
Usage
The following example shows starting an AO when a per-task stack is needed:
int main() {
static Philo l_philo[N]; /* N Philo active objects */
static QEvt const *l_philQueueSto[N][N]; /* storage for event queues */
static int l_philoStk[N][256]; /* stacks for the Philo active objects */
. . .
for (n = 0; n < N; ++n) {
TableEvt ie; /* initialization event for the Philo SM */
ie.philNum = n;
Philo_ctor(&l_philo[n]);
QACTIVE_START((QActive *)&l_philo[n], /* Philo pointer */
(uint_fast8_t)(n*10 + 1), /* priority */
l_philoQueueSto[n], Q_DIM(l_philoQueueSto[n]), /* queue */
l_philoStk[n], sizeof(l_philoStk[n]), /* per AO stack */
&ie.super); /* initialization event */
}
. . .
}
Precondition
The priority must be in range and the stack storage must not be provided, because the QV kernel does not need per-AO stacks.

Definition at line 82 of file qutest.c.

◆ QActive_get_()

QEvt const* QActive_get_ ( QActive *const  me)

Get an event from the event queue of an active object.

Description
The behavior of this function depends on the kernel/OS used in the QF port. For built-in kernels (QV or QK) the function can be called only when the queue is not empty, so it doesn't block. For a blocking kernel/OS the function can block and wait for delivery of an event.
Parameters
[in,out]mepointer (see Object Orientation)
Returns
a pointer to the received event. The returned pointer is guaranteed to be valid (can't be NULL).
Note
This function is used internally by a QF port to extract events from the event queue of an active object. This function depends on the event queue implementation and is sometimes customized in the QF port (file qf_port.h). Depending on the definition of the macro QACTIVE_EQUEUE_WAIT_(), the function might block the calling thread when no events are available.

Definition at line 329 of file qf_actq.c.

◆ QActive_post_()

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.

Description
Direct event posting is the simplest asynchronous communication method available in QF.
Parameters
[in,out]mepointer (see Object Orientation)
[in]epointer to the event to be posted
[in]marginnumber of required free slots in the queue after posting the event. The special value QF_NO_MARGIN means that this function will assert if posting fails.
Returns
'true' (success) if the posting succeeded (with the provided margin) and 'false' (failure) when the posting fails.
Attention
This function should be called only via the macro QACTIVE_POST() or QACTIVE_POST_X().
Note
The QF_NO_MARGIN value of the margin parameter is special and denotes situation when the post() operation is assumed to succeed (event delivery guarantee). An assertion fires, when the event cannot be delivered in this case.
Usage
extern QActive *AO_Table;
QState Philoso_hungry(Philo * const me, QEvt const * const e) {
QState status;
switch (e->sig) {
case Q_ENTRY_SIG: {
TableEvt *pe = Q_NEW(TableEvt, HUNGRY_SIG); /* dynamic alloc */
pe->philNum = me->num;
QACTIVE_POST(AO_Table, &pe->super, me); /* direct posting */
status = Q_HANDLED();
break;
}
. . .
default: {
status = Q_SUPER(&QHsm_top);
break;
}
}
return status;
}
See also
QActive_post_(), QActive_postLIFO()
Precondition
event pointer must be valid

Definition at line 93 of file qf_actq.c.

◆ QActive_postLIFO_()

void QActive_postLIFO_ ( QActive *const  me,
QEvt const *const  e 
)

Implementation of the active object post LIFO operation.

Description
posts an event to the event queue of the active object me using the Last-In-First-Out (LIFO) policy.
Note
The LIFO policy should be used only for self-posting and with caution, because it alters order of events in the queue.
Parameters
[in]mepointer (see Object Orientation)
[ine pointer to the event to post to the queue
Attention
This function should be called only via the macro QACTIVE_POST_LIFO().
See also
QActive_post_(), QACTIVE_POST(), QACTIVE_POST_X()

Definition at line 237 of file qf_actq.c.

Variable Documentation

◆ QF_timeEvtHead_

QTimeEvt QF_timeEvtHead_[QF_MAX_TICK_RATE]

heads of linked lists of time events, one for every clock tick rate

Definition at line 53 of file qf_time.c.

◆ QF_pool_

allocate event pools

Definition at line 54 of file qf_dyn.c.

◆ QF_maxPool_

uint_fast8_t QF_maxPool_

of initialized event pools

Definition at line 55 of file qf_dyn.c.

◆ QF_subscrList_

QSubscrList* QF_subscrList_

the subscriber list array

Definition at line 54 of file qf_ps.c.

◆ QF_maxPubSignal_

enum_t QF_maxPubSignal_

the maximum published signal

Definition at line 55 of file qf_ps.c.