|
QP/C++
|
00001 00002 // Product: QF/C++ 00003 // Last Updated for Version: 4.5.00 00004 // Date of the Last Update: May 19, 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 program is open source software: you can redistribute it and/or 00013 // modify it under the terms of the GNU General Public License as published 00014 // by the Free Software Foundation, either version 2 of the License, or 00015 // (at your option) any later version. 00016 // 00017 // Alternatively, this program may be distributed and modified under the 00018 // terms of Quantum Leaps commercial licenses, which expressly supersede 00019 // the GNU General Public License and are specifically designed for 00020 // licensees interested in retaining the proprietary status of their code. 00021 // 00022 // This program is distributed in the hope that it will be useful, 00023 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 // GNU General Public License for more details. 00026 // 00027 // You should have received a copy of the GNU General Public License 00028 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00029 // 00030 // Contact information: 00031 // Quantum Leaps Web sites: http://www.quantum-leaps.com 00032 // http://www.state-machine.com 00033 // e-mail: info@quantum-leaps.com 00035 #include "qf_pkg.h" 00036 #include "qassert.h" 00037 00042 00043 QP_BEGIN_ 00044 00045 Q_DEFINE_THIS_MODULE("qf_act") 00046 00047 // public objects ------------------------------------------------------------ 00048 QActive *QF::active_[QF_MAX_ACTIVE + 1]; // to be used by QF ports only 00049 uint8_t QF_intLockNest_; // interrupt-lock nesting level 00050 00051 //............................................................................ 00052 char_t const Q_ROM * Q_ROM_VAR QF::getVersion(void) { 00053 uint8_t const u8_zero = static_cast<uint8_t>('0'); 00054 static char_t const Q_ROM Q_ROM_VAR version[] = { 00055 static_cast<char_t>(((QP_VERSION >> 12) & 0xFU) + u8_zero), 00056 static_cast<char_t>('.'), 00057 static_cast<char_t>(((QP_VERSION >> 8) & 0xFU) + u8_zero), 00058 static_cast<char_t>('.'), 00059 static_cast<char_t>(((QP_VERSION >> 4) & 0xFU) + u8_zero), 00060 static_cast<char_t>((QP_VERSION & 0xFU) + u8_zero), 00061 static_cast<char_t>('\0') 00062 }; 00063 return version; 00064 } 00065 //............................................................................ 00066 void QF::add_(QActive * const a) { 00067 uint8_t p = a->m_prio; 00068 00069 Q_REQUIRE((u8_0 < p) && (p <= static_cast<uint8_t>(QF_MAX_ACTIVE)) 00070 && (active_[p] == static_cast<QActive *>(0))); 00071 00072 QF_CRIT_STAT_ 00073 QF_CRIT_ENTRY_(); 00074 00075 active_[p] = a; // registger the active object at this priority 00076 00077 QS_BEGIN_NOCRIT_(QS_QF_ACTIVE_ADD, QS::aoObj_, a) 00078 QS_TIME_(); // timestamp 00079 QS_OBJ_(a); // the active object 00080 QS_U8_(p); // the priority of the active object 00081 QS_END_NOCRIT_() 00082 00083 QF_CRIT_EXIT_(); 00084 } 00085 //............................................................................ 00086 void QF::remove_(QActive const * const a) { 00087 uint8_t p = a->m_prio; 00088 00089 Q_REQUIRE((u8_0 < p) && (p <= static_cast<uint8_t>(QF_MAX_ACTIVE)) 00090 && (active_[p] == a)); 00091 00092 QF_CRIT_STAT_ 00093 QF_CRIT_ENTRY_(); 00094 00095 active_[p] = static_cast<QActive *>(0); // free-up the priority level 00096 00097 QS_BEGIN_NOCRIT_(QS_QF_ACTIVE_REMOVE, QS::aoObj_, a) 00098 QS_TIME_(); // timestamp 00099 QS_OBJ_(a); // the active object 00100 QS_U8_(p); // the priority of the active object 00101 QS_END_NOCRIT_() 00102 00103 QF_CRIT_EXIT_(); 00104 } 00105 00106 QP_END_ 00107
1.7.6.1