qk.h

Go to the documentation of this file.
00001 
00002 // Product: QK/C++ platform-independent public interface
00003 // Last Updated for Version: 4.0.00
00004 // Date of the Last Update:  Apr 06, 2008
00005 //
00006 //                    Q u a n t u m     L e a P s
00007 //                    ---------------------------
00008 //                    innovating embedded systems
00009 //
00010 // Copyright (C) 2002-2008 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 
00042 
00044 // QF configuration for QK
00045 
00053 #define QF_EQUEUE_TYPE             QEQueue
00054 
00055 #if defined(QK_TLS) || defined(QK_EXT_SAVE)
00067     #define QF_OS_OBJECT_TYPE      uint8_t
00068 
00076     #define QF_THREAD_TYPE         void *
00077 #endif                                             /* QK_TLS || QK_EXT_SAVE */
00078 
00079 #if (QF_MAX_ACTIVE <= 8)
00080     extern QPSet8  volatile QK_readySet_;                 
00081 #else
00082     extern QPSet64 volatile QK_readySet_;                 
00083 #endif
00084 
00085 extern uint8_t volatile QK_currPrio_;     
00086 extern uint8_t volatile QK_intNest_;              
00087 
00088 // QK active object queue implementation .....................................
00089 
00096 // need to define the macro appropriately for the underlying kernel/OS you're
00098 #define QACTIVE_EQUEUE_WAIT_(me_) \
00099     Q_ASSERT((me_)->m_eQueue.m_frontEvt != (QEvent *)0)
00100 
00114 #define QACTIVE_EQUEUE_SIGNAL_(me_) \
00115     QK_readySet_.insert((me_)->m_prio); \
00116     if (QK_intNest_ == (uint8_t)0) { \
00117         QK_SCHEDULE_(); \
00118     } else ((void)0)
00119 
00129 #define QACTIVE_EQUEUE_ONEMPTY_(me_) \
00130     QK_readySet_.remove((me_)->m_prio)
00131 
00132 // QK event pool operations ..................................................
00133 
00140 #define QF_EPOOL_TYPE_              QMPool
00141 
00147 #define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \
00148     (p_).init(poolSto_, poolSize_, evtSize_)
00149 
00156 #define QF_EPOOL_EVENT_SIZE_(p_)    ((p_).getBlockSize())
00157 
00164 #define QF_EPOOL_GET_(p_, e_)       ((e_) = (QEvent *)(p_).get())
00165 
00172 #define QF_EPOOL_PUT_(p_, e_)       ((p_).put(e_))
00173 
00180 typedef uint8_t QMutex;
00181 
00188 // \note The QK scheduler, QK priority, QK ready set, etc. belong conceptually
00193 class QK {
00194 public:
00195 
00203     static char const Q_ROM * Q_ROM_VAR getVersion(void);
00204 
00213     static char const Q_ROM * Q_ROM_VAR getPortVersion(void);
00214 
00225     static void onIdle(void);
00226 
00231     // \note This function should be always paired with QK::mutexUnlock().
00236     static QMutex mutexLock(uint8_t prioCeiling);
00237 
00245     static void mutexUnlock(QMutex mutex);
00246 };
00247 
00248 extern "C" {
00249 
00254 void QK_init(void);
00255 
00256 // QK scheduler and extended scheduler
00257 #ifndef QF_INT_KEY_TYPE
00258     void QK_schedule_(void);                                   // QK scheduler
00259     void QK_scheduleExt_(void);                       // QK extended scheduler
00260 
00261     #define QK_SCHEDULE_()    QK_schedule_()
00262 #else
00263 
00280     void QK_schedule_(QF_INT_KEY_TYPE intLockKey);
00281 
00295     void QK_scheduleExt_(QF_INT_KEY_TYPE intLockKey); // QK extended scheduler
00296 
00301     #define QK_SCHEDULE_()    QK_schedule_(intLockKey_)
00302 
00303 #endif
00304 }                                                                // extern "C"
00305 
00307 // QS software tracing integration, only if enabled
00308 #ifdef Q_SPY                                   // QS software tracing enabled?
00309     #ifndef qs_h
00310     #include "qs_port.h"                                    // include QS port
00311     #endif
00312 #else
00313     #ifndef qs_dummy_h
00314     #include "qs_dummy.h"                   // disable the QS software tracing
00315     #endif
00316 #endif                                                                // Q_SPY
00317 
00318 #endif                                                                 // qk_h

Generated on Sat Nov 15 13:53:46 2008 for QP/C++ by  doxygen 1.5.4