|
QP/C++
|
00001 00002 // Product: QK/C++ platform-independent public interface 00003 // Last Updated for Version: 4.3.00 00004 // Date of the Last Update: Nov 01, 2011 00005 // 00006 // Q u a n t u m L e a P s 00007 // --------------------------- 00008 // innovating embedded systems 00009 // 00010 // Copyright (C) 2002-2011 Quantum Leaps, LLC. All rights reserved. 00011 // 00012 // This software may be distributed and modified under the terms of the GNU 00013 // General Public License version 2 (GPL) as published by the Free Software 00014 // Foundation and appearing in the file GPL.TXT included in the packaging of 00015 // this file. Please note that GPL Section 2[b] requires that all works based 00016 // on this software must also be made publicly available under the terms of 00017 // the GPL ("Copyleft"). 00018 // 00019 // Alternatively, this software may be distributed and modified under the 00020 // terms of Quantum Leaps commercial licenses, which expressly supersede 00021 // the GPL and are specifically designed for licensees interested in 00022 // retaining the proprietary status of their code. 00023 // 00024 // Contact information: 00025 // Quantum Leaps Web site: http://www.quantum-leaps.com 00026 // e-mail: info@quantum-leaps.com 00028 #ifndef qk_h 00029 #define qk_h 00030 00037 00038 #include "qequeue.h" // The QK kernel uses the native QF event queue 00039 #include "qmpool.h" // The QK kernel uses the native QF memory pool 00040 #include "qpset.h" // The QK kernel uses the native QF priority set 00041 00043 // QF configuration for QK 00044 00052 #define QF_EQUEUE_TYPE QEQueue 00053 00054 #if defined(QK_TLS) || defined(QK_EXT_SAVE) 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 #define QF_OS_OBJECT_TYPE uint8_t 00067 00075 #define QF_THREAD_TYPE void * 00076 #endif /* QK_TLS || QK_EXT_SAVE */ 00077 00078 #if (QF_MAX_ACTIVE <= 8U) 00079 #ifdef Q_USE_NAMESPACE 00080 extern "C" QP::QPSet8 volatile QK_readySet_; 00081 #else 00082 extern "C" QPSet8 volatile QK_readySet_; 00083 #endif 00084 #else 00085 #ifdef Q_USE_NAMESPACE 00086 extern "C" QP::QPSet64 volatile QK_readySet_; 00087 #else 00088 extern "C" QPSet64 volatile QK_readySet_; 00089 #endif 00090 #endif 00091 00092 extern "C" uint8_t volatile QK_currPrio_; 00093 extern "C" uint8_t volatile QK_intNest_; 00094 00095 // QK active object queue implementation ..................................... 00096 00103 // need to define the macro appropriately for the underlying kernel/OS you're 00105 #define QACTIVE_EQUEUE_WAIT_(me_) \ 00106 Q_ASSERT((me_)->m_eQueue.m_frontEvt != (QEvent *)0) 00107 00121 #define QACTIVE_EQUEUE_SIGNAL_(me_) \ 00122 QK_readySet_.insert((me_)->m_prio); \ 00123 if (QK_intNest_ == (uint8_t)0) { \ 00124 uint8_t p = QK_schedPrio_(); \ 00125 if (p != (uint8_t)0) { \ 00126 QK_sched_(p); \ 00127 } \ 00128 } else ((void)0) 00129 00139 #define QACTIVE_EQUEUE_ONEMPTY_(me_) \ 00140 QK_readySet_.remove((me_)->m_prio) 00141 00142 // QK event pool operations .................................................. 00143 00150 #define QF_EPOOL_TYPE_ QMPool 00151 00157 #define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \ 00158 (p_).init(poolSto_, poolSize_, evtSize_) 00159 00166 #define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize()) 00167 00174 #define QF_EPOOL_GET_(p_, e_) ((e_) = (QEvent *)(p_).get()) 00175 00182 #define QF_EPOOL_PUT_(p_, e_) ((p_).put(e_)) 00183 00185 #ifdef Q_USE_NAMESPACE 00186 namespace QP { 00187 #endif 00188 00189 00190 #ifndef QK_NO_MUTEX 00191 00192 00193 00194 00195 00196 00197 typedef uint8_t QMutex; 00198 #endif // QK_NO_MUTEX 00199 00206 // \note The QK scheduler, QK priority, QK ready set, etc. belong conceptually 00211 class QK { 00212 public: 00213 00219 static char const Q_ROM * Q_ROM_VAR getVersion(void); 00220 00231 static void onIdle(void); 00232 00233 #ifndef QK_NO_MUTEX 00234 00239 // \note This function should be always paired with QK::mutexUnlock(). 00244 static QMutex mutexLock(uint8_t prioCeiling); 00245 00253 static void mutexUnlock(QMutex mutex); 00254 00255 #endif // QK_NO_MUTEX 00256 00257 }; 00258 00259 #ifdef Q_USE_NAMESPACE 00260 } // namespace QP 00261 #endif 00262 00263 00265 extern "C" { 00266 00271 void QK_init(void); 00272 00279 void QK_sched_(uint8_t p); 00280 00287 void QK_schedExt_(uint8_t p); 00288 00293 uint8_t QK_schedPrio_(void); 00294 00295 } // extern "C" 00296 00297 00299 // QS software tracing integration, only if enabled 00300 #ifdef Q_SPY // QS software tracing enabled? 00301 #ifndef qs_h 00302 #include "qs_port.h" // include QS port 00303 #endif 00304 #else 00305 #ifndef qs_dummy_h 00306 #include "qs_dummy.h" // disable the QS software tracing 00307 #endif 00308 #endif // Q_SPY 00309 00310 #endif // qk_h
1.7.5.1