|
QP/C
|
00001 /***************************************************************************** 00002 * Product: QK/C platform-independent public interface 00003 * Last Updated for Version: 4.4.00 00004 * Date of the Last Update: Jan 17, 2012 00005 * 00006 * Q u a n t u m L e a P s 00007 * --------------------------- 00008 * innovating embedded systems 00009 * 00010 * Copyright (C) 2002-2012 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 00027 *****************************************************************************/ 00028 #ifndef qk_h 00029 #define qk_h 00030 00040 #include "qequeue.h" /* The QK kernel uses the native QF event queue */ 00041 #include "qmpool.h" /* The QK kernel uses the native QF memory pool */ 00042 #include "qpset.h" /* The QK kernel uses the native QF priority set */ 00043 00044 /****************************************************************************/ 00045 /* QF configuration for QK */ 00046 00055 #define QF_EQUEUE_TYPE QEQueue 00056 00057 #if defined(QK_TLS) || defined(QK_EXT_SAVE) 00058 00070 #define QF_OS_OBJECT_TYPE uint8_t 00071 00080 #define QF_THREAD_TYPE void * 00081 #endif /* QK_TLS || QK_EXT_SAVE */ 00082 00083 #if (QF_MAX_ACTIVE <= 8) 00084 extern QPSet8 QK_readySet_; 00085 #else 00086 extern QPSet64 QK_readySet_; 00087 #endif 00088 00089 /* QK active object queue implementation ...................................*/ 00090 00100 #define QACTIVE_EQUEUE_WAIT_(me_) \ 00101 Q_ASSERT((me_)->eQueue.frontEvt != (QEvent *)0) 00102 00103 #if (QF_MAX_ACTIVE <= 8) 00104 #define QACTIVE_EQUEUE_SIGNAL_(me_) do { \ 00105 QPSet8_insert(&QK_readySet_, (me_)->prio); \ 00106 if (QK_intNest_ == (uint8_t)0) { \ 00107 uint8_t p = QK_schedPrio_(); \ 00108 if (p != (uint8_t)0) { \ 00109 QK_sched_(p); \ 00110 } \ 00111 } \ 00112 } while (0) 00113 00114 #define QACTIVE_EQUEUE_ONEMPTY_(me_) \ 00115 QPSet8_remove(&QK_readySet_, (me_)->prio) 00116 #else 00117 00131 #define QACTIVE_EQUEUE_SIGNAL_(me_) do { \ 00132 QPSet64_insert(&QK_readySet_, (me_)->prio); \ 00133 if (QK_intNest_ == (uint8_t)0) { \ 00134 uint8_t p = QK_schedPrio_(); \ 00135 if (p != (uint8_t)0) { \ 00136 QK_sched_(p); \ 00137 } \ 00138 } \ 00139 } while (0) 00140 00154 #define QACTIVE_EQUEUE_ONEMPTY_(me_) \ 00155 QPSet64_remove(&QK_readySet_, (me_)->prio) 00156 #endif 00157 00158 00159 /* QK event pool operations ................................................*/ 00160 00168 #define QF_EPOOL_TYPE_ QMPool 00169 00176 #define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \ 00177 QMPool_init(&(p_), (poolSto_), (poolSize_), (QMPoolSize)(evtSize_)) 00178 00186 #define QF_EPOOL_EVENT_SIZE_(p_) ((QEventSize)(p_).blockSize) 00187 00195 #define QF_EPOOL_GET_(p_, e_) ((e_) = (QEvent *)QMPool_get(&(p_))) 00196 00204 #define QF_EPOOL_PUT_(p_, e_) (QMPool_put(&(p_), (e_))) 00205 00206 /****************************************************************************/ 00213 void QK_sched_(uint8_t p); 00214 00221 void QK_schedExt_(uint8_t p); 00222 00228 uint8_t QK_schedPrio_(void); 00229 00230 /* public-scope objects */ 00231 extern uint8_t QK_currPrio_; 00232 extern uint8_t QK_intNest_; 00234 /****************************************************************************/ 00240 void QK_init(void); 00241 00253 void QK_onIdle(void); 00254 00263 char_t const Q_ROM * Q_ROM_VAR QK_getVersion(void); 00264 00265 #ifndef QK_NO_MUTEX 00266 00273 typedef uint8_t QMutex; 00274 00285 QMutex QK_mutexLock(uint8_t prioCeiling); 00286 00295 void QK_mutexUnlock(QMutex mutex); 00296 00297 #endif /* QK_MUTEX */ 00298 00299 #endif /* qk_h */ 00300
1.7.6.1