qpc/include/qv.h

109 lines
4.3 KiB
C
Raw Normal View History

2014-04-06 11:43:13 -04:00
/**
2015-04-28 13:45:35 -04:00
* @file
* @brief QV/C (cooperative "Vanilla" kernel) platform-independent
* public interface
* @ingroup qv
* @cond
2014-04-06 11:43:13 -04:00
******************************************************************************
2020-10-01 12:48:48 -04:00
* Last updated for version 6.9.1
* Last updated on 2020-09-08
2012-08-14 18:07:04 -04:00
*
2019-10-27 11:57:33 -04:00
* Q u a n t u m L e a P s
* ------------------------
* Modern Embedded Software
2012-08-14 18:07:04 -04:00
*
2020-10-01 12:48:48 -04:00
* Copyright (C) 2005-2020 Quantum Leaps, LLC. All rights reserved.
2012-08-14 18:07: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
2012-08-14 18:07:04 -04:00
* (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 11:57:33 -04:00
* along with this program. If not, see <www.gnu.org/licenses>.
2012-08-14 18:07:04 -04:00
*
* Contact information:
2019-12-31 15:55:08 -05:00
* <www.state-machine.com/licensing>
2019-10-27 11:57:33 -04:00
* <info@state-machine.com>
2014-04-06 11:43:13 -04:00
******************************************************************************
2015-04-28 13:45:35 -04:00
* @endcond
2014-04-06 11:43:13 -04:00
*/
2019-10-27 11:57:33 -04:00
#ifndef QV_H
#define QV_H
2012-08-14 18:07:04 -04:00
2016-09-23 12:08:21 -04:00
#include "qequeue.h" /* QV kernel uses the native QP event queue */
#include "qmpool.h" /* QV kernel uses the native QP memory pool */
#include "qpset.h" /* QV kernel uses the native QP priority set */
2012-08-14 18:07:04 -04:00
2020-08-24 16:41:40 -04:00
/* QV event-queue used for AOs */
#define QF_EQUEUE_TYPE QEQueue
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
/*! QV idle callback (customized in BSPs) */
2014-04-06 11:43:13 -04:00
/**
2015-04-28 13:45:35 -04:00
* @description
* QV_onIdle() is called by the cooperative QV kernel (from QF_run()) when
* the scheduler detects that no events are available for active objects
* (the idle condition). This callback gives the application an opportunity
* to enter a power-saving CPU mode, or perform some other idle processing
* (such as QS software tracing output).
2014-04-06 11:43:13 -04:00
*
2015-04-28 13:45:35 -04:00
* @note QV_onIdle() is invoked with interrupts DISABLED because the idle
2014-04-06 11:43:13 -04:00
* condition can be asynchronously changed at any time by an interrupt.
2015-04-28 13:45:35 -04:00
* QV_onIdle() MUST enable the interrupts internally, but not before
2014-04-06 11:43:13 -04:00
* putting the CPU into the low-power mode. (Ideally, enabling interrupts and
* low-power mode should happen atomically). At the very least, the function
* MUST enable interrupts, otherwise interrupts will remain disabled
* permanently.
*
2015-04-28 13:45:35 -04:00
* @note QV_onIdle() is only used by the cooperative QV kenrnel in the
* native (bare metal) QF ports, and is NOT used in any other QF ports. When
* QF is combined with the preemptive QK, the QK idle loop calls a different
* function QK_onIdle(), with different semantics than QV_onIdle(). When QF
* is combined with a 3rd-party RTOS or kernel, the idle processing mechanism
* of the RTOS or kernel is used instead of QV_onIdle().
2013-09-23 14:34:35 -04:00
*/
2015-04-28 13:45:35 -04:00
void QV_onIdle(void);
2014-04-06 11:43:13 -04:00
2015-05-14 15:45:53 -04:00
2014-04-06 11:43:13 -04:00
/****************************************************************************/
/* interface used only inside QP implementation, but not in applications */
#ifdef QP_IMPL
2016-09-29 18:08:33 -04:00
/* QV-specific scheduler locking (not needed in QV) */
#define QF_SCHED_STAT_
#define QF_SCHED_LOCK_(dummy) ((void)0)
2016-03-30 18:50:33 -04:00
#define QF_SCHED_UNLOCK_(dummy) ((void)0)
2016-09-29 18:08:33 -04:00
/* native QF event queue operations... */
2013-09-23 14:34:35 -04:00
#define QACTIVE_EQUEUE_WAIT_(me_) \
2014-04-06 11:43:13 -04:00
Q_ASSERT_ID(0, (me_)->eQueue.frontEvt != (QEvt *)0)
2012-08-14 18:07:04 -04:00
2016-09-23 12:08:21 -04:00
#define QACTIVE_EQUEUE_SIGNAL_(me_) \
2017-12-11 12:13:22 -05:00
QPSet_insert(&QV_readySet_, (uint_fast8_t)(me_)->prio)
2016-09-23 12:08:21 -04:00
2014-04-06 11:43:13 -04:00
/* native QF event pool operations */
2013-12-30 17:37:40 -05:00
#define QF_EPOOL_TYPE_ QMPool
2013-09-23 14:34:35 -04:00
#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \
2013-12-30 17:37:40 -05:00
(QMPool_init(&(p_), (poolSto_), (poolSize_), (evtSize_)))
2014-04-06 11:43:13 -04:00
#define QF_EPOOL_EVENT_SIZE_(p_) ((uint_fast16_t)(p_).blockSize)
2020-10-01 12:48:48 -04:00
#define QF_EPOOL_GET_(p_, e_, m_, qs_id_) \
((e_) = (QEvt *)QMPool_get(&(p_), (m_), (qs_id_)))
#define QF_EPOOL_PUT_(p_, e_, qs_id_) \
(QMPool_put(&(p_), (e_), (qs_id_)))
2013-09-23 14:34:35 -04:00
2016-09-23 12:08:21 -04:00
extern QPSet QV_readySet_; /*!< QV ready-set of AOs */
2012-08-14 18:07:04 -04:00
2014-04-06 11:43:13 -04:00
#endif /* QP_IMPL */
2012-08-14 18:07:04 -04:00
2019-10-27 11:57:33 -04:00
#endif /* QV_H */