qpcpp/include/qv.hpp

117 lines
4.3 KiB
C++
Raw Normal View History

2015-05-14 16:05:04 -04:00
/// @file
/// @brief QV/C++ platform-independent public interface.
/// @ingroup qv
/// @cond
///***************************************************************************
2020-10-01 12:50:17 -04:00
/// Last updated for version 6.9.1
/// Last updated on 2020-09-15
2015-05-14 16:05:04 -04:00
///
2019-10-27 12:26:31 -04:00
/// Q u a n t u m L e a P s
/// ------------------------
/// Modern Embedded Software
2015-05-14 16:05:04 -04:00
///
2020-03-17 21:33:58 -04:00
/// Copyright (C) 2005-2020 Quantum Leaps. All rights reserved.
2015-05-14 16:05:04 -04:00
///
/// This program is open source software: you can redistribute it and/or
/// modify it under the terms of the GNU General Public License as published
/// by the Free Software Foundation, either version 3 of the License, or
/// (at your option) any later version.
///
/// Alternatively, this program may be distributed and modified under the
/// terms of Quantum Leaps commercial licenses, which expressly supersede
/// the GNU General Public License and are specifically designed for
/// licensees interested in retaining the proprietary status of their code.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
2019-10-27 12:26:31 -04:00
/// along with this program. If not, see <www.gnu.org/licenses>.
2015-05-14 16:05:04 -04:00
///
/// Contact information:
2019-12-31 15:56:23 -05:00
/// <www.state-machine.com/licensing>
2019-10-27 12:26:31 -04:00
/// <info@state-machine.com>
2015-05-14 16:05:04 -04:00
///***************************************************************************
/// @endcond
2019-10-27 12:26:31 -04:00
#ifndef QV_HPP
#define QV_HPP
2015-05-14 16:05:04 -04:00
2019-10-27 12:26:31 -04:00
#include "qequeue.hpp" // QV kernel uses the native QF event queue
#include "qmpool.hpp" // QV kernel uses the native QF memory pool
#include "qpset.hpp" // QV kernel uses the native QF priority set
2015-05-14 16:05:04 -04:00
//****************************************************************************
// QF configuration for QK
2020-08-24 16:42:48 -04:00
// QV event-queue used for AOs
#define QF_EQUEUE_TYPE QEQueue
2015-05-14 16:05:04 -04:00
//****************************************************************************
namespace QP {
//! QV services.
/// @description
/// This class groups together QV services. It has only static members and
/// should not be instantiated.
///
// @note The QV ready set, etc. belong conceptually to the QV class (as static
/// class members). However, to avoid C++ potential name-mangling problems in
/// assembly language, these elements are defined outside of the QK class and
/// use the extern "C" linkage specification.
class QV {
public:
//! QV idle callback (customized in BSPs for QK)
/// @description
/// QV::onIdle() must be called with interrupts DISABLED because
/// the determination of the idle condition (no events in the
/// queues) can change at any time by an interrupt posting events
/// to a queue. QV::onIdle() MUST enable interrupts internally,
/// perhaps at the same time as putting the CPU into a power-saving
/// mode.
///
/// @sa QP::QK::onIdle()
static void onIdle(void);
};
2015-06-06 18:30:55 -04:00
2015-05-14 16:05:04 -04:00
} // namespace QP
//****************************************************************************
extern "C" {
2016-09-29 19:54:50 -04:00
extern QP::QPSet QV_readySet_; //!< ready set of AOs
2015-05-14 16:05:04 -04:00
} // extern "C"
//****************************************************************************
// interface used only inside QF, but not in applications
#ifdef QP_IMPL
2016-09-29 19:54:50 -04:00
// QV-specific scheduler locking (not needed in QV)
#define QF_SCHED_STAT_
2020-07-18 17:58:58 -04:00
#define QF_SCHED_LOCK_(dummy) (static_cast<void>(0))
#define QF_SCHED_UNLOCK_() (static_cast<void>(0))
2016-04-01 13:55:34 -04:00
2016-10-08 12:46:03 -04:00
// QV-specific native event queue operations...
2015-05-14 16:05:04 -04:00
#define QACTIVE_EQUEUE_WAIT_(me_) \
2020-03-17 21:33:58 -04:00
Q_ASSERT_ID(110, (me_)->m_eQueue.m_frontEvt != nullptr)
2015-05-14 16:05:04 -04:00
#define QACTIVE_EQUEUE_SIGNAL_(me_) \
2020-03-17 21:33:58 -04:00
(QV_readySet_.insert(static_cast<std::uint_fast8_t>((me_)->m_prio)))
2015-05-14 16:05:04 -04:00
2016-10-08 12:46:03 -04:00
// QV-specific native QF event pool operations...
2015-05-14 16:05:04 -04:00
#define QF_EPOOL_TYPE_ QMPool
#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \
(p_).init((poolSto_), (poolSize_), (evtSize_))
2020-10-01 12:50:17 -04:00
#define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize())
#define QF_EPOOL_GET_(p_, e_, m_, qs_id_) \
((e_) = static_cast<QEvt *>((p_).get((m_), (qs_id_))))
#define QF_EPOOL_PUT_(p_, e_, qs_id_) ((p_).put((e_), (qs_id_)))
2015-05-14 16:05:04 -04:00
#endif // QP_IMPL
2019-10-27 12:26:31 -04:00
#endif // QV_HPP
2018-03-19 14:51:26 -04:00