qpcpp/ports/vxworks/qf_port.hpp

144 lines
5.2 KiB
C++
Raw Normal View History

2018-11-22 11:34:13 -05:00
/// @file
/// @brief QF/C++ port to VxWorks API
/// @ingroup ports
/// @cond
///***************************************************************************
2019-10-27 12:26:31 -04:00
/// Last updated for version 6.6.0
/// Last updated on 2019-07-30
2018-11-22 11:34:13 -05:00
///
/// Q u a n t u m L e a P s
/// ------------------------
/// Modern Embedded Software
///
2019-10-27 12:26:31 -04:00
/// Copyright (C) 2005-2019 Quantum Leaps. All rights reserved.
2018-11-22 11:34:13 -05: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>.
2018-11-22 11:34:13 -05: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>
2018-11-22 11:34:13 -05:00
///***************************************************************************
/// @endcond
///
2019-10-27 12:26:31 -04:00
#ifndef QF_PORT_HPP
#define QF_PORT_HPP
2018-11-22 11:34:13 -05:00
// VxWorks event queue and thread types
// queue: QP queue
// os-obj: used for VxWorks task options
// thred: used for VxWorks task ID
//
#define QF_EQUEUE_TYPE QEQueue
#define QF_OS_OBJECT_TYPE int
#define QF_THREAD_TYPE int
// The maximum number of active objects in the application
2020-03-17 21:33:58 -04:00
#define QF_MAX_ACTIVE 64U
2018-11-22 11:34:13 -05:00
// The number of system clock tick rates
2020-03-17 21:33:58 -04:00
#define QF_MAX_TICK_RATE 2U
2018-11-22 11:34:13 -05:00
// various QF object sizes configuration for this port
2020-03-17 21:33:58 -04:00
#define QF_EVENT_SIZ_SIZE 4U
#define QF_EQUEUE_CTR_SIZE 4U
#define QF_MPOOL_SIZ_SIZE 4U
#define QF_MPOOL_CTR_SIZE 4U
#define QF_TIMEEVT_CTR_SIZE 4U
2018-11-22 11:34:13 -05:00
// QF priority offset within VxWorks priority numbering scheme, see NOTE1
#define QF_VX_PRIO_OFFSET 108
// QF critical section entry/exit for VxWorks
#define QF_CRIT_STAT_TYPE int
#define QF_CRIT_ENTRY(stat_) ((stat_) = intLock())
#define QF_CRIT_EXIT(stat_) (intUnlock(stat_))
// QF_LOG2 not defined -- use the internal LOG2() implementation
#include "intLib.h" // for prototypes of intLock()/intUnlock()
2019-10-27 12:26:31 -04:00
#include "qep_port.hpp" // QEP port
#include "qequeue.hpp" // VxWorks port needs event-queue
#include "qmpool.hpp" // VxWorks port needs memory-pool
#include "qpset.hpp" // VxWorks port needs priority-set
#include "qf.hpp" // QF platform-independent public interface
2018-11-22 11:34:13 -05:00
//****************************************************************************
// interface used only inside QF, but not in applications
#ifdef QP_IMPL
#define QF_EQUEUE_EVT (0x00800000)
// scheduler locking
#define QF_SCHED_STAT_
#define QF_SCHED_LOCK_(dummy) if (intContext() == FALSE) { \
Q_ALLEGE_ID(110, OK == taskLock()); \
} else ((void)0)
#define QF_SCHED_UNLOCK_() if (intContext() == FALSE) { \
Q_ALLEGE_ID(115, OK == taskUnlock()); \
} else ((void)0)
// event queue customization
2020-03-17 21:33:58 -04:00
#define QACTIVE_EQUEUE_WAIT_(me_) \
while ((me_)->m_eQueue.m_frontEvt == nullptr) { \
UINT32 eventsReceived; \
QF_CRIT_EXIT_(); \
2018-11-22 11:34:13 -05:00
Q_ALLEGE_ID(405, eventReceive(QF_EQUEUE_EVT, EVENTS_WAIT_ANY, \
2020-03-17 21:33:58 -04:00
WAIT_FOREVER, &eventsReceived) == OK); \
QF_CRIT_ENTRY_(); \
2018-11-22 11:34:13 -05:00
}
#define QACTIVE_EQUEUE_SIGNAL_(me_) \
2020-03-17 21:33:58 -04:00
Q_ASSERT_ID(410, QF::active_[(me_)->m_prio] != nullptr); \
2018-11-22 11:34:13 -05:00
Q_ALLEGE_ID(415, eventSend((me_)->m_thread, QF_EQUEUE_EVT) == OK)
// event pool operations
#define QF_EPOOL_TYPE_ QMPool
#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \
(p_).init((poolSto_), (poolSize_), (evtSize_))
#define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize())
#define QF_EPOOL_GET_(p_, e_, m_) \
((e_) = static_cast<QEvt *>((p_).get((m_))))
#define QF_EPOOL_PUT_(p_, e_) ((p_).put(e_))
#include "taskLib.h" // for taskXXX() functions
#include "eventLib.h" // for eventXXX() functions
#endif // QP_IMPL
// NOTES: ====================================================================
//
// NOTE1:
// QF_VX_PRIO_OFFSET specifies the number of highest-urgency VxWorks
// priorities not available to QP active objects. These highest-urgency
// priorities might be used by VxWorks tasks that run "above" QP active
// objects.
//
// Because the VxWorks priority numbering is "upside down" compared
// to the QP priority numbering, the VxWorks priority for an active object
// task is calculated as follows:
// vx_prio = QF_VX_PRIO_OFFSET + QF_MAX_ACTIVE - qp_prio
//
2019-10-27 12:26:31 -04:00
#endif // QF_PORT_HPP