00001 00002 // Product: QK/C++ 00003 // Last Updated for Version: 4.0.02 00004 // Date of the Last Update: Nov 14, 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 #include "qk_pkg.h" 00029 #include "qassert.h" 00030 00031 Q_DEFINE_THIS_MODULE(qk) 00032 00033 00034 00035 00036 00037 00038 00039 // Public-scope objects ------------------------------------------------------ 00040 #if (QF_MAX_ACTIVE <= 8) 00041 QPSet8 volatile QK_readySet_; // ready set of QK 00042 #else 00043 QPSet64 volatile QK_readySet_; // ready set of QK 00044 #endif 00045 // start with the QK scheduler locked 00046 uint8_t volatile QK_currPrio_ = (uint8_t)(QF_MAX_ACTIVE + 1); 00047 uint8_t volatile QK_intNest_; // start with nesting level of 0 00048 00049 00050 //............................................................................ 00051 //lint -e970 -e971 ignore MISRA rules 13 and 14 in this function 00052 char const Q_ROM * Q_ROM_VAR QK::getVersion(void) { 00053 static char const Q_ROM Q_ROM_VAR version[] = "4.0.02"; 00054 return version; 00055 } 00056 //............................................................................ 00057 void QF::init(void) { 00058 QK_init(); // QK initialization ("C" linkage, might be assembly) 00059 } 00060 //............................................................................ 00061 void QF::stop(void) { 00062 QF::onCleanup(); // cleanup callback 00063 // nothing else to do for the QK preemptive kernel 00064 } 00065 //............................................................................ 00066 void QF::run(void) { 00067 QK_INT_LOCK_KEY_ 00068 00069 QK_INT_LOCK_(); 00070 QK_currPrio_ = (uint8_t)0; // set the priority for the QK idle loop 00071 QK_SCHEDULE_(); // process all events produced so far 00072 QK_INT_UNLOCK_(); 00073 00074 QF::onStartup(); // startup callback 00075 00076 for (;;) { // the QK idle loop 00077 QK::onIdle(); // invoke the QK on-idle callback 00078 } 00079 } 00080 //............................................................................ 00081 void QActive::start(uint8_t prio, 00082 QEvent const *qSto[], uint32_t qLen, 00083 void *tls, uint32_t flags, 00084 QEvent const *ie) 00085 { 00086 Q_REQUIRE(((uint8_t)0 < prio) && (prio <= (uint8_t)QF_MAX_ACTIVE)); 00087 00088 m_eQueue.init(qSto, (QEQueueCtr)qLen); // initialize the event queue 00089 m_prio = prio; 00090 QF::add_(this); // make QF aware of this active object 00091 00092 #if defined(QK_TLS) || defined(QK_EXT_SAVE) 00093 m_osObject = (uint8_t)flags; // m_osObject contains the thread flags 00094 m_thread = tls; // contains the pointer to the thread-local-storage 00095 #else 00096 Q_ASSERT((tls == (void *)0) && (flags == (uint32_t)0)); 00097 #endif 00098 00099 init(ie); // execute initial transition 00100 00101 QS_FLUSH(); // flush the trace buffer to the host 00102 } 00103 //............................................................................ 00104 void QActive::stop(void) { 00105 QF::remove_(this); // remove this active object from the QF 00106 }
1.5.4