QK/C platform-independent public interface. More...
#include "qequeue.h"#include "qmpool.h"#include "qpset.h"#include "qs_port.h"Go to the source code of this file.
Defines | |
| #define | QF_EQUEUE_TYPE QEQueue |
| This macro defines the type of the event queue used for the active objects. | |
| #define | QF_OS_OBJECT_TYPE uint8_t |
| This macro defines the type of the OS-Object used for blocking the native QF event queue when the queue is empty. | |
| #define | QF_THREAD_TYPE void * |
| This macro defines the type of the thread handle used for the active objects. | |
| #define | QACTIVE_EQUEUE_WAIT_(me_) Q_ASSERT((me_)->eQueue.frontEvt != (QEvent *)0) |
| Platform-dependent macro defining how QF should block the calling task when the QF native queue is empty. | |
| #define | QACTIVE_EQUEUE_SIGNAL_(me_) |
| Platform-dependent macro defining how QF should signal the active object task that an event has just arrived. | |
| #define | QACTIVE_EQUEUE_ONEMPTY_(me_) QPSet64_remove(&QK_readySet_, (me_)->prio) |
| Platform-dependent macro defining the action QF should take when the native QF event queue becomes empty. | |
| #define | QF_EPOOL_TYPE_ QMPool |
| This macro defines the type of the event pool used in this QF port. | |
| #define | QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) QMPool_init(&(p_), poolSto_, poolSize_, evtSize_) |
| Platform-dependent macro defining the event pool initialization. | |
| #define | QF_EPOOL_EVENT_SIZE_(p_) ((p_).blockSize) |
| Platform-dependent macro defining how QF should obtain the event pool block-size. | |
| #define | QF_EPOOL_GET_(p_, e_) ((e_) = (QEvent *)QMPool_get(&(p_))) |
| Platform-dependent macro defining how QF should obtain an event e_ from the event pool p_. | |
| #define | QF_EPOOL_PUT_(p_, e_) (QMPool_put(&(p_), (e_))) |
| Platform-dependent macro defining how QF should return an event e_ to the event pool p_. | |
| #define | QK_SCHEDULE_() QK_schedule_(intLockKey_) |
| This is an internal macro for invoking QK scheduler with interrupts locked. | |
Typedefs | |
| typedef uint8_t | QMutex |
| QK Mutex type. | |
Functions | |
| void | QK_init (void) |
| QK initialization. | |
| void | QK_onIdle (void) |
| QK idle callback (customized in BSPs for QK). | |
| char const Q_ROM *Q_ROM_VAR | QK_getVersion (void) |
| get the current QK version number string | |
| char const Q_ROM *Q_ROM_VAR | QK_getPortVersion (void) |
| Returns the QK-port version. | |
| QMutex | QK_mutexLock (uint8_t prioCeiling) |
| QK priority-ceiling mutex lock. | |
| void | QK_mutexUnlock (QMutex mutex) |
| QK priority-ceiling mutex unlock. | |
| void | QK_schedule_ (QF_INT_KEY_TYPE intLockKey) |
| The QK scheduler. | |
| void | QK_scheduleExt_ (QF_INT_KEY_TYPE intLockKey) |
| The QK extended scheduler for interrupt context. | |
Variables | |
| QPSet64 volatile | QK_readySet_ |
| uint8_t volatile | QK_currPrio_ |
| uint8_t volatile | QK_intNest_ |
QK/C platform-independent public interface.
This header file must be included directly or indirectly in all modules (*.c files) that use QK/C.
Definition in file qk.h.
| #define QACTIVE_EQUEUE_ONEMPTY_ | ( | me_ | ) | QPSet64_remove(&QK_readySet_, (me_)->prio) |
Platform-dependent macro defining the action QF should take when the native QF event queue becomes empty.
The macro is necessary only when the native QF event queue is used. The signaling of task involves unblocking the task if it is blocked.
Definition at line 152 of file qk.h.
Referenced by QActive_get_().
| #define QACTIVE_EQUEUE_SIGNAL_ | ( | me_ | ) |
QPSet64_insert(&QK_readySet_, (me_)->prio); \ if (QK_intNest_ == (uint8_t)0) { \ QK_SCHEDULE_(); \ } \ else ((void)0)
Platform-dependent macro defining how QF should signal the active object task that an event has just arrived.
The macro is necessary only when the native QF event queue is used. The signaling of task involves unblocking the task if it is blocked.
Definition at line 132 of file qk.h.
Referenced by QActive_postFIFO(), and QActive_postLIFO().
| #define QACTIVE_EQUEUE_WAIT_ | ( | me_ | ) | Q_ASSERT((me_)->eQueue.frontEvt != (QEvent *)0) |
Platform-dependent macro defining how QF should block the calling task when the QF native queue is empty.
Definition at line 104 of file qk.h.
Referenced by QActive_get_().
| #define QF_EPOOL_EVENT_SIZE_ | ( | p_ | ) | ((p_).blockSize) |
Platform-dependent macro defining how QF should obtain the event pool block-size.
Definition at line 184 of file qk.h.
Referenced by QF_new_(), and QF_poolInit().
| #define QF_EPOOL_GET_ | ( | p_, | |||
| e_ | ) | ((e_) = (QEvent *)QMPool_get(&(p_))) |
Platform-dependent macro defining how QF should obtain an event e_ from the event pool p_.
Definition at line 193 of file qk.h.
Referenced by QF_new_().
| #define QF_EPOOL_INIT_ | ( | p_, | |||
| poolSto_, | |||||
| poolSize_, | |||||
| evtSize_ | ) | QMPool_init(&(p_), poolSto_, poolSize_, evtSize_) |
Platform-dependent macro defining the event pool initialization.
Definition at line 174 of file qk.h.
Referenced by QF_poolInit().
| #define QF_EPOOL_PUT_ | ( | p_, | |||
| e_ | ) | (QMPool_put(&(p_), (e_))) |
Platform-dependent macro defining how QF should return an event e_ to the event pool p_.
Definition at line 202 of file qk.h.
Referenced by QF_gc().
| #define QF_EPOOL_TYPE_ QMPool |
This macro defines the type of the event pool used in this QF port.
| #define QF_EQUEUE_TYPE QEQueue |
This macro defines the type of the event queue used for the active objects.
| #define QF_OS_OBJECT_TYPE uint8_t |
This macro defines the type of the OS-Object used for blocking the native QF event queue when the queue is empty.
In QK, the OS object is used to hold the per-thread flags, which might be used, for example, to rembember the thread attributes (e.g., if the thread uses a floating point co-processor). The OS object value is set on per-thread basis in QActive_start(). Later, the extended context switch macros (QK_EXT_SAVE() and QK_EXT_RESTORE()) might use the per-thread flags to determine what kind of extended context switch this particular thread needs (e.g., the thread might not be using the coprocessor or might be using a different one).
| #define QF_THREAD_TYPE void * |
This macro defines the type of the thread handle used for the active objects.
The thread type in QK is the pointer to the thread-local storage (TLS). This thread-local storage can be set on per-thread basis in QActive_start(). Later, the QK scheduler uses this pointer for extended context switch and passes the pointer to the macro QK_TLS.
| #define QK_SCHEDULE_ | ( | ) | QK_schedule_(intLockKey_) |
This is an internal macro for invoking QK scheduler with interrupts locked.
The purpose of this macro is to enable writing the same code for the case when interrupt key is defined and when it is not. If the macro QF_INT_KEY_TYPE is defined, this internal macro invokes QK_schedule_() passing the key variable as the parameter. Otherwise QK_schedule_() is invoked without parameters.
Definition at line 331 of file qk.h.
Referenced by QF_run(), and QK_mutexUnlock().
QK Mutex type.
QMutex represents the priority-ceiling mutex available in QK.
| char const Q_ROM* Q_ROM_VAR QK_getPortVersion | ( | void | ) |
Returns the QK-port version.
This function returns constant version string in the format x.y.zz, where x (one digit) is the major version, y (one digit) is the minor version, and zz (two digits) is the maintenance release version. An example of the QK-port version string is "1.1.03".
| char const Q_ROM* Q_ROM_VAR QK_getVersion | ( | void | ) |
get the current QK version number string
Definition at line 54 of file qk.c.
References QP_VERSION.
| void QK_init | ( | void | ) |
QK priority-ceiling mutex lock.
Lock the QK scheduler up to the priority level prioCeiling.
QMutex mux; . . . mux = QK_mutexLock(PRIO_CEILING); /* access the shared resource */ QK_mutexUnlock(mux); . . .
Definition at line 47 of file qk_mutex.c.
References QK_ceilingPrio_, QK_INT_LOCK_, QK_INT_LOCK_KEY_, QK_INT_UNLOCK_, QS_BEGIN_NOLOCK_, QS_END_NOLOCK_, QS_QK_MUTEX_LOCK, QS_TIME_, and QS_U8_.
| void QK_mutexUnlock | ( | QMutex | mutex | ) |
QK priority-ceiling mutex unlock.
QMutex mux; . . . mux = QK_mutexLock(PRIO_CEILING); /* access the shared resource */ QK_mutexUnlock(mux); . . .
Definition at line 66 of file qk_mutex.c.
References QK_ceilingPrio_, QK_INT_LOCK_, QK_INT_LOCK_KEY_, QK_INT_UNLOCK_, QK_SCHEDULE_, QS_BEGIN_NOLOCK_, QS_END_NOLOCK_, QS_QK_MUTEX_UNLOCK, QS_TIME_, and QS_U8_.
| void QK_onIdle | ( | void | ) |
QK idle callback (customized in BSPs for QK).
QK_onIdle() is called continously by the QK idle loop. This callback gives the application an opportunity to enter a power-saving CPU mode, or perform some other idle processing.
Referenced by QF_run().
| void QK_schedule_ | ( | QF_INT_KEY_TYPE | intLockKey | ) |
The QK scheduler.
The signature of QK_schedule_() depends on the policy of locking and unlocking interrupts. When the interrupt lock key is not used (QF_INT_KEY_TYPE undefined), the signature is as follows:
void QK_schedule_(void);
However, when the interrupt key lock is used (QF_INT_KEY_TYPE defined), the signature is different:
void QK_schedule_(QF_INT_KEY_TYPE intLockKey);
For the internal use, these differences are hidden by the macro QK_SCHEDULE_().
Definition at line 44 of file qk_sched.c.
References Q_REQUIRE, QActive_get_(), QF_active_, QF_gc(), QK_ceilingPrio_, QK_currPrio_, QK_INT_LOCK_, QK_INT_UNLOCK_, QK_intNest_, QK_readySet_, QK_TLS, QPSet64_findMax, QPSet8_findMax, QS_aoObj_, QS_BEGIN_NOLOCK_, QS_END_NOLOCK_, QS_QK_SCHEDULE, QS_TIME_, QS_U8_, and QActive::super.
| void QK_scheduleExt_ | ( | QF_INT_KEY_TYPE | intLockKey | ) |
The QK extended scheduler for interrupt context.
The signature of QK_scheduleExt_() depends on the policy of locking and unlocking interrupts. When the interrupt lock key is not used (QF_INT_KEY_TYPE undefined), the signature is as follows:
void QK_scheduleExt_(void);
However, when the interrupt key lock is used (QF_INT_KEY_TYPE defined), the signature is different:
void QK_scheduleExt_(QF_INT_KEY_TYPE intLockKey);
Definition at line 44 of file qk_ext.c.
References Q_REQUIRE, QActive_get_(), QF_active_, QF_gc(), QK_ceilingPrio_, QK_currPrio_, QK_EXT_RESTORE, QK_EXT_SAVE, QK_INT_LOCK_, QK_INT_UNLOCK_, QK_intNest_, QK_readySet_, QK_TLS, QPSet64_findMax, QPSet8_findMax, QS_aoObj_, QS_BEGIN_NOLOCK_, QS_END_NOLOCK_, QS_QK_SCHEDULE, QS_TIME_, QS_U8_, and QActive::super.
| uint8_t volatile QK_currPrio_ |
current task/interrupt priority
Definition at line 48 of file qk.c.
Referenced by QK_schedule_(), and QK_scheduleExt_().
| uint8_t volatile QK_intNest_ |
interrupt nesting level
Definition at line 49 of file qk.c.
Referenced by QK_schedule_(), and QK_scheduleExt_().
| QPSet64 volatile QK_readySet_ |
QK ready-set
Definition at line 45 of file qk.c.
Referenced by QK_schedule_(), and QK_scheduleExt_().
1.6.2