├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSES ├── GPL-3.0-or-later.txt ├── License.txt ├── LicenseRef-QL-commercial.txt ├── LicenseRef-QL-dual.qlc ├── QP-Arduino_GPL_Exception.txt ├── QP-RasPi_GPL_Exception.txt └── QP-mbed_GPL_Exception.txt ├── README.md ├── cmakeSupport.md ├── include ├── README.md ├── qequeue.hpp ├── qk.hpp ├── qmpool.hpp ├── qp.hpp ├── qp_pkg.hpp ├── qpcpp.hpp ├── qs_dummy.hpp ├── qsafe.h ├── qstamp.hpp └── qv.hpp ├── ports ├── CMakeLists.txt ├── README.md ├── arm-cm │ ├── CMakeLists.txt │ ├── README.md │ ├── config │ │ └── qp_config.hpp │ ├── qk │ │ ├── armclang │ │ │ ├── qk_port.cpp │ │ │ ├── qp_port.hpp │ │ │ └── qs_port.hpp │ │ ├── gnu │ │ │ ├── qk_port.cpp │ │ │ ├── qp_port.hpp │ │ │ ├── qs_port.hpp │ │ │ └── syscalls.c │ │ └── iar │ │ │ ├── qk_port.cpp │ │ │ ├── qp_port.hpp │ │ │ └── qs_port.hpp │ └── qv │ │ ├── armclang │ │ ├── qp_port.hpp │ │ ├── qs_port.hpp │ │ └── qv_port.cpp │ │ ├── gnu │ │ ├── qp_port.hpp │ │ ├── qs_port.hpp │ │ ├── qv_port.cpp │ │ └── syscalls.c │ │ └── iar │ │ ├── qp_port.hpp │ │ ├── qs_port.hpp │ │ └── qv_port.cpp ├── arm-cr │ ├── CMakeLists.txt │ ├── config │ │ └── qp_config.hpp │ ├── qk │ │ ├── gnu │ │ │ ├── qp_port.hpp │ │ │ └── qs_port.hpp │ │ ├── iar │ │ │ ├── qp_port.hpp │ │ │ └── qs_port.hpp │ │ └── ti │ │ │ ├── qp_port.hpp │ │ │ └── qs_port.hpp │ └── qv │ │ ├── gnu │ │ ├── qp_port.hpp │ │ └── qs_port.hpp │ │ ├── iar │ │ ├── qp_port.hpp │ │ └── qs_port.hpp │ │ └── ti │ │ ├── qp_port.hpp │ │ └── qs_port.hpp ├── config │ └── qp_config.hpp ├── embos │ ├── CMakeLists.txt │ ├── qf_port.cpp │ ├── qp_port.hpp │ ├── qs_port.hpp │ └── syscalls.c ├── freertos │ ├── CMakeLists.txt │ ├── qf_port.cpp │ ├── qp_port.hpp │ ├── qs_port.hpp │ └── syscalls.c ├── msp430 │ ├── CMakeLists.txt │ ├── README.md │ ├── qk │ │ ├── qp_port.hpp │ │ └── qs_port.hpp │ ├── qutest │ │ ├── qp_port.hpp │ │ └── qs_port.hpp │ └── qv │ │ ├── qp_port.hpp │ │ └── qs_port.hpp ├── posix-qv │ ├── CMakeLists.txt │ ├── README.md │ ├── qf_port.cpp │ ├── qp_port.hpp │ ├── qs_port.cpp │ ├── qs_port.hpp │ └── safe_std.h ├── posix │ ├── CMakeLists.txt │ ├── README.md │ ├── qf_port.cpp │ ├── qp_port.hpp │ ├── qs_port.cpp │ ├── qs_port.hpp │ └── safe_std.h ├── qep-only │ ├── CMakeLists.txt │ ├── qp_port.hpp │ └── safe_std.h ├── threadx │ ├── CMakeLists.txt │ ├── README.md │ ├── qf_port.cpp │ ├── qp_port.hpp │ ├── qs_port.hpp │ └── syscalls.c ├── uc-os2 │ ├── CMakeLists.txt │ ├── qf_port.cpp │ ├── qp_port.hpp │ ├── qs_port.hpp │ └── syscalls.c ├── win32-qv │ ├── CMakeLists.txt │ ├── README.md │ ├── qf_port.cpp │ ├── qp_port.hpp │ ├── qs_port.cpp │ ├── qs_port.hpp │ ├── qwin_gui.c │ ├── qwin_gui.h │ └── safe_std.h ├── win32 │ ├── CMakeLists.txt │ ├── README.md │ ├── qf_port.cpp │ ├── qp_port.hpp │ ├── qs_port.cpp │ ├── qs_port.hpp │ ├── qwin_gui.c │ ├── qwin_gui.h │ └── safe_std.h └── zephyr │ └── README.md ├── qpcpp_8.0.4.sha1 ├── qpcpp_sdk_init.cmake ├── sha1.bat ├── src ├── CMakeLists.txt ├── README.md ├── qf │ ├── CMakeLists.txt │ ├── qep_hsm.cpp │ ├── qep_msm.cpp │ ├── qf_act.cpp │ ├── qf_actq.cpp │ ├── qf_defer.cpp │ ├── qf_dyn.cpp │ ├── qf_mem.cpp │ ├── qf_ps.cpp │ ├── qf_qact.cpp │ ├── qf_qeq.cpp │ ├── qf_qmact.cpp │ └── qf_time.cpp ├── qk │ ├── CMakeLists.txt │ └── qk.cpp ├── qs │ ├── CMakeLists.txt │ └── qstamp.cpp └── qv │ ├── CMakeLists.txt │ └── qv.cpp └── zephyr ├── CMakeLists.txt ├── Kconfig ├── README.md ├── module.yml ├── qf_port.cpp ├── qp-zephyr.jpg ├── qp_port.hpp └── qs_port.hpp /.gitignore: -------------------------------------------------------------------------------- 1 | *.qms 2 | *.obj 3 | *.o 4 | *.d 5 | *.lib 6 | *.a 7 | *.bin 8 | *.elf 9 | *.err 10 | *.hex 11 | *.exe 12 | *.EXE 13 | *.map 14 | *.dep 15 | *.pdf 16 | *.PDF 17 | *.Hbp 18 | *.nav 19 | *.tps 20 | *.tws 21 | *.tmp 22 | *.log 23 | *.chm 24 | *.zip 25 | *.pdb 26 | *.ncb 27 | *.suo 28 | *.sdf 29 | *.chw 30 | *.sfr 31 | *.ewt 32 | *.user 33 | *.avrsuo 34 | *.Debug 35 | *.Release 36 | *.bak 37 | version-* 38 | JLink*.* 39 | 40 | include/qs.hpp 41 | include/qs_pkg.hpp 42 | include/qxk.hpp 43 | src/qs/qs.cpp 44 | src/qs/qs_64bit.cpp 45 | src/qs/qs_fp.cpp 46 | src/qs/qs_rx.cpp 47 | src/qs/qutest.cpp 48 | src/qxk/qxk.cpp 49 | src/qxk/qxk_mutex.cpp 50 | src/qxk/qxk_sema.cpp 51 | src/qxk/qxk_xthr.cpp 52 | 53 | ports/arm-cm/qxk/ 54 | ports/arm-cm/qutest/ 55 | ports/posix-qutest/ 56 | ports/win32-qutest/ 57 | 58 | priv/ 59 | html/ 60 | latex/ 61 | dbg/ 62 | rel/ 63 | spy/ 64 | build*/ 65 | settings/ 66 | .settings/ 67 | targetConfigs/ 68 | 69 | Debug/ 70 | Release/ 71 | Spy/ 72 | QSpy/ 73 | 74 | lib/ 75 | obj/ 76 | output/ 77 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "3rd_party"] 2 | path = 3rd_party 3 | url = https://github.com/QuantumLeaps/3rd_party.git 4 | [submodule "examples"] 5 | path = examples 6 | url = https://github.com/QuantumLeaps/qpcpp-examples 7 | -------------------------------------------------------------------------------- /LICENSES/License.txt: -------------------------------------------------------------------------------- 1 | Quantum Leaps Dual-Licensing: 2 | 3 | The QP/C Real-Time Embedded Framework is dually-licensed under 4 | the following two alternatives: 5 | 6 | 1. Open source GNU General Public License (GPL) version 3, 7 | or alternatively, 8 | 9 | 2. One of the closed source Quantum Leaps commercial licenses. 10 | 11 | The terms of the open source GNU General Public License version 3 12 | can be found at: https://www.gnu.org/licenses/gpl-3.0 13 | 14 | The terms of the closed source Quantum Leaps commercial licenses 15 | can be found at: https://www.state-machine.com/licensing 16 | 17 | Redistributions in source code must retain the top-level comment blocks 18 | in all files. Plagiarizing this software to sidestep the license 19 | obligations is illegal. 20 | -------------------------------------------------------------------------------- /LICENSES/LicenseRef-QL-commercial.txt: -------------------------------------------------------------------------------- 1 | Quantum Leaps Commercial Licenses 2 | 3 | Copyright (C) 2005 Quantum Leaps, LLC 4 | 5 | Quantum Leaps commercial licenses are traditional closed-source, paid-for 6 | licenses designed for licensees interested in retaining the proprietary 7 | status of their code. 8 | 9 | The Quantum Leaps commercial licenses expressly supersede the GPL open source 10 | license. This means that when you license the QP/C or QP/C++ Real-Time 11 | Event Frameworks under a Quantum Leaps commercial license, you specifically 12 | do not use the software under the open source license and therefore you are 13 | not subject to any of its terms. 14 | 15 | Quantum Leaps commercial licensing options are described below: 16 | 17 | 18 | SPDX-License-Identifier: LicenseRef-QL-Single-Product 19 | ----------------------------------------------------- 20 | Single Product License allows a given company ("Licensee") to embed the 21 | specified type(s) of the QP Real-Time Event Framework(s) into one end- 22 | product of the Licensee (Single Product). Licensee can distribute/sell an 23 | unlimited number of units of the Single Product (royalty-free licensing), 24 | for the life of the Single Product. A different Single Product license is 25 | required for each different end product (i.e. model) even if the end-product 26 | is in the same family as a previously licensed end product. This license 27 | is specific to the Licensee and the name and model of the Single Product, 28 | which needs to be defined in the license. The general rule we apply is: 29 | 30 | If you consider it a separate product... so do we! 31 | 32 | Volume discounts are offered if several Single Products are licensed at once 33 | with one license agreement. 34 | 35 | 36 | SPDX-License-Identifier: LicenseRef-QL-Product-Line 37 | --------------------------------------------------- 38 | Product Line License allows a given company ("Licensee") to embed the 39 | specified type(s) of the QP Real-Time Event Framework(s) into any number 40 | of end-products within a family of related products (Product Line). Licensee 41 | can distribute/sell an unlimited number of units of each of those products 42 | (royalty-free licensing), for the life of the end-products within the 43 | Product Line. Product Line License applies to all end-products that do 44 | similar functions within the same Product Line. 45 | 46 | 47 | SPDX-License-Identifier: LicenseRef-QL-Any-Product 48 | -------------------------------------------------- 49 | Any-Product License allows a given company ("Licensee") to embed the 50 | specified type(s) of the QP Real-Time Event Framework(s) into any end- 51 | product of that company. The Licensee can distribute/sell an unlimited number 52 | of the products containing the licensed QP framework type(s) (royalty-free 53 | licensing). 54 | 55 | 56 | SPDX-License-Identifier: LicenseRef-QL-Site 57 | ------------------------------------------- 58 | Site-License allows a given company ("Licensee") to embed the specified 59 | type(s) of the QP Real-Time Event Framework(s) into any end-customer 60 | product, as long as the products are designed at a given physical location 61 | (Site), which must be defined in the license. This license gives the 62 | Licensee also limited sublicensing rights for its clients and is specifically 63 | designed for development contractors and consultants, who develop embedded 64 | software for other companies. 65 | 66 | 67 | SPDX-License-Identifier: LicenseRef-QL-OEM 68 | ------------------------------------------ 69 | OEM License allows a given company ("Licensee") to embed the specified 70 | type(s) of the QP Real-Time Event Framework(s) in any product of that 71 | company (Original Equipment Manufacturer) and gives limited sublicensing 72 | rights to system integrators, subsystem vendors, subcontractors, and other 73 | affiliates. OEM licenses are customizable to match exactly the specific 74 | licensing needs of a given Licensee. 75 | 76 | 77 | SPDX-License-Identifier: LicenseRef-QL-Eval 78 | ------------------------------------------- 79 | Evaluation License allows a specific company ("Licensee") to temporarily 80 | use the specified type(s) of the QP Real-Time Event Framework(s) for 81 | in-house evaluation. This license expressly prohibits any distribution 82 | of the licensed QP software. 83 | 84 | 85 | **** 86 | NOTE: Please use the contact information below to find the current prices 87 | of the Quantum Leaps commercial licenses and to request the license 88 | agreements and price quotes. 89 | **** 90 | 91 | Contact Information: 92 | ==================== 93 | - https://www.state-machine.com/licensing 94 | - mailto:info@state-machine.com 95 | -------------------------------------------------------------------------------- /LICENSES/LicenseRef-QL-dual.qlc: -------------------------------------------------------------------------------- 1 | public 2 | qpcpp 3 | 2025-12-31 4 | 5 | Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 6 | 7 | Q u a n t u m L e a P s 8 | ------------------------ 9 | Modern Embedded Software 10 | 11 | SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 12 | 13 | This software is dual-licensed under the terms of the open-source GNU 14 | General Public License (GPL) or, alternatively under the terms of one of 15 | the closed-source Quantum Leaps commercial licenses. 16 | 17 | Redistributions in source code must retain this top-level comment block. 18 | Plagiarizing this software to sidestep the license obligations is illegal. 19 | 20 | NOTE: 21 | The GPL does NOT permit the incorporation of this code into proprietary 22 | programs. Please contact Quantum Leaps for commercial licensing options, 23 | which expressly supersede the GPL and are designed explicitly for 24 | closed-source distribution. 25 | 26 | Quantum Leaps contact information: 27 | 28 | 29 | #22068EAFB0B47F43F9A380BA77EA1CA618EE0EC6 -------------------------------------------------------------------------------- /LICENSES/QP-Arduino_GPL_Exception.txt: -------------------------------------------------------------------------------- 1 | QP/C++ and QP-nano FRAMEWORK EXCEPTION FOR ARDUINO 2 | 3 | Version 3.0, December 22, 2021 4 | 5 | Copyright (c) 2005-2021 Quantum Leaps, LLC. 6 | 7 | Everyone is permitted to copy and distribute verbatim copies of this 8 | license document, but changing it is not allowed. 9 | 10 | This QP/C++ and QP-nano Framework Exception for Arduino ("Exception") 11 | is an additional permission under section 7 of the GNU General Public 12 | License, version 3 ("GPLv3"). It applies to the QP/C++ and QP-nano 13 | source code (the "QP Frameworks") that is distributed as part of the 14 | QP-Arduino Support Package. 15 | 16 | When you use QP/C++ or QP-nano Frameworks inside your program, the frameworks' 17 | code is combined with your code of the program. The purpose of this Exception 18 | is to allow non-GPL (including proprietary) programs to use, in this way, the 19 | QP Frameworks' code covered by this Exception. 20 | 21 | 0. Definitions. 22 | "QP Frameworks" are lightweight real-time event frameworks (RTEFs) 23 | as well as all supporting ports and examples, as distributed from: 24 | and 25 | 26 | 27 | "Arduino-Certified Board" means any board with an Arduino-supported 28 | CPU that bears an official Arduino logo and/or is officially certified 29 | under the Arduino Certified Program 30 | (see ). 31 | 32 | "Target Code" refers to output from any compiler and linker in 33 | executable form suitable for execution by an embedded microcontroller. 34 | 35 | 36 | 1. Grant of Additional Permission 37 | As a special Exception, the copyright holder of QP Frameworks gives you 38 | permission to propagate a work of Target Code formed by combining 39 | the QP Frameworks with your own source code without the requirement 40 | to expose your proprietary source code, provided that all Target Code 41 | will execute on Arduino-Certified Board(s). 42 | 43 | 2. No Weakening of GPL 44 | The availability of this Exception does not imply any general 45 | presumption that third-party software linking to the QP Framework is 46 | unaffected by the copyleft requirements of the GPLv3 license. 47 | -------------------------------------------------------------------------------- /LICENSES/QP-RasPi_GPL_Exception.txt: -------------------------------------------------------------------------------- 1 | QP/C and QP/C++ FRAMEWORKS EXCEPTION FOR RASPBERRY PI 2 | 3 | Version 2.0, 2 August 2022 4 | 5 | Copyright (c) 2005-2021 Quantum Leaps, LLC. 6 | 7 | Everyone is permitted to copy and distribute verbatim copies of this 8 | license document, but changing it is not allowed. 9 | 10 | This QP/C and QP/C++ Framework Exception for Raspberry Pi ("Exception") 11 | is an additional permission under section 7 of the GNU General Public 12 | License, version 3 ("GPLv3"). It applies to the QP/C and QP/C++ source 13 | code (the "QP Frameworks"). 14 | 15 | When you use QP Frameworks inside your program, the QP Frameworks' code 16 | is combined with your code of the program. The purpose of this Exception 17 | is to allow non-GPL (including proprietary) programs to use, in this way, 18 | the QP Frameworks' code covered by this Exception. 19 | 20 | 0. Definitions. 21 | "QP Frameworks" are lightweight real-time event frameworks (RTEFs) 22 | as well as all supporting ports and examples, as distributed from: 23 | and 24 | 25 | 26 | "Raspberry Pi" is a low cost, credit-card sized computer that is designed 27 | by the Raspberry Pi Foundation based in the UK and registered as UK 28 | educational charity under the number 1129409. For the purpose of this 29 | license, Raspberry Pi means only genuine Raspberry Pi computer bearing 30 | the Raspberry Pi logo, as described at: 31 | . 32 | 33 | "Target Code" refers to output from any compiler and linker in executable 34 | form suitable for execution by Raspberry Pi. 35 | 36 | 37 | 1. Grant of Additional Permission 38 | As a special Exception, the copyright holder of QP Frameworks gives you 39 | permission to propagate a work of Target Code formed by combining the 40 | QP/C or QP/C++ Frameworks with your own source code without the requirement 41 | to expose your propriatory source code, provided that all Target Code will 42 | execute on a genuine Raspberry Pi computer(s). 43 | 44 | 2. No Weakening of GPL 45 | The availability of this Exception does not imply any general 46 | presumption that third-party software linking to the QP Framework is 47 | unaffected by the copyleft requirements of the GPLv3 license. 48 | -------------------------------------------------------------------------------- /LICENSES/QP-mbed_GPL_Exception.txt: -------------------------------------------------------------------------------- 1 | QP/C and QP/C++ FRAMEWORKS EXCEPTION FOR ARM mbed 2 | 3 | Version 2.0, August 2022 4 | 5 | Copyright (c) 2005-2014 Quantum Leaps, LLC. 6 | 7 | Everyone is permitted to copy and distribute verbatim copies of this 8 | license document, but changing it is not allowed. 9 | 10 | This QP/C and QP/C++ Framework Exception for ARM mbed ("Exception") 11 | is an additional permission under section 7 of the GNU General Public 12 | License, version 3 ("GPLv3"). It applies to the QP/C and QP/C++ source 13 | code (the "QP Frameworks"). 14 | 15 | When you use QP Frameworks inside your program, the QP Frameworks' code 16 | is combined with your code of the program. The purpose of this Exception 17 | is to allow non-GPL (including proprietary) programs to use, in this way, 18 | the QP Frameworks' code covered by this Exception. 19 | 20 | 0. Definitions. 21 | "QP Frameworks" are lightweight real-time event frameworks (RTEFs) 22 | as well as all supporting ports and examples, as distributed from: 23 | and 24 | 25 | 26 | "mbed-Enabled Board" means any board with an ARM Cortex-M CPU that is listed 27 | on the official "mbed platforms" website . 28 | 29 | 30 | 1. Grant of Additional Permission 31 | As a special Exception, the copyright holder of QP Frameworks gives you 32 | permission to propagate a work of Target Code formed by combining the 33 | QP/C or QP/C++ Frameworks with your own source code without the requirement 34 | to expose your propriatory source code, provided that all Target Code will 35 | execute on an "mbed-Enabled Board". 36 | 37 | 2. No Weakening of GPL 38 | The availability of this Exception does not imply any general 39 | presumption that third-party software linking to the QP Framework is 40 | unaffected by the copyleft requirements of the GPLv3 license. 41 | -------------------------------------------------------------------------------- /include/README.md: -------------------------------------------------------------------------------- 1 | # Files Missing from the QP/C++ GPL Distribution 2 | Due to the widespread non-compliance with the GPL, as well as infringement 3 | on the [dual-licensing model of QP frameworks][Lic], the following files 4 | have been **removed from the open-source GPL distribution**: 5 | 6 | ``` 7 | qpcpp 8 | | 9 | +---include 10 | | qs.hpp 11 | | qs_pkg.hpp 12 | | qxk.hpp 13 | | 14 | \---src 15 | | 16 | +---qs 17 | | qs.cpp 18 | | qs_64bit.cpp 19 | | qs_fp.cpp 20 | | qs_rx.cpp 21 | | qutest.cpp 22 | | 23 | \---qxk 24 | qxk.cpp 25 | qxk_mutex.cpp 26 | qxk_sema.cpp 27 | qxk_xthr.cpp 28 | ``` 29 | 30 | > NOTE: These files are available to the [commercial licensees][Cust] with 31 | the active Support Term. Please contact [Quantum Leaps technical support][Sup] 32 | to get the complete QP/C++ framework distribution. 33 | 34 | # QP/C++ Framework Evaluation 35 | To request **evaluation** of the complete QP/C++ framework, please contact 36 | Quantum Leaps at: 37 | - https://www.state-machine.com/contact 38 | 39 | # Quantum Leaps Licensing: 40 | To learn more about the open source and commercial licensing options: 41 | - https://www.state-machine.com/licensing 42 | 43 | [Lic]: 44 | [Cust]: 45 | [Sup]: 46 | -------------------------------------------------------------------------------- /include/qequeue.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #ifndef QEQUEUE_HPP_ 30 | #define QEQUEUE_HPP_ 31 | 32 | #ifndef QF_EQUEUE_CTR_SIZE 33 | #define QF_EQUEUE_CTR_SIZE 1U 34 | #endif 35 | 36 | namespace QP { 37 | 38 | #if (QF_EQUEUE_CTR_SIZE == 1U) 39 | using QEQueueCtr = std::uint8_t; 40 | #elif (QF_EQUEUE_CTR_SIZE == 2U) 41 | using QEQueueCtr = std::uint16_t; 42 | #else 43 | #error QF_EQUEUE_CTR_SIZE defined incorrectly, expected 1U or 2U 44 | #endif 45 | 46 | class QEvt; // forward declaration 47 | 48 | } // namespace QP 49 | 50 | //============================================================================ 51 | namespace QP { 52 | 53 | class QEQueue { 54 | public: 55 | QEQueue() noexcept 56 | : m_frontEvt(nullptr), 57 | m_ring(nullptr), 58 | m_end(0U), 59 | m_head(0U), 60 | m_tail(0U), 61 | m_nFree(0U), 62 | m_nMin(0U) 63 | {} 64 | void init( 65 | QEvt const * * const qSto, 66 | std::uint_fast16_t const qLen) noexcept; 67 | bool post( 68 | QEvt const * const e, 69 | std::uint_fast16_t const margin, 70 | std::uint_fast8_t const qsId) noexcept; 71 | void postLIFO( 72 | QEvt const * const e, 73 | std::uint_fast8_t const qsId) noexcept; 74 | QEvt const * get(std::uint_fast8_t const qsId) noexcept; 75 | QEQueueCtr getNFree() const noexcept { 76 | return m_nFree; 77 | } 78 | QEQueueCtr getNMin() const noexcept { 79 | return m_nMin; 80 | } 81 | bool isEmpty() const noexcept { 82 | return m_frontEvt == nullptr; 83 | } 84 | QEvt const *peekFront() const noexcept { 85 | return m_frontEvt; 86 | } 87 | 88 | private: 89 | QEvt const * volatile m_frontEvt; 90 | QEvt const * * m_ring; 91 | QEQueueCtr m_end; 92 | QEQueueCtr volatile m_head; 93 | QEQueueCtr volatile m_tail; 94 | QEQueueCtr volatile m_nFree; 95 | QEQueueCtr m_nMin; 96 | 97 | QEQueue(QEQueue const & other) = delete; 98 | QEQueue & operator=(QEQueue const & other) = delete; 99 | void postFIFO_( 100 | QEvt const * const e, 101 | void const * const sender); 102 | 103 | // friends... 104 | friend class QActive; 105 | friend class QTicker; 106 | friend class QXMutex; 107 | friend class QXThread; 108 | friend class QS; 109 | }; // class QEQueue 110 | 111 | } // namespace QP 112 | 113 | #endif // QEQUEUE_HPP_ 114 | -------------------------------------------------------------------------------- /include/qk.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #ifndef QK_HPP_ 30 | #define QK_HPP_ 31 | 32 | namespace QP { 33 | 34 | using QSchedStatus = std::uint_fast8_t; 35 | 36 | } // namespace QP 37 | 38 | //============================================================================ 39 | extern "C" { 40 | 41 | class QK_Attr { 42 | public: 43 | QP::QPSet readySet; 44 | std::uint8_t actPrio; 45 | std::uint8_t nextPrio; 46 | std::uint8_t actThre; 47 | std::uint8_t lockCeil; 48 | std::uint8_t intNest; 49 | }; // class QK_Attr 50 | 51 | extern QK_Attr QK_priv_; 52 | 53 | std::uint_fast8_t QK_sched_() noexcept; 54 | 55 | std::uint_fast8_t QK_sched_act_( 56 | QP::QActive const * const act, 57 | std::uint_fast8_t const pthre_in) noexcept; 58 | 59 | void QK_activate_() noexcept; 60 | 61 | } // extern "C" 62 | 63 | //============================================================================ 64 | namespace QP { 65 | namespace QK { 66 | 67 | QSchedStatus schedLock(std::uint_fast8_t const ceiling) noexcept; 68 | void schedUnlock(QSchedStatus const prevCeil) noexcept; 69 | void onIdle(); 70 | 71 | } // namespace QK 72 | } // namespace QP 73 | 74 | //============================================================================ 75 | // interface used only for internal implementation, but not in applications 76 | #ifdef QP_IMPL 77 | 78 | // scheduler locking for QK... 79 | #define QF_SCHED_STAT_ QSchedStatus lockStat_; 80 | #define QF_SCHED_LOCK_(ceil_) do { \ 81 | if (QK_ISR_CONTEXT_()) { \ 82 | lockStat_ = 0xFFU; \ 83 | } else { \ 84 | lockStat_ = QK::schedLock((ceil_)); \ 85 | } \ 86 | } while (false) 87 | 88 | #define QF_SCHED_UNLOCK_() do { \ 89 | if (lockStat_ != 0xFFU) { \ 90 | QK::schedUnlock(lockStat_); \ 91 | } \ 92 | } while (false) 93 | 94 | // QActive event queue customization for QK... 95 | #define QACTIVE_EQUEUE_WAIT_(me_) (static_cast(0)) 96 | #define QACTIVE_EQUEUE_SIGNAL_(me_) do { \ 97 | QK_priv_.readySet.insert( \ 98 | static_cast((me_)->m_prio)); \ 99 | if (!QK_ISR_CONTEXT_()) { \ 100 | if (QK_sched_() != 0U) { \ 101 | QK_activate_(); \ 102 | } \ 103 | } \ 104 | } while (false) 105 | 106 | // QF event pool customization for QK... 107 | #define QF_EPOOL_TYPE_ QMPool 108 | #define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \ 109 | (p_).init((poolSto_), (poolSize_), (evtSize_)) 110 | #define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize()) 111 | #define QF_EPOOL_GET_(p_, e_, m_, qsId_) \ 112 | ((e_) = static_cast((p_).get((m_), (qsId_)))) 113 | #define QF_EPOOL_PUT_(p_, e_, qsId_) ((p_).put((e_), (qsId_))) 114 | 115 | #endif // QP_IMPL 116 | 117 | #endif // QK_HPP_ 118 | -------------------------------------------------------------------------------- /include/qmpool.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #ifndef QMPOOL_HPP_ 30 | #define QMPOOL_HPP_ 31 | 32 | #ifndef QF_MPOOL_SIZ_SIZE 33 | #define QF_MPOOL_SIZ_SIZE 2U 34 | #endif 35 | #ifndef QF_MPOOL_CTR_SIZE 36 | #define QF_MPOOL_CTR_SIZE 2U 37 | #endif 38 | 39 | #define QF_MPOOL_EL(evType_) struct { \ 40 | void * sto_[((sizeof(evType_) - 1U) / sizeof(void *)) + \ 41 | (sizeof(evType_) < (2U * sizeof(void *)) ? 2U : 1U)]; \ 42 | } 43 | 44 | //============================================================================ 45 | namespace QP { 46 | 47 | #if (QF_MPOOL_SIZ_SIZE == 1U) 48 | using QMPoolSize = std::uint8_t; 49 | #elif (QF_MPOOL_SIZ_SIZE == 2U) 50 | using QMPoolSize = std::uint16_t; 51 | #elif (QF_MPOOL_SIZ_SIZE == 4U) 52 | using QMPoolSize = std::uint32_t; 53 | #else 54 | #error QF_MPOOL_SIZ_SIZE defined incorrectly, expected 1U, 2U, or 4U 55 | #endif 56 | 57 | #if (QF_MPOOL_CTR_SIZE == 1U) 58 | using QMPoolCtr = std::uint8_t; 59 | #elif (QF_MPOOL_CTR_SIZE == 2U) 60 | using QMPoolCtr = std::uint16_t; 61 | #elif (QF_MPOOL_CTR_SIZE == 4U) 62 | using QMPoolCtr = std::uint32_t; 63 | #else 64 | #error QF_MPOOL_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U 65 | #endif 66 | 67 | //============================================================================ 68 | class QMPool { 69 | private: 70 | void * * m_start; 71 | void * * m_end; 72 | void * * volatile m_freeHead; 73 | QMPoolSize m_blockSize; 74 | QMPoolCtr m_nTot; 75 | QMPoolCtr volatile m_nFree; 76 | QMPoolCtr m_nMin; 77 | 78 | public: 79 | QMPool() 80 | : m_start(nullptr), 81 | m_end(nullptr), 82 | m_freeHead(nullptr), 83 | m_blockSize(0U), 84 | m_nTot(0U), 85 | m_nFree(0U), 86 | m_nMin(0U) 87 | {} 88 | void init( 89 | void * const poolSto, 90 | std::uint_fast32_t const poolSize, 91 | std::uint_fast16_t const blockSize) noexcept; 92 | void * get( 93 | std::uint_fast16_t const margin, 94 | std::uint_fast8_t const qsId) noexcept; 95 | void put( 96 | void * const block, 97 | std::uint_fast8_t const qsId) noexcept; 98 | QMPoolSize getBlockSize() const noexcept { 99 | return m_blockSize; 100 | } 101 | QMPoolCtr getNMin() const noexcept { 102 | #ifndef Q_UNSAFE 103 | return m_nMin; 104 | #else 105 | return 0U; 106 | #endif 107 | } 108 | QMPoolCtr getNFree() const noexcept { 109 | return m_nFree; 110 | } 111 | 112 | private: 113 | QMPool(QEQueue const & other) = delete; 114 | QMPool & operator=(QMPool const & other) = delete; 115 | 116 | // friends... 117 | friend class QS; 118 | 119 | public: 120 | 121 | #ifdef QF_ISR_API 122 | void * getFromISR( 123 | std::uint_fast16_t const margin, 124 | std::uint_fast8_t const qsId) noexcept; 125 | #endif 126 | 127 | #ifdef QF_ISR_API 128 | void putFromISR( 129 | void * const b, 130 | std::uint_fast8_t const qsId) noexcept; 131 | #endif // def QF_ISR_API 132 | }; // class QMPool 133 | 134 | } // namespace QP 135 | 136 | #endif // QMPOOL_HPP_ 137 | -------------------------------------------------------------------------------- /include/qp_pkg.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #ifndef QP_PKG_HPP_ 30 | #define QP_PKG_HPP_ 31 | 32 | //============================================================================ 33 | // helper macros... 34 | #define QF_CONST_CAST_(type_, ptr_) const_cast(ptr_) 35 | #define QF_PTR_RANGE_(x_, min_, max_) (((min_) <= (x_)) && ((x_) <= (max_))) 36 | #define QP_DIS_UPDATE_(T_, org_) (static_cast(~(org_))) 37 | #define QP_DIS_PTR_UPDATE_(T_, org_) (reinterpret_cast(~(org_))) 38 | #define QP_DIS_VERIFY_(T_, org_, dis_) \ 39 | (reinterpret_cast(org_) == static_cast(~(dis_))) 40 | 41 | //============================================================================ 42 | namespace QP { 43 | namespace QF { 44 | 45 | class Attr { 46 | public: 47 | 48 | #if (QF_MAX_EPOOL > 0U) 49 | QF_EPOOL_TYPE_ ePool_[QF_MAX_EPOOL]; 50 | std::uint_fast8_t maxPool_; 51 | #else 52 | std::uint8_t dummy; 53 | #endif // (QF_MAX_EPOOL == 0U) 54 | }; // class Attr 55 | 56 | extern QF::Attr priv_; 57 | 58 | void bzero_( 59 | void * const start, 60 | std::uint_fast16_t const len) noexcept; 61 | 62 | } // namespace QF 63 | 64 | //============================================================================ 65 | // Bitmasks are for the QTimeEvt::flags attribute 66 | constexpr std::uint8_t QTE_FLAG_IS_LINKED {1U << 7U}; 67 | constexpr std::uint8_t QTE_FLAG_WAS_DISARMED {1U << 6U}; 68 | 69 | //============================================================================ 70 | inline void QEvt_refCtr_inc_(QEvt const * const e) noexcept { 71 | // NOTE: this function must be called inside a critical section 72 | std::uint8_t rc = e->refCtr_ + 1U; 73 | (QF_CONST_CAST_(QEvt*, e))->refCtr_ = rc; // cast away 'const' 74 | } 75 | 76 | inline void QEvt_refCtr_dec_(QEvt const * const e) noexcept { 77 | // NOTE: this function must be called inside a critical section 78 | std::uint8_t rc = e->refCtr_ - 1U; 79 | (QF_CONST_CAST_(QEvt*, e))->refCtr_ = rc; // cast away 'const' 80 | } 81 | 82 | } // namespace QP 83 | 84 | #endif // QP_PKG_HPP_ 85 | -------------------------------------------------------------------------------- /include/qpcpp.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #ifndef QPCPP_HPP_ 30 | #define QPCPP_HPP_ 31 | 32 | //============================================================================ 33 | #include "qp_port.hpp" // QP port from the port directory 34 | #include "qsafe.h" // QP Functional Safety (FuSa) Subsystem 35 | #ifdef Q_SPY // software tracing enabled? 36 | #include "qs_port.hpp" // QS/C++ port from the port directory 37 | #else 38 | #include "qs_dummy.hpp" // QS/C++ dummy (inactive) interface 39 | #endif 40 | 41 | //============================================================================ 42 | #ifndef QP_API_VERSION 43 | #define QP_API_VERSION 0 44 | #endif // QP_API_VERSION 45 | 46 | // QP API compatibility layer... 47 | //============================================================================ 48 | #if (QP_API_VERSION < 800) 49 | 50 | #define QM_SM_STATE_DECL(subm_, state_) error "submachines no longer supported" 51 | #define qm_super_sub(sm_state_) error "submachines no longer supported" 52 | #define qm_tran_ep(tatbl_) error "submachines no longer supported" 53 | #define qm_tran_xp(xp_, tatbl_) error "submachines no longer supported" 54 | #define qm_sm_exit(sm_state_) error "submachines no longer supported" 55 | 56 | #ifdef QEVT_DYN_CTOR 57 | //! @deprecated #QEVT_DYN_CTOR, please use #QEVT_PAR_INIT 58 | #define QEVT_PAR_INIT 59 | #endif 60 | 61 | //! @deprecated plain 'char' is no longer forbidden in MISRA-C++:2023 62 | using char_t = char; 63 | 64 | //! @deprecated assertion failure handler 65 | //! Use Q_onError() instead. 66 | #define Q_onAssert(module_, id_) Q_onError(module_, id_) 67 | 68 | //! @deprecated #Q_NASSERT preprocessor switch to disable QP assertions 69 | #ifdef Q_NASSERT 70 | 71 | // #Q_UNSAFE now replaces the functionality of Q_NASSERT 72 | #define Q_UNSAFE 73 | 74 | //! @deprecated general purpose assertion with user-specified ID 75 | //! number that **always** evaluates the `expr_` expression. 76 | #define Q_ALLEGE_ID(id_, expr_) (static_cast(expr_)) 77 | 78 | #elif defined Q_UNSAFE 79 | 80 | //! @deprecated general purpose assertion with user-specified ID 81 | //! number that **always** evaluates the `expr_` expression. 82 | #define Q_ALLEGE_ID(id_, expr_) (static_cast(expr_)) 83 | 84 | #else // QP FuSa Subsystem enabled 85 | 86 | //! @deprecated general purpose assertion with user-specified ID 87 | //! number that **always** evaluates the `expr_` expression. 88 | //! @note 89 | //! The use of this macro is no longer recommended. 90 | #define Q_ALLEGE_ID(id_, expr_) if (!(expr_)) { \ 91 | QF_CRIT_STAT \ 92 | QF_CRIT_ENTRY(); \ 93 | Q_onError(&Q_this_module_[0], (id_)); \ 94 | QF_CRIT_EXIT(); \ 95 | } else ((void)0) 96 | 97 | #endif 98 | 99 | //! @deprecated general purpose assertion without ID number 100 | //! that **always** evaluates the `expr_` expression. 101 | //! Instead of ID number, this macro is based on the standard 102 | //! `__LINE__` macro. 103 | //! 104 | //! @note The use of this macro is no longer recommended. 105 | #define Q_ALLEGE(expr_) Q_ALLEGE_ID(__LINE__, (expr_)) 106 | 107 | //! Static (compile-time) assertion. 108 | //! @deprecated 109 | //! Use Q_ASSERT_STATIC() or better yet `static_assert()` instead. 110 | #define Q_ASSERT_COMPILE(expr_) Q_ASSERT_STATIC(expr_) 111 | 112 | #endif // QP_API_VERSION < 800 113 | 114 | #endif // QPCPP_HPP_ 115 | -------------------------------------------------------------------------------- /include/qs_dummy.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #ifndef QS_DUMMY_HPP_ 30 | #define QS_DUMMY_HPP_ 31 | 32 | #ifdef Q_SPY 33 | #error Q_SPY must NOT be defined to include qs_dummy.hpp 34 | #endif 35 | 36 | #ifdef Q_UTEST 37 | #error Q_UTEST must NOT be defined to include qs_dummy.hpp 38 | #endif 39 | 40 | #define QS_INIT(arg_) (true) 41 | #define QS_EXIT() static_cast(0) 42 | #define QS_DUMP() static_cast(0) 43 | #define QS_GLB_FILTER(rec_) static_cast(0) 44 | #define QS_LOC_FILTER(qsId_) static_cast(0) 45 | 46 | #define QS_BEGIN_ID(rec_, qsId_) if (false) { 47 | #define QS_END() } 48 | #define QS_BEGIN_INCRIT(rec_, qsId_) if (false) { 49 | #define QS_END_INCRIT() } 50 | 51 | #define QS_I8(width_, data_) static_cast(0) 52 | #define QS_U8(width_, data_) static_cast(0) 53 | #define QS_I16(width_, data_) static_cast(0) 54 | #define QS_U16(width_, data_) static_cast(0) 55 | #define QS_I32(width_, data_) static_cast(0) 56 | #define QS_U32(width_, data_) static_cast(0) 57 | #define QS_F32(width_, data_) static_cast(0) 58 | #define QS_F64(width_, data_) static_cast(0) 59 | #define QS_I64(width_, data_) static_cast(0) 60 | #define QS_U64(width_, data_) static_cast(0) 61 | #define QS_ENUM(group_, value_) static_cast(0) 62 | #define QS_STR(str_) static_cast(0) 63 | #define QS_MEM(mem_, size_) static_cast(0) 64 | #define QS_SIG(sig_, obj_) static_cast(0) 65 | #define QS_OBJ(obj_) static_cast(0) 66 | #define QS_FUN(fun_) static_cast(0) 67 | 68 | #define QS_SIG_DICTIONARY(sig_, obj_) static_cast(0) 69 | #define QS_OBJ_DICTIONARY(obj_) static_cast(0) 70 | #define QS_OBJ_ARR_DICTIONARY(obj_, idx_) static_cast(0) 71 | #define QS_FUN_DICTIONARY(fun_) static_cast(0) 72 | #define QS_USR_DICTIONARY(rec_) static_cast(0) 73 | #define QS_ENUM_DICTIONARY(value_, group_) static_cast(0) 74 | #define QS_ASSERTION(module_, loc_, delay_) static_cast(0) 75 | #define QS_FLUSH() static_cast(0) 76 | 77 | #define QS_TEST_PROBE_DEF(fun_) 78 | #define QS_TEST_PROBE(code_) 79 | #define QS_TEST_PROBE_ID(id_, code_) 80 | #define QS_TEST_PAUSE() static_cast(0) 81 | 82 | #define QS_OUTPUT() static_cast(0) 83 | #define QS_RX_INPUT() static_cast(0) 84 | #define QS_ONLY(code_) static_cast(0) 85 | 86 | //============================================================================ 87 | // interface used only for internal implementation, but not in applications 88 | #ifdef QP_IMPL 89 | // predefined QS trace records 90 | #define QS_BEGIN_PRE(rec_, qsId_) if (false) { 91 | #define QS_END_PRE() } 92 | #define QS_U8_PRE(data_) static_cast(0) 93 | #define QS_2U8_PRE(data1_, data2_) static_cast(0) 94 | #define QS_U16_PRE(data_) static_cast(0) 95 | #define QS_U32_PRE(data_) static_cast(0) 96 | #define QS_TIME_PRE() static_cast(0) 97 | #define QS_SIG_PRE(sig_) static_cast(0) 98 | #define QS_EVS_PRE(size_) static_cast(0) 99 | #define QS_OBJ_PRE(obj_) static_cast(0) 100 | #define QS_FUN_PRE(fun_) static_cast(0) 101 | #define QS_EQC_PRE(ctr_) static_cast(0) 102 | #define QS_MPC_PRE(ctr_) static_cast(0) 103 | #define QS_MPS_PRE(size_) static_cast(0) 104 | #define QS_TEC_PRE(ctr_) static_cast(0) 105 | 106 | #define QS_CRIT_STAT 107 | #define QS_CRIT_ENTRY() static_cast(0) 108 | #define QS_CRIT_EXIT() static_cast(0) 109 | 110 | #define QS_TR_CRIT_ENTRY() static_cast(0) 111 | #define QS_TR_CRIT_EXIT() static_cast(0) 112 | #define QS_TR_ISR_ENTRY(isrnest_, prio_) static_cast(0) 113 | #define QS_TR_ISR_EXIT(isrnest_, prio_) static_cast(0) 114 | #endif // QP_IMPL 115 | 116 | #endif // QS_DUMMY_HPP_ 117 | -------------------------------------------------------------------------------- /include/qsafe.h: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #ifndef QSAFE_H_ 30 | #define QSAFE_H_ 31 | 32 | // QF-FuSa enabled =========================================================== 33 | #ifndef Q_UNSAFE 34 | 35 | #ifndef QF_CRIT_STAT 36 | #define QF_CRIT_STAT 37 | #endif 38 | 39 | #ifndef QF_CRIT_ENTRY 40 | #define QF_CRIT_ENTRY() ((void)0) 41 | #endif 42 | 43 | #ifndef QF_CRIT_EXIT 44 | #define QF_CRIT_EXIT() ((void)0) 45 | #endif 46 | 47 | #ifndef QF_CRIT_EST 48 | #define QF_CRIT_EST() ((void)0) 49 | #endif 50 | 51 | #define Q_DEFINE_THIS_MODULE(name_) \ 52 | static char const Q_this_module_[] = name_; 53 | 54 | #define Q_ASSERT_INCRIT(id_, expr_) \ 55 | ((expr_) ? ((void)0) : Q_onError(&Q_this_module_[0], (id_))) 56 | 57 | #define Q_ERROR_INCRIT(id_) \ 58 | (Q_onError(&Q_this_module_[0], (id_))) 59 | 60 | #define Q_ASSERT_ID(id_, expr_) do { \ 61 | QF_CRIT_STAT \ 62 | QF_CRIT_ENTRY(); \ 63 | if (!(expr_)) Q_onError(&Q_this_module_[0], (id_)); \ 64 | QF_CRIT_EXIT(); \ 65 | } while (false) 66 | 67 | #define Q_ERROR_ID(id_) do { \ 68 | QF_CRIT_EST(); \ 69 | Q_onError(&Q_this_module_[0], (id_)); \ 70 | } while (false) 71 | 72 | #define Q_ASSERT_LOCAL(id_, expr_) do { \ 73 | if (!(expr_)) { \ 74 | QF_CRIT_EST(); \ 75 | Q_onError(&Q_this_module_[0], (id_)); \ 76 | } \ 77 | } while (false) 78 | 79 | // QF-FuSa disabled ========================================================== 80 | #else 81 | 82 | #define Q_DEFINE_THIS_MODULE(name_) 83 | #define Q_ASSERT_INCRIT(id_, expr_) ((void)0) 84 | #define Q_ERROR_INCRIT(id_) ((void)0) 85 | #define Q_ASSERT_ID(id_, expr_) ((void)0) 86 | #define Q_ERROR_ID(id_) ((void)0) 87 | #define Q_ASSERT_LOCAL(id_, expr_) ((void)0) 88 | 89 | #endif // QF-FuSa disabled 90 | 91 | //============================================================================ 92 | #define Q_DEFINE_THIS_FILE Q_DEFINE_THIS_MODULE(__FILE__) 93 | #define Q_ASSERT(expr_) Q_ASSERT_ID(__LINE__, (expr_)) 94 | #define Q_ERROR() Q_ERROR_ID(__LINE__) 95 | 96 | #define Q_REQUIRE(expr_) Q_ASSERT(expr_) 97 | #define Q_REQUIRE_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_)) 98 | #define Q_REQUIRE_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_)) 99 | #define Q_REQUIRE_LOCAL(id_, expr_) Q_ASSERT_LOCAL((id_), (expr_)) 100 | 101 | #define Q_ENSURE(expr_) Q_ASSERT(expr_) 102 | #define Q_ENSURE_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_)) 103 | #define Q_ENSURE_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_)) 104 | #define Q_ENSURE_LOCAL(id_, expr_) Q_ASSERT_LOCAL((id_), (expr_)) 105 | 106 | #define Q_INVARIANT(expr_) Q_ASSERT(expr_) 107 | #define Q_INVARIANT_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_)) 108 | #define Q_INVARIANT_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_)) 109 | #define Q_INVARIANT_LOCAL(id_, expr_) Q_ASSERT_LOCAL((id_), (expr_)) 110 | 111 | #define Q_ERROR_LOCAL(id_) Q_ERROR_ID(id_) 112 | 113 | #ifndef Q_ASSERT_STATIC 114 | #define Q_ASSERT_STATIC(expr_) extern char Q_static_assert_[(expr_) ? 1 : -1] 115 | #endif // ndef Q_ASSERT_STATIC 116 | 117 | #ifndef Q_NORETURN 118 | #define Q_NORETURN _Noreturn void 119 | #endif // ndef Q_NORETURN 120 | 121 | // Is this header file used outside QP? 122 | #ifndef QP_VERSION 123 | #define Q_DIM(array_) (sizeof(array_) / sizeof((array_)[0U])) 124 | #endif // ndef QP_VERSION 125 | 126 | //============================================================================ 127 | #ifdef __cplusplus 128 | extern "C" { 129 | #endif 130 | 131 | #ifndef QP_VERSION 132 | typedef int int_t; 133 | #endif // ndef QP_VERSION 134 | 135 | Q_NORETURN Q_onError( 136 | char const * const module, 137 | int_t const id); 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | #endif // QSAFE_H_ 144 | -------------------------------------------------------------------------------- /include/qstamp.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #ifndef QSTAMP_HPP_ 30 | #define QSTAMP_HPP_ 31 | 32 | namespace QP { 33 | extern char const BUILD_DATE[12]; 34 | extern char const BUILD_TIME[9]; 35 | } // namespace QP 36 | 37 | #endif // QSTAMP_HPP_ 38 | -------------------------------------------------------------------------------- /include/qv.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #ifndef QV_HPP_ 30 | #define QV_HPP_ 31 | 32 | namespace QP { 33 | namespace QV { 34 | 35 | //============================================================================ 36 | class Attr { 37 | public: 38 | QPSet readySet; 39 | std::uint8_t schedCeil; 40 | }; // class Attr 41 | 42 | extern QV::Attr priv_; 43 | 44 | void schedDisable(std::uint_fast8_t const ceiling); 45 | 46 | void schedEnable(); 47 | 48 | void onIdle(); 49 | 50 | } // namespace QV 51 | } // namespace QP 52 | 53 | //============================================================================ 54 | // interface used only for internal implementation, but not in applications 55 | #ifdef QP_IMPL 56 | 57 | // scheduler locking for QV (not needed)... 58 | #define QF_SCHED_STAT_ 59 | #define QF_SCHED_LOCK_(dummy) (static_cast(0)) 60 | #define QF_SCHED_UNLOCK_() (static_cast(0)) 61 | 62 | // QActive event queue customization for QV... 63 | #define QACTIVE_EQUEUE_WAIT_(me_) (static_cast(0)) 64 | #define QACTIVE_EQUEUE_SIGNAL_(me_) \ 65 | (QV::priv_.readySet.insert((me_)->m_prio)) 66 | 67 | // QF event pool customization for QV... 68 | #define QF_EPOOL_TYPE_ QMPool 69 | #define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \ 70 | (p_).init((poolSto_), (poolSize_), (evtSize_)) 71 | #define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize()) 72 | #define QF_EPOOL_GET_(p_, e_, m_, qsId_) \ 73 | ((e_) = static_cast((p_).get((m_), (qsId_)))) 74 | #define QF_EPOOL_PUT_(p_, e_, qsId_) ((p_).put((e_), (qsId_))) 75 | 76 | #endif // QP_IMPL 77 | 78 | #endif // QV_HPP_ 79 | -------------------------------------------------------------------------------- /ports/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMake the qpcpp libraries for different targets 2 | set(PORT_DIR ${PORT}) 3 | if((PORT STREQUAL win32) OR (PORT STREQUAL posix)) 4 | if(QPCPP_CFG_UNIT_TEST) 5 | set(PORT_DIR ${PORT_DIR}-qutest) 6 | elseif(KERNEL STREQUAL qv) 7 | set(PORT_DIR ${PORT_DIR}-qv) 8 | endif() 9 | endif() 10 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${PORT_DIR}) 11 | message(STATUS "Found port dir - './${PORT_DIR}' for port ${PORT}, KERNEL ${KERNEL}") 12 | else() 13 | message(FATAL_ERROR "Target port dir '${CMAKE_CURRENT_SOURCE_DIR}/${PORT_DIR}' not found!") 14 | endif() 15 | 16 | add_subdirectory(${PORT_DIR}) 17 | if(NOT QPCPP_CFG_QPCONFIG_H_INCLUDE_PATH) 18 | set(QPCPP_CFG_QPCONFIG_H_INCLUDE_PATH config) 19 | endif() 20 | target_include_directories(qpcpp PUBLIC ${QPCPP_CFG_QPCONFIG_H_INCLUDE_PATH}) 21 | -------------------------------------------------------------------------------- /ports/README.md: -------------------------------------------------------------------------------- 1 | # Files Missing from the QP/C GPL Distribution 2 | Due to the growing non-compliance with the GPL as well as infringement 3 | on the dual-licensing model of QP frameworks, the following files have 4 | been **removed from the open-source GPL distribution**: 5 | 6 | ``` 7 | qpcpp 8 | | 9 | \---ports 10 | +---arm-cm 11 | | +---qxk 12 | | | +---armclang 13 | | | | qxk_port.cpp 14 | | | | qp_port.hpp 15 | | | | qs_port.hpp 16 | | | | 17 | | | +---config 18 | | | | qp_config.hpp 19 | | | | 20 | | | +---gnu 21 | | | | qxk_port.cpp 22 | | | | qp_port.hpp 23 | | | | qs_port.hpp 24 | | | | 25 | | | \---iar 26 | | | qxk_port.cpp 27 | | | qp_port.hpp 28 | | | qs_port.hpp 29 | | | 30 | | \---qutest 31 | | qp_port.hpp 32 | | qs_port.hpp 33 | | 34 | +---posix-qutest 35 | | qp_port.hpp 36 | | qs_port.hpp 37 | | qutest_port.cpp 38 | | safe_std.hpp 39 | | 40 | \---win32-qutest 41 | qp_port.hpp 42 | qs_port.hpp 43 | qutest_port.cpp 44 | safe_std.hpp 45 | ``` 46 | 47 | > NOTE: These files are available to the [commercial licensees][com] with 48 | current Support Term. Please contact [Quantum Leaps technical support][sup] 49 | to get the complete QP/C++ framework distribution. 50 | 51 | # QP/C++ Framework Evaluation 52 | To request **evaluation** of the complete QP/C++ framework, please contact 53 | Quantum Leaps at: 54 | 55 | - https://www.state-machine.com/contact 56 | - mailto:info@state-machine.com 57 | 58 | # Quantum Leaps Licensing: 59 | To learn more about the open source and commercial licensing options: 60 | - https://www.state-machine.com/licensing 61 | 62 | [com]: 63 | [sup]: 64 | -------------------------------------------------------------------------------- /ports/arm-cm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ports/arm-cm 2 | string(TOLOWER ${CMAKE_C_COMPILER_ID} _compiler_) 3 | list (APPEND compList gnu iar armclang) 4 | if(NOT (${_compiler_} IN_LIST compList)) 5 | message(WARNING "no support for compiler '${_compiler_}'. Falling back to GNU. Just give it a try :)") 6 | set(_compiler_ gnu) 7 | endif() 8 | unset(compList) 9 | 10 | set(qx_port_cpp ${KERNEL}_port.cpp) 11 | 12 | if(QPCPP_CFG_UNIT_TEST) 13 | target_include_directories(qpcpp PUBLIC qutest) 14 | else() 15 | target_include_directories(qpcpp PUBLIC ${KERNEL}/${_compiler_}) 16 | endif() 17 | 18 | target_sources(qpcpp PRIVATE ${KERNEL}/${_compiler_}/${qx_port_cpp}) 19 | 20 | -------------------------------------------------------------------------------- /ports/arm-cm/README.md: -------------------------------------------------------------------------------- 1 | # Native QP/C Ports to ARM Cortex-M 2 | 3 | ## Supported ARM Cortex-M Architectures: 4 | 5 | - ARMv6-M (**ARM Cortex-M0/M0+**) 6 | - ARMv7-M (**ARM Cortex-M3/M4/M7**) 7 | - ARMv8-M (**ARM Cortex-M23/M33**) 8 | 9 | ## Supported QP/C Kernels and Toolchains: 10 | - [Cooperative QV kernel](https://www.state-machine.com/qpcpp/group__qv.html) 11 | + ARM/KEIL MDK, ARM Compiler 6 (ARM-CLANG) 12 | + IAR-ARM 13 | + GNU-ARM 14 | - [Preemptive, non-locking QK kernel](https://www.state-machine.com/qpcpp/group__qk.html) 15 | + ARM/KEIL MDK, ARM Compiler 6 (ARM-CLANG) 16 | + IAR-ARM 17 | + GNU-ARM 18 | - [Dual-mode (blocking/non-blocking) QXK kernel](https://www.state-machine.com/qpcpp/group__qxk.html) 19 | + ARM/KEIL MDK, ARM Compiler 6 (ARM-CLANG) 20 | + IAR-ARM 21 | + GNU-ARM 22 | 23 | ## Documentation: 24 | 25 | Detailed documentation for these ports is available in the QP/C Manual at: 26 | 27 | - https://www.state-machine.com/qpcpp/arm-cm.html 28 | -------------------------------------------------------------------------------- /ports/arm-cm/qk/armclang/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/arm-cm/qk/gnu/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/arm-cm/qk/gnu/syscalls.c: -------------------------------------------------------------------------------- 1 | // dummy system calls to eliminate the following GNU linker warning: 2 | // "warning: xxxx is not implemented and will always fail" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | extern int __io_putchar(int ch) __attribute__((weak)); 14 | extern int __io_getchar(void) __attribute__((weak)); 15 | 16 | char *__env[1] = { 0 }; 17 | char **environ = __env; 18 | 19 | void initialise_monitor_handles() { 20 | } 21 | int _getpid(void) { 22 | return 1; 23 | } 24 | int _kill(int pid, int sig) { 25 | (void)pid; 26 | (void)sig; 27 | errno = EINVAL; 28 | return -1; 29 | } 30 | void _exit (int status) { 31 | _kill(status, -1); 32 | while (1) { // do not return 33 | } 34 | } 35 | __attribute__((weak)) int _read(int file, char *ptr, int len) { 36 | (void)file; 37 | for (int i = len; i != 0; --i) { 38 | *ptr++ = __io_getchar(); 39 | } 40 | return len; 41 | } 42 | __attribute__((weak)) int _write(int file, char *ptr, int len) { 43 | (void)file; 44 | for (int i = len; i != 0; --i) { 45 | __io_putchar(*ptr++); 46 | } 47 | return len; 48 | } 49 | int _close(int file) { 50 | (void)file; 51 | return -1; 52 | } 53 | int _fstat(int file, struct stat *st) { 54 | (void)file; 55 | st->st_mode = S_IFCHR; 56 | return 0; 57 | } 58 | int _isatty(int file) { 59 | (void)file; 60 | return 1; 61 | } 62 | int _lseek(int file, int ptr, int dir) { 63 | (void)file; 64 | (void)ptr; 65 | (void)dir; 66 | return 0; 67 | } 68 | int _open(char *path, int flags, ...) { 69 | (void)path; 70 | (void)flags; 71 | return -1; 72 | } 73 | int _wait(int *status) { 74 | (void)status; 75 | errno = ECHILD; 76 | return -1; 77 | } 78 | int _unlink(char *name) { 79 | (void)name; 80 | errno = ENOENT; 81 | return -1; 82 | } 83 | int _times(struct tms *buf) { 84 | (void)buf; 85 | return -1; 86 | } 87 | int _stat(char *file, struct stat *st) { 88 | (void)file; 89 | st->st_mode = S_IFCHR; 90 | return 0; 91 | } 92 | int _link(char *old, char *new) { 93 | (void)old; 94 | (void)new; 95 | errno = EMLINK; 96 | return -1; 97 | } 98 | int _fork(void) { 99 | errno = EAGAIN; 100 | return -1; 101 | } 102 | int _execve(char *name, char **argv, char **env) { 103 | (void)name; 104 | (void)argv; 105 | (void)env; 106 | errno = ENOMEM; 107 | return -1; 108 | } 109 | -------------------------------------------------------------------------------- /ports/arm-cm/qk/iar/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/arm-cm/qv/armclang/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/arm-cm/qv/gnu/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/arm-cm/qv/gnu/syscalls.c: -------------------------------------------------------------------------------- 1 | // dummy system calls to eliminate the following GNU linker warning: 2 | // "warning: xxxx is not implemented and will always fail" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | extern int __io_putchar(int ch) __attribute__((weak)); 14 | extern int __io_getchar(void) __attribute__((weak)); 15 | 16 | char *__env[1] = { 0 }; 17 | char **environ = __env; 18 | 19 | void initialise_monitor_handles() { 20 | } 21 | int _getpid(void) { 22 | return 1; 23 | } 24 | int _kill(int pid, int sig) { 25 | (void)pid; 26 | (void)sig; 27 | errno = EINVAL; 28 | return -1; 29 | } 30 | void _exit (int status) { 31 | _kill(status, -1); 32 | while (1) { // do not return 33 | } 34 | } 35 | __attribute__((weak)) int _read(int file, char *ptr, int len) { 36 | (void)file; 37 | for (int i = len; i != 0; --i) { 38 | *ptr++ = __io_getchar(); 39 | } 40 | return len; 41 | } 42 | __attribute__((weak)) int _write(int file, char *ptr, int len) { 43 | (void)file; 44 | for (int i = len; i != 0; --i) { 45 | __io_putchar(*ptr++); 46 | } 47 | return len; 48 | } 49 | int _close(int file) { 50 | (void)file; 51 | return -1; 52 | } 53 | int _fstat(int file, struct stat *st) { 54 | (void)file; 55 | st->st_mode = S_IFCHR; 56 | return 0; 57 | } 58 | int _isatty(int file) { 59 | (void)file; 60 | return 1; 61 | } 62 | int _lseek(int file, int ptr, int dir) { 63 | (void)file; 64 | (void)ptr; 65 | (void)dir; 66 | return 0; 67 | } 68 | int _open(char *path, int flags, ...) { 69 | (void)path; 70 | (void)flags; 71 | return -1; 72 | } 73 | int _wait(int *status) { 74 | (void)status; 75 | errno = ECHILD; 76 | return -1; 77 | } 78 | int _unlink(char *name) { 79 | (void)name; 80 | errno = ENOENT; 81 | return -1; 82 | } 83 | int _times(struct tms *buf) { 84 | (void)buf; 85 | return -1; 86 | } 87 | int _stat(char *file, struct stat *st) { 88 | (void)file; 89 | st->st_mode = S_IFCHR; 90 | return 0; 91 | } 92 | int _link(char *old, char *new) { 93 | (void)old; 94 | (void)new; 95 | errno = EMLINK; 96 | return -1; 97 | } 98 | int _fork(void) { 99 | errno = EAGAIN; 100 | return -1; 101 | } 102 | int _execve(char *name, char **argv, char **env) { 103 | (void)name; 104 | (void)argv; 105 | (void)env; 106 | errno = ENOMEM; 107 | return -1; 108 | } 109 | -------------------------------------------------------------------------------- /ports/arm-cm/qv/iar/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/arm-cr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ports/arm-cr 2 | string(TOLOWER ${CMAKE_C_COMPILER_ID} _compiler_) 3 | list (APPEND compList gnu iar ti) 4 | if(NOT (${_compiler_} IN_LIST compList)) 5 | message(WARNING "no support for compiler '${_compiler_}'. Falling back to GNU. Just give it a try :)") 6 | set(_compiler_ gnu) 7 | endif() 8 | unset(compList) 9 | 10 | if(NOT KERNEL MATCHES "q[vk]") 11 | message(WARNING "Kernel ${KERNEL} is not supported! Falling back to QV kernel") 12 | set(KERNEL qv) 13 | endif() 14 | target_include_directories(qpcpp PUBLIC ${KERNEL}/${_compiler_}) 15 | -------------------------------------------------------------------------------- /ports/arm-cr/qk/gnu/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/arm-cr/qk/iar/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/arm-cr/qk/ti/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/arm-cr/qv/gnu/qp_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QP_PORT_HPP_ 31 | #define QP_PORT_HPP_ 32 | 33 | #include // Exact-width types. C++11 Standard 34 | #include "qp_config.hpp" // QP configuration from the application 35 | 36 | // no-return function specifier (C++11 Standard) 37 | #define Q_NORETURN [[ noreturn ]] void 38 | 39 | // QF configuration for QV -- data members of the QActive class... 40 | 41 | // QV event-queue used for AOs 42 | #define QACTIVE_EQUEUE_TYPE QEQueue 43 | 44 | // QF interrupt disable/enable, see NOTE2 45 | #ifdef __thumb__ // THUMB mode? 46 | 47 | #define QF_INT_DISABLE() __asm volatile ("cpsid i") 48 | #define QF_INT_ENABLE() __asm volatile ("cpsie i") 49 | #define QF_INT_ENABLE_ALL() __asm volatile ("cpsie if") 50 | 51 | #elif (defined __arm__) // ARM mode? 52 | 53 | #define QF_INT_DISABLE() \ 54 | __asm volatile ("MSR cpsr_c,#(0x1F | 0x80)" ::: "cc") 55 | #define QF_INT_ENABLE() \ 56 | __asm volatile ("MSR cpsr_c,#(0x1F)" ::: "cc") 57 | #define QF_INT_ENABLE_ALL() \ 58 | __asm volatile ("MSR cpsr_c,#(0x1F)" ::: "cc") 59 | #else 60 | #error Incorrect CPU mode. Must be either __arm__ or __thumb__. 61 | #endif 62 | 63 | // Cortex-R provide the CLZ instruction for fast LOG2 64 | #define QF_LOG2(n_) (static_cast(32U - __builtin_clz(n_))) 65 | 66 | // QF critical section entry/exit, see NOTE3 67 | #define QF_CRIT_STAT std::uint32_t cpsr_; 68 | #define QF_CRIT_ENTRY() do { \ 69 | __asm volatile ("MRS %0,cpsr" : "=r" (cpsr_) :: "cc"); \ 70 | QF_INT_DISABLE(); \ 71 | } while (false) 72 | 73 | #define QF_CRIT_EXIT() \ 74 | __asm volatile ("MSR cpsr_c,%0" :: "r" (cpsr_) : "cc") 75 | 76 | #define QF_CRIT_EST() QF_INT_DISABLE() 77 | #define QF_CRIT_EXIT_NOP() __asm volatile ("ISB") 78 | 79 | // macro to put the CPU to sleep inside QV_onIdle() 80 | #define QV_CPU_SLEEP() do { \ 81 | __asm volatile ("WFI"); \ 82 | QF_INT_ENABLE(); \ 83 | } while (false) 84 | 85 | // include files ------------------------------------------------------------- 86 | #include "qequeue.hpp" // QV kernel uses the native QP event queue 87 | #include "qmpool.hpp" // QV kernel uses the native QP memory pool 88 | #include "qp.hpp" // QP framework 89 | #include "qv.hpp" // QV kernel 90 | 91 | //============================================================================ 92 | // NOTE2: 93 | // The FIQ-type interrupts are NEVER disabled in this port, so the FIQ is 94 | // a "kernel-unaware" interrupt. If the FIQ is ever used in the application, 95 | // it must be an "ARM FIQ"-type function. For this to work, the FIQ 96 | // stack needs to be initialized. 97 | // 98 | // NOTE3: 99 | // This port implements the "save and restore" interrupt status policy, 100 | // which again never disables the FIQ-type interrupts. This policy allows 101 | // for nesting critical sections, which is necessary inside IRQ-type 102 | // interrupts that run with interrupts (IRQ) disabled. 103 | // 104 | 105 | #endif // QP_PORT_HPP_ 106 | 107 | -------------------------------------------------------------------------------- /ports/arm-cr/qv/gnu/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/arm-cr/qv/iar/qp_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QP_PORT_HPP_ 31 | #define QP_PORT_HPP_ 32 | 33 | #include // Exact-width types. C++11 Standard 34 | #include // IAR intrinsic functions 35 | #include "qp_config.hpp" // QP configuration from the application 36 | 37 | // no-return function specifier (C++11 Standard) 38 | #define Q_NORETURN [[ noreturn ]] void 39 | 40 | // QF configuration for QV -- data members of the QActive class... 41 | 42 | // QV event-queue used for AOs 43 | #define QACTIVE_EQUEUE_TYPE QEQueue 44 | 45 | // QF interrupt disable/enable, see NOTE2 46 | #define QF_INT_DISABLE() __disable_irq() 47 | #define QF_INT_ENABLE() __enable_irq() 48 | #define QF_INT_ENABLE_ALL() __enable_interrupt() 49 | 50 | // Cortex-R provide the CLZ instruction for fast LOG2 51 | #define QF_LOG2(n_) (static_cast(32U - __CLZ(n_))) 52 | 53 | // QF critical section entry/exit, see NOTE3 54 | #define QF_CRIT_STAT std::uint32_t cpsr_; 55 | #define QF_CRIT_ENTRY() do { \ 56 | cpsr_ = __get_CPSR(); \ 57 | QF_INT_DISABLE(); \ 58 | } while (false) 59 | #define QF_CRIT_EXIT() __set_CPSR(cpsr_) 60 | #define QF_CRIT_EST() QF_INT_DISABLE() 61 | #define QF_CRIT_EXIT_NOP() __ISB() 62 | 63 | // macro to put the CPU to sleep inside QV_onIdle() 64 | #define QV_CPU_SLEEP() do { \ 65 | __WFI(); \ 66 | QF_INT_ENABLE(); \ 67 | } while (false) 68 | 69 | // include files ------------------------------------------------------------- 70 | #include "qequeue.hpp" // QV kernel uses the native QP event queue 71 | #include "qmpool.hpp" // QV kernel uses the native QP memory pool 72 | #include "qp.hpp" // QP framework 73 | #include "qv.hpp" // QV kernel 74 | 75 | //============================================================================ 76 | // NOTE2: 77 | // The FIQ-type interrupts are NEVER disabled in this port, so the FIQ is 78 | // a "kernel-unaware" interrupt. If the FIQ is ever used in the application, 79 | // it must be an "__arm __fiq"-type function. For this to work, the FIQ 80 | // stack needs to be initialized. 81 | // 82 | // NOTE3: 83 | // This port implements the "save and restore" interrupt status policy, 84 | // which again never disables the FIQ-type interrupts. This policy allows 85 | // for nesting critical sections, which is necessary inside IRQ-type 86 | // interrupts that run with interrupts (IRQ) disabled. 87 | // 88 | 89 | #endif // QP_PORT_HPP_ 90 | 91 | -------------------------------------------------------------------------------- /ports/arm-cr/qv/iar/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/arm-cr/qv/ti/qp_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QP_PORT_HPP_ 31 | #define QP_PORT_HPP_ 32 | 33 | #include // Exact-width types. C++11 Standard 34 | #include "qp_config.hpp" // QP configuration from the application 35 | 36 | // no-return function specifier (C++11 Standard) 37 | #define Q_NORETURN [[ noreturn ]] void 38 | 39 | // QF configuration for QV -- data members of the QActive class... 40 | 41 | // QV event-queue used for AOs 42 | #define QACTIVE_EQUEUE_TYPE QEQueue 43 | 44 | // QF interrupt disable/enable, see NOTE2 45 | #ifdef __16bis__ 46 | #define QF_INT_DISABLE() __asm(" CPSID i") 47 | #define QF_INT_ENABLE() __asm(" CPSIE i") 48 | #define QF_INT_ENABLE_ALL() __asm(" CPSIE if") 49 | #else 50 | #define QF_INT_DISABLE() _disable_IRQ() 51 | #define QF_INT_ENABLE() _enable_IRQ() 52 | #define QF_INT_ENABLE_ALL() _enable_interrupts() 53 | #endif 54 | 55 | // Cortex-R provide the CLZ instruction for fast LOG2 56 | #define QF_LOG2(n_) (static_cast(32U - __clz(n_))) 57 | 58 | // QF critical section entry/exit, see NOTE3 59 | #define QF_CRIT_STAT std::uint32_t cpsr_; 60 | #define QF_CRIT_ENTRY() do { \ 61 | cpsr_ = _get_CPSR(); \ 62 | QF_INT_DISABLE(); \ 63 | } while (false) 64 | #define QF_CRIT_EXIT() do { \ 65 | if ((cpsr_ & (1U << 7U)) == 0U) { \ 66 | QF_INT_ENABLE(); \ 67 | } \ 68 | } while (false) 69 | 70 | #define QF_CRIT_EST() QF_INT_DISABLE() 71 | #define QF_CRIT_EXIT_NOP() __asm(" ISB") 72 | 73 | // macro to put the CPU to sleep inside QV_onIdle() 74 | #define QV_CPU_SLEEP() do { \ 75 | __wfi(); \ 76 | QF_INT_ENABLE(); \ 77 | } while (false) 78 | 79 | // include files ------------------------------------------------------------- 80 | #include "qequeue.hpp" // QV kernel uses the native QP event queue 81 | #include "qmpool.hpp" // QV kernel uses the native QP memory pool 82 | #include "qp.hpp" // QP framework 83 | #include "qv.hpp" // QV kernel 84 | 85 | //============================================================================ 86 | // NOTE2: 87 | // The FIQ-type interrupts are NEVER disabled in this port, so the FIQ is 88 | // a "kernel-unaware" interrupt. If the FIQ is ever used in the application, 89 | // it must be an "ARM FIQ"-type function. For this to work, the FIQ 90 | // stack needs to be initialized. 91 | // 92 | // NOTE3: 93 | // This port implements the "save and restore" interrupt status policy, 94 | // which again never disables the FIQ-type interrupts. This policy allows 95 | // for nesting critical sections, which is necessary inside IRQ-type 96 | // interrupts that run with interrupts (IRQ) disabled. 97 | // 98 | 99 | #endif // QP_PORT_HPP_ 100 | 101 | -------------------------------------------------------------------------------- /ports/arm-cr/qv/ti/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/embos/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ports/embos 2 | target_include_directories(qpcpp PUBLIC .) 3 | target_sources(qpcpp PRIVATE qf_port.cpp) 4 | -------------------------------------------------------------------------------- /ports/embos/qp_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QP_PORT_HPP_ 31 | #define QP_PORT_HPP_ 32 | 33 | #include // Exact-width types. C++11 Standard 34 | #include "qp_config.hpp" // QP configuration from the application 35 | 36 | // no-return function specifier (C++11 Standard) 37 | #define Q_NORETURN [[ noreturn ]] void 38 | 39 | // QActive customization for embOS 40 | #define QACTIVE_EQUEUE_TYPE OS_MAILBOX 41 | #define QACTIVE_THREAD_TYPE OS_TASK 42 | #define QACTIVE_OS_OBJ_TYPE std::uint32_t 43 | 44 | // QF interrupt disable/enable 45 | #define QF_INT_DISABLE() OS_INT_IncDI() 46 | #define QF_INT_ENABLE() OS_INT_DecRI() 47 | 48 | // QF critical section for embOS, see NOTE2 49 | #define QF_CRIT_STAT 50 | #define QF_CRIT_ENTRY() QF_INT_DISABLE() 51 | #define QF_CRIT_EXIT() QF_INT_ENABLE() 52 | #define QF_CRIT_EST() QF_INT_DISABLE() 53 | 54 | // include files ------------------------------------------------------------- 55 | #include "RTOS.h" // embOS API 56 | 57 | #include "qequeue.hpp" // QP event queue (for deferring events) 58 | #include "qmpool.hpp" // QP memory pool (for event pools) 59 | #include "qp.hpp" // QP platform-independent public interface 60 | 61 | 62 | namespace QP { 63 | 64 | enum EmbOS_TaskAttrs { 65 | TASK_NAME_ATTR, 66 | TASK_USES_FPU 67 | }; 68 | 69 | } // namespace QP 70 | 71 | 72 | //============================================================================ 73 | // interface used only inside QF, but not in applications 74 | 75 | #ifdef QP_IMPL 76 | 77 | // embOS-specific scheduler locking, see NOTE3 78 | #define QF_SCHED_STAT_ 79 | #define QF_SCHED_LOCK_(dummy) do { \ 80 | if (OS_INT_InInterrupt() == static_cast(0)) { \ 81 | OS_TASK_EnterRegion(); \ 82 | } \ 83 | } while (false) 84 | 85 | #define QF_SCHED_UNLOCK_() do { \ 86 | if (OS_INT_InInterrupt() == static_cast(0)) { \ 87 | OS_TASK_LeaveRegion(); \ 88 | } \ 89 | } while (false) 90 | 91 | // native QF event pool customization 92 | #define QF_EPOOL_TYPE_ QMPool 93 | #define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \ 94 | (p_).init((poolSto_), (poolSize_), (evtSize_)) 95 | #define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize()) 96 | #define QF_EPOOL_GET_(p_, e_, m_, qsId_) \ 97 | ((e_) = static_cast((p_).get((m_), (qsId_)))) 98 | #define QF_EPOOL_PUT_(p_, e_, qsId_) ((p_).put((e_), (qsId_))) 99 | 100 | #endif // QP_IMPL 101 | 102 | //============================================================================ 103 | // NOTE2: 104 | // The embOS critical section does not use the status variable, because the 105 | // implementation uses a global up-down counter, which allows the embOS 106 | // critical section to nest. Nesting of critical sections is needed in this 107 | // QP-embOS port. 108 | // 109 | // NOTE3: 110 | // embOS provides only global scheduler locking for all thread priorities 111 | // by means of OS_EnterRegion() and OS_LeaveRegion(). Therefore, locking the 112 | // scheduler only up to the specified lock priority is not supported. 113 | // 114 | 115 | #endif // QP_PORT_HPP_ 116 | 117 | -------------------------------------------------------------------------------- /ports/embos/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/embos/syscalls.c: -------------------------------------------------------------------------------- 1 | // dummy system calls to eliminate the following GNU linker warning: 2 | // "warning: xxxx is not implemented and will always fail" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | extern int __io_putchar(int ch) __attribute__((weak)); 14 | extern int __io_getchar(void) __attribute__((weak)); 15 | 16 | char *__env[1] = { 0 }; 17 | char **environ = __env; 18 | 19 | void initialise_monitor_handles() { 20 | } 21 | int _getpid(void) { 22 | return 1; 23 | } 24 | int _kill(int pid, int sig) { 25 | (void)pid; 26 | (void)sig; 27 | errno = EINVAL; 28 | return -1; 29 | } 30 | void _exit (int status) { 31 | _kill(status, -1); 32 | while (1) { // do not return 33 | } 34 | } 35 | __attribute__((weak)) int _read(int file, char *ptr, int len) { 36 | (void)file; 37 | for (int i = len; i != 0; --i) { 38 | *ptr++ = __io_getchar(); 39 | } 40 | return len; 41 | } 42 | __attribute__((weak)) int _write(int file, char *ptr, int len) { 43 | (void)file; 44 | for (int i = len; i != 0; --i) { 45 | __io_putchar(*ptr++); 46 | } 47 | return len; 48 | } 49 | int _close(int file) { 50 | (void)file; 51 | return -1; 52 | } 53 | int _fstat(int file, struct stat *st) { 54 | (void)file; 55 | st->st_mode = S_IFCHR; 56 | return 0; 57 | } 58 | int _isatty(int file) { 59 | (void)file; 60 | return 1; 61 | } 62 | int _lseek(int file, int ptr, int dir) { 63 | (void)file; 64 | (void)ptr; 65 | (void)dir; 66 | return 0; 67 | } 68 | int _open(char *path, int flags, ...) { 69 | (void)path; 70 | (void)flags; 71 | return -1; 72 | } 73 | int _wait(int *status) { 74 | (void)status; 75 | errno = ECHILD; 76 | return -1; 77 | } 78 | int _unlink(char *name) { 79 | (void)name; 80 | errno = ENOENT; 81 | return -1; 82 | } 83 | int _times(struct tms *buf) { 84 | (void)buf; 85 | return -1; 86 | } 87 | int _stat(char *file, struct stat *st) { 88 | (void)file; 89 | st->st_mode = S_IFCHR; 90 | return 0; 91 | } 92 | int _link(char *old, char *new) { 93 | (void)old; 94 | (void)new; 95 | errno = EMLINK; 96 | return -1; 97 | } 98 | int _fork(void) { 99 | errno = EAGAIN; 100 | return -1; 101 | } 102 | int _execve(char *name, char **argv, char **env) { 103 | (void)name; 104 | (void)argv; 105 | (void)env; 106 | errno = ENOMEM; 107 | return -1; 108 | } 109 | -------------------------------------------------------------------------------- /ports/freertos/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ports/freertos 2 | target_include_directories(qpcpp PUBLIC .) 3 | target_sources(qpcpp PRIVATE qf_port.cpp) 4 | -------------------------------------------------------------------------------- /ports/freertos/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 4U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 4U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/freertos/syscalls.c: -------------------------------------------------------------------------------- 1 | // dummy system calls to eliminate the following GNU linker warning: 2 | // "warning: xxxx is not implemented and will always fail" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | extern int __io_putchar(int ch) __attribute__((weak)); 14 | extern int __io_getchar(void) __attribute__((weak)); 15 | 16 | char *__env[1] = { 0 }; 17 | char **environ = __env; 18 | 19 | void initialise_monitor_handles() { 20 | } 21 | int _getpid(void) { 22 | return 1; 23 | } 24 | int _kill(int pid, int sig) { 25 | (void)pid; 26 | (void)sig; 27 | errno = EINVAL; 28 | return -1; 29 | } 30 | void _exit (int status) { 31 | _kill(status, -1); 32 | while (1) { // do not return 33 | } 34 | } 35 | __attribute__((weak)) int _read(int file, char *ptr, int len) { 36 | (void)file; 37 | for (int i = len; i != 0; --i) { 38 | *ptr++ = __io_getchar(); 39 | } 40 | return len; 41 | } 42 | __attribute__((weak)) int _write(int file, char *ptr, int len) { 43 | (void)file; 44 | for (int i = len; i != 0; --i) { 45 | __io_putchar(*ptr++); 46 | } 47 | return len; 48 | } 49 | int _close(int file) { 50 | (void)file; 51 | return -1; 52 | } 53 | int _fstat(int file, struct stat *st) { 54 | (void)file; 55 | st->st_mode = S_IFCHR; 56 | return 0; 57 | } 58 | int _isatty(int file) { 59 | (void)file; 60 | return 1; 61 | } 62 | int _lseek(int file, int ptr, int dir) { 63 | (void)file; 64 | (void)ptr; 65 | (void)dir; 66 | return 0; 67 | } 68 | int _open(char *path, int flags, ...) { 69 | (void)path; 70 | (void)flags; 71 | return -1; 72 | } 73 | int _wait(int *status) { 74 | (void)status; 75 | errno = ECHILD; 76 | return -1; 77 | } 78 | int _unlink(char *name) { 79 | (void)name; 80 | errno = ENOENT; 81 | return -1; 82 | } 83 | int _times(struct tms *buf) { 84 | (void)buf; 85 | return -1; 86 | } 87 | int _stat(char *file, struct stat *st) { 88 | (void)file; 89 | st->st_mode = S_IFCHR; 90 | return 0; 91 | } 92 | int _link(char *old, char *new) { 93 | (void)old; 94 | (void)new; 95 | errno = EMLINK; 96 | return -1; 97 | } 98 | int _fork(void) { 99 | errno = EAGAIN; 100 | return -1; 101 | } 102 | int _execve(char *name, char **argv, char **env) { 103 | (void)name; 104 | (void)argv; 105 | (void)env; 106 | errno = ENOMEM; 107 | return -1; 108 | } 109 | -------------------------------------------------------------------------------- /ports/msp430/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ports/msp430 2 | if(QPCPP_CFG_UNIT_TEST) 3 | target_include_directories(qpcpp PUBLIC qutest) 4 | else() 5 | if(NOT KERNEL MATCHES "q[vk]") 6 | message(WARNING "Kernel ${KERNEL} is not supported! Falling back to QV kernel") 7 | set(KERNEL qv) 8 | endif() 9 | target_include_directories(qpcpp PUBLIC ${KERNEL}) 10 | endif() 11 | -------------------------------------------------------------------------------- /ports/msp430/README.md: -------------------------------------------------------------------------------- 1 | # MSP430 Port 2 | 3 | Documentation for this port is available in the QP/C Manual at: 4 | 5 | - https://www.state-machine.com/qpcpp/msp430.html 6 | -------------------------------------------------------------------------------- /ports/msp430/qk/qp_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QP_PORT_HPP_ 31 | #define QP_PORT_HPP_ 32 | 33 | #include // Exact-width types. C++11 Standard 34 | #include "qp_config.hpp" // QP configuration from the application 35 | 36 | // no-return function specifier (C++11 Standard) 37 | #define Q_NORETURN [[ noreturn ]] void 38 | 39 | // QF configuration for QK -- data members of the QActive class... 40 | 41 | // QActive event queue type 42 | #define QACTIVE_EQUEUE_TYPE QEQueue 43 | // QACTIVE_OS_OBJ_TYPE not used in this port 44 | // QACTIVE_THREAD_TYPE not used in this port 45 | 46 | // QF interrupt disable/enable... 47 | #define QF_INT_DISABLE() __disable_interrupt() 48 | #define QF_INT_ENABLE() __enable_interrupt() 49 | 50 | // QF critical section entry/exit... 51 | #define QF_CRIT_STAT unsigned short int_state_; 52 | #define QF_CRIT_ENTRY() do { \ 53 | int_state_ = __get_interrupt_state(); \ 54 | __disable_interrupt(); \ 55 | } while (false) 56 | 57 | #define QF_CRIT_EST() __disable_interrupt() 58 | #define QF_CRIT_EXIT() __set_interrupt_state(int_state_) 59 | 60 | // Check if the code executes in the ISR context 61 | #define QK_ISR_CONTEXT_() (QK_priv_.intNest != 0U) 62 | 63 | // QK interrupt entry and exit... 64 | #define QK_ISR_ENTRY() (++QK_priv_.intNest) 65 | 66 | #define QK_ISR_EXIT() do { \ 67 | --QK_priv_.intNest; \ 68 | if (QK_priv_.intNest == 0U) { \ 69 | if (QK_sched_() != 0U) { \ 70 | QK_activate_(); \ 71 | } \ 72 | } \ 73 | } while (false) 74 | 75 | // include files ------------------------------------------------------------- 76 | #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) 77 | #include 78 | #elif defined(__GNUC__) 79 | #include 80 | #include "in430.h" 81 | #endif 82 | 83 | #include "qequeue.hpp" // QK kernel uses the native QP event queue 84 | #include "qmpool.hpp" // QK kernel uses the native QP memory pool 85 | #include "qp.hpp" // QP framework 86 | #include "qk.hpp" // QK kernel 87 | 88 | #endif // QP_PORT_HPP_ 89 | 90 | -------------------------------------------------------------------------------- /ports/msp430/qk/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 2U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 2U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/msp430/qutest/qp_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: LicenseRef-QL-commercial 11 | // 12 | // This software is licensed under the terms of the Quantum Leaps commercial 13 | // licenses. Please contact Quantum Leaps for more information about the 14 | // available licensing options. 15 | // 16 | // RESTRICTIONS 17 | // You may NOT : 18 | // (a) redistribute, encumber, sell, rent, lease, sublicense, or otherwise 19 | // transfer rights in this software, 20 | // (b) remove or alter any trademark, logo, copyright or other proprietary 21 | // notices, legends, symbols or labels present in this software, 22 | // (c) plagiarize this software to sidestep the licensing obligations. 23 | // 24 | // Quantum Leaps contact information: 25 | // 26 | // 27 | //============================================================================ 28 | #ifndef QP_PORT_HPP_ 29 | #define QP_PORT_HPP_ 30 | 31 | #include // Exact-width types. C++11 Standard 32 | #include "qp_config.hpp" // QP configuration from the application 33 | 34 | // no-return function specifier (C++11 Standard) 35 | #define Q_NORETURN [[ noreturn ]] void 36 | 37 | // QActive event queue type 38 | #define QACTIVE_EQUEUE_TYPE QEQueue 39 | // QACTIVE_OS_OBJ_TYPE not used in this port 40 | // QACTIVE_THREAD_TYPE not used in this port 41 | 42 | // QF critical section 43 | #define QF_CRIT_STAT QP::QF::QCritStatus critStat_; 44 | #define QF_CRIT_ENTRY() (critStat_ = QP::QF::critEntry()) 45 | #define QF_CRIT_EXIT() (QP::QF::critExit(critStat_)) 46 | #define QF_CRIT_EST() static_cast(QP::QF::critEntry()) 47 | 48 | // QF_LOG2 not defined -- use the internal LOG2() implementation 49 | 50 | // include files ------------------------------------------------------------- 51 | #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) 52 | #include 53 | #elif defined(__GNUC__) 54 | #include 55 | #include "in430.h" 56 | #endif 57 | 58 | #include "qequeue.hpp" // QUTest port uses QEQueue event-queue 59 | #include "qmpool.hpp" // QUTest port uses QMPool memory-pool 60 | #include "qp.hpp" // QP platform-independent public interface 61 | 62 | //============================================================================ 63 | // interface used only inside QF implementation, but not in applications 64 | 65 | #ifdef QP_IMPL 66 | 67 | // QUTest scheduler locking 68 | #define QF_SCHED_STAT_ QP::QF::QSchedStatus lockStat_; 69 | #define QF_SCHED_LOCK_(ceil_) (lockStat_ = QP::QF::schedLock((ceil_))) 70 | #define QF_SCHED_UNLOCK_() (QP::QF::schedUnlock(lockStat_)) 71 | 72 | // native QEQueue operations 73 | #define QACTIVE_EQUEUE_WAIT_(me_) (static_cast(0)) 74 | #define QACTIVE_EQUEUE_SIGNAL_(me_) \ 75 | (QP::QS::tstPriv_.readySet.insert( \ 76 | static_cast((me_)->m_prio))) 77 | 78 | // native QMPool operations 79 | #define QF_EPOOL_TYPE_ QMPool 80 | #define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \ 81 | (p_).init((poolSto_), (poolSize_), (evtSize_)) 82 | #define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize()) 83 | #define QF_EPOOL_GET_(p_, e_, m_, qsId_) \ 84 | ((e_) = static_cast((p_).get((m_), (qsId_)))) 85 | #define QF_EPOOL_PUT_(p_, e_, qsId_) ((p_).put((e_), (qsId_))) 86 | 87 | #endif // QP_IMPL 88 | 89 | #endif // QP_PORT_HPP_ 90 | 91 | -------------------------------------------------------------------------------- /ports/msp430/qutest/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 2U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 2U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/msp430/qv/qp_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QP_PORT_HPP_ 31 | #define QP_PORT_HPP_ 32 | 33 | #include // Exact-width types. C++11 Standard 34 | #include "qp_config.hpp" // QP configuration from the application 35 | 36 | // no-return function specifier (C++11 Standard) 37 | #define Q_NORETURN [[ noreturn ]] void 38 | 39 | // QF configuration for QK -- data members of the QActive class... 40 | 41 | // QActive event queue type 42 | #define QACTIVE_EQUEUE_TYPE QEQueue 43 | // QACTIVE_OS_OBJ_TYPE not used in this port 44 | // QACTIVE_THREAD_TYPE not used in this port 45 | 46 | // QF interrupt disable/enable... 47 | #define QF_INT_DISABLE() __disable_interrupt() 48 | #define QF_INT_ENABLE() __enable_interrupt() 49 | 50 | // QF critical section entry/exit... 51 | #define QF_CRIT_STAT unsigned short int_state_; 52 | #define QF_CRIT_ENTRY() do { \ 53 | int_state_ = __get_interrupt_state(); \ 54 | __disable_interrupt(); \ 55 | } while (false) 56 | 57 | #define QF_CRIT_EST() __disable_interrupt() 58 | #define QF_CRIT_EXIT() __set_interrupt_state(int_state_) 59 | 60 | // include files ------------------------------------------------------------- 61 | #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) 62 | #include 63 | #elif defined(__GNUC__) 64 | #include 65 | #include "in430.h" 66 | #endif 67 | 68 | #include "qequeue.hpp" // QV kernel uses the native QP event queue 69 | #include "qmpool.hpp" // QV kernel uses the native QP memory pool 70 | #include "qp.hpp" // QP framework 71 | #include "qv.hpp" // QV kernel 72 | 73 | #endif // QP_PORT_HPP_ 74 | 75 | -------------------------------------------------------------------------------- /ports/msp430/qv/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | // object pointer size in bytes 34 | #define QS_OBJ_PTR_SIZE 2U 35 | 36 | // function pointer size in bytes 37 | #define QS_FUN_PTR_SIZE 2U 38 | 39 | //============================================================================ 40 | // NOTE: QS might be used with or without other QP components, in which 41 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 42 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 43 | // with the other QP component, by simply including "qp_port.hpp" 44 | // *before* "qs.hpp". 45 | #ifndef QP_PORT_HPP_ 46 | #include "qp_port.hpp" // use QS with QP 47 | #endif 48 | 49 | #include "qs.hpp" // QS platform-independent public interface 50 | 51 | #endif // QS_PORT_HPP_ 52 | -------------------------------------------------------------------------------- /ports/posix-qv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ports/posix-qv 2 | target_include_directories(qpcpp PUBLIC .) 3 | target_sources(qpcpp PRIVATE 4 | qf_port.cpp 5 | $<$:${CMAKE_CURRENT_SOURCE_DIR}/qs_port.cpp> 6 | ) -------------------------------------------------------------------------------- /ports/posix-qv/README.md: -------------------------------------------------------------------------------- 1 | # POSIX (single-threaded) 2 | 3 | Documentation for this port is available in the QP/C Manual at: 4 | 5 | - https://www.state-machine.com/qpcpp/posix-qv.html 6 | -------------------------------------------------------------------------------- /ports/posix-qv/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | #if defined(_WIN64) || defined(__LP64__) || defined(_LP64) // 64-bit OS? 34 | #define QS_OBJ_PTR_SIZE 8U 35 | #define QS_FUN_PTR_SIZE 8U 36 | #else // 32-bit OS 37 | #define QS_OBJ_PTR_SIZE 4U 38 | #define QS_FUN_PTR_SIZE 4U 39 | #endif 40 | 41 | namespace QP { 42 | void QS_output(void); // handle the QS output 43 | void QS_rx_input(void); // handle the QS-RX input 44 | } 45 | 46 | //============================================================================ 47 | // NOTE: QS might be used with or without other QP components, in which 48 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 49 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 50 | // with the other QP component, by simply including "qp_port.hpp" 51 | // *before* "qs.hpp". 52 | #ifndef QP_PORT_HPP_ 53 | #include "qp_port.hpp" // use QS with QP 54 | #endif 55 | 56 | #include "qs.hpp" // QS platform-independent public interface 57 | 58 | #endif // QS_PORT_HPP_ 59 | -------------------------------------------------------------------------------- /ports/posix-qv/safe_std.h: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // SafeQP/C++ Real-Time Event Framework (RTEF) 3 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 4 | // 5 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 6 | // 7 | // This software is dual-licensed under the terms of the open source GNU 8 | // General Public License version 3 (or any later version), or alternatively, 9 | // under the terms of one of the closed source Quantum Leaps commercial 10 | // licenses. 11 | // 12 | // The terms of the open source GNU General Public License version 3 13 | // can be found at: 14 | // 15 | // The terms of the closed source Quantum Leaps commercial licenses 16 | // can be found at: 17 | // 18 | // Redistributions in source code must retain this top-level comment block. 19 | // Plagiarizing this software to sidestep the license obligations is illegal. 20 | // 21 | // Contact information: 22 | // 23 | // 24 | //============================================================================ 25 | #ifndef SAFE_STD_H 26 | #define SAFE_STD_H 27 | 28 | #include 29 | #include 30 | 31 | // portable "safe" facilities from and ................ 32 | #ifdef _WIN32 // Windows OS? 33 | 34 | #define MEMMOVE_S(dest_, num_, src_, count_) \ 35 | memmove_s(dest_, num_, src_, count_) 36 | 37 | #define STRNCPY_S(dest_, destsiz_, src_) \ 38 | strncpy_s(dest_, destsiz_, src_, _TRUNCATE) 39 | 40 | #define STRCAT_S(dest_, destsiz_, src_) \ 41 | strcat_s(dest_, destsiz_, src_) 42 | 43 | #define SNPRINTF_S(buf_, bufsiz_, format_, ...) \ 44 | _snprintf_s(buf_, bufsiz_, _TRUNCATE, format_, __VA_ARGS__) 45 | 46 | #define PRINTF_S(format_, ...) \ 47 | printf_s(format_, __VA_ARGS__) 48 | 49 | #define FPRINTF_S(fp_, format_, ...) \ 50 | fprintf_s(fp_, format_, __VA_ARGS__) 51 | 52 | #ifdef _MSC_VER 53 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 54 | fread_s(buf_, bufsiz_, elsiz_, count_, fp_) 55 | #else 56 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 57 | fread(buf_, elsiz_, count_, fp_) 58 | #endif // _MSC_VER 59 | 60 | #define FOPEN_S(fp_, fName_, mode_) \ 61 | if (fopen_s(&fp_, fName_, mode_) != 0) { \ 62 | fp_ = (FILE *)0; \ 63 | } else (void)0 64 | 65 | #define LOCALTIME_S(tm_, time_) \ 66 | localtime_s(tm_, time_) 67 | 68 | #else // other OS (Linux, MacOS, etc.) ..................................... 69 | 70 | #define MEMMOVE_S(dest_, num_, src_, count_) \ 71 | memmove(dest_, src_, count_) 72 | 73 | #define STRNCPY_S(dest_, destsiz_, src_) do { \ 74 | strncpy(dest_, src_, destsiz_); \ 75 | dest_[(destsiz_) - 1] = '\0'; \ 76 | } while (false) 77 | 78 | #define STRCAT_S(dest_, destsiz_, src_) \ 79 | strcat(dest_, src_) 80 | 81 | #define SNPRINTF_S(buf_, bufsiz_, format_, ...) \ 82 | snprintf(buf_, bufsiz_, format_, __VA_ARGS__) 83 | 84 | #define PRINTF_S(format_, ...) \ 85 | printf(format_, __VA_ARGS__) 86 | 87 | #define FPRINTF_S(fp_, format_, ...) \ 88 | fprintf(fp_, format_, __VA_ARGS__) 89 | 90 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 91 | fread(buf_, elsiz_, count_, fp_) 92 | 93 | #define FOPEN_S(fp_, fName_, mode_) \ 94 | (fp_ = fopen(fName_, mode_)) 95 | 96 | #define LOCALTIME_S(tm_, time_) \ 97 | memcpy(tm_, localtime(time_), sizeof(struct tm)) 98 | 99 | #endif // _WIN32 100 | 101 | #endif // SAFE_STD_H 102 | -------------------------------------------------------------------------------- /ports/posix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ports/posix 2 | target_include_directories(qpcpp PUBLIC .) 3 | target_sources(qpcpp PRIVATE 4 | qf_port.cpp 5 | $<$:${CMAKE_CURRENT_SOURCE_DIR}/qs_port.cpp> 6 | ) -------------------------------------------------------------------------------- /ports/posix/README.md: -------------------------------------------------------------------------------- 1 | # POSIX (multi-threaded with p-threads) 2 | 3 | Documentation for this port is available in the QP/C Manual at: 4 | 5 | - https://www.state-machine.com/qpcpp/posix.html 6 | -------------------------------------------------------------------------------- /ports/posix/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | #if defined(_WIN64) || defined(__LP64__) || defined(_LP64) // 64-bit OS? 34 | #define QS_OBJ_PTR_SIZE 8U 35 | #define QS_FUN_PTR_SIZE 8U 36 | #else // 32-bit OS 37 | #define QS_OBJ_PTR_SIZE 4U 38 | #define QS_FUN_PTR_SIZE 4U 39 | #endif 40 | 41 | namespace QP { 42 | void QS_output(void); // handle the QS output 43 | void QS_rx_input(void); // handle the QS-RX input 44 | } 45 | 46 | //============================================================================ 47 | // NOTE: QS might be used with or without other QP components, in which 48 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 49 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 50 | // with the other QP component, by simply including "qp_port.hpp" 51 | // *before* "qs.hpp". 52 | #ifndef QP_PORT_HPP_ 53 | #include "qp_port.hpp" // use QS with QP 54 | #endif 55 | 56 | #include "qs.hpp" // QS platform-independent public interface 57 | 58 | #endif // QS_PORT_HPP_ 59 | -------------------------------------------------------------------------------- /ports/posix/safe_std.h: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // SafeQP/C++ Real-Time Event Framework (RTEF) 3 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 4 | // 5 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 6 | // 7 | // This software is dual-licensed under the terms of the open source GNU 8 | // General Public License version 3 (or any later version), or alternatively, 9 | // under the terms of one of the closed source Quantum Leaps commercial 10 | // licenses. 11 | // 12 | // The terms of the open source GNU General Public License version 3 13 | // can be found at: 14 | // 15 | // The terms of the closed source Quantum Leaps commercial licenses 16 | // can be found at: 17 | // 18 | // Redistributions in source code must retain this top-level comment block. 19 | // Plagiarizing this software to sidestep the license obligations is illegal. 20 | // 21 | // Contact information: 22 | // 23 | // 24 | //============================================================================ 25 | #ifndef SAFE_STD_H 26 | #define SAFE_STD_H 27 | 28 | #include 29 | #include 30 | 31 | // portable "safe" facilities from and ................ 32 | #ifdef _WIN32 // Windows OS? 33 | 34 | #define MEMMOVE_S(dest_, num_, src_, count_) \ 35 | memmove_s(dest_, num_, src_, count_) 36 | 37 | #define STRNCPY_S(dest_, destsiz_, src_) \ 38 | strncpy_s(dest_, destsiz_, src_, _TRUNCATE) 39 | 40 | #define STRCAT_S(dest_, destsiz_, src_) \ 41 | strcat_s(dest_, destsiz_, src_) 42 | 43 | #define SNPRINTF_S(buf_, bufsiz_, format_, ...) \ 44 | _snprintf_s(buf_, bufsiz_, _TRUNCATE, format_, __VA_ARGS__) 45 | 46 | #define PRINTF_S(format_, ...) \ 47 | printf_s(format_, __VA_ARGS__) 48 | 49 | #define FPRINTF_S(fp_, format_, ...) \ 50 | fprintf_s(fp_, format_, __VA_ARGS__) 51 | 52 | #ifdef _MSC_VER 53 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 54 | fread_s(buf_, bufsiz_, elsiz_, count_, fp_) 55 | #else 56 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 57 | fread(buf_, elsiz_, count_, fp_) 58 | #endif // _MSC_VER 59 | 60 | #define FOPEN_S(fp_, fName_, mode_) \ 61 | if (fopen_s(&fp_, fName_, mode_) != 0) { \ 62 | fp_ = (FILE *)0; \ 63 | } else (void)0 64 | 65 | #define LOCALTIME_S(tm_, time_) \ 66 | localtime_s(tm_, time_) 67 | 68 | #else // other OS (Linux, MacOS, etc.) ..................................... 69 | 70 | #define MEMMOVE_S(dest_, num_, src_, count_) \ 71 | memmove(dest_, src_, count_) 72 | 73 | #define STRNCPY_S(dest_, destsiz_, src_) do { \ 74 | strncpy(dest_, src_, destsiz_); \ 75 | dest_[(destsiz_) - 1] = '\0'; \ 76 | } while (false) 77 | 78 | #define STRCAT_S(dest_, destsiz_, src_) \ 79 | strcat(dest_, src_) 80 | 81 | #define SNPRINTF_S(buf_, bufsiz_, format_, ...) \ 82 | snprintf(buf_, bufsiz_, format_, __VA_ARGS__) 83 | 84 | #define PRINTF_S(format_, ...) \ 85 | printf(format_, __VA_ARGS__) 86 | 87 | #define FPRINTF_S(fp_, format_, ...) \ 88 | fprintf(fp_, format_, __VA_ARGS__) 89 | 90 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 91 | fread(buf_, elsiz_, count_, fp_) 92 | 93 | #define FOPEN_S(fp_, fName_, mode_) \ 94 | (fp_ = fopen(fName_, mode_)) 95 | 96 | #define LOCALTIME_S(tm_, time_) \ 97 | memcpy(tm_, localtime(time_), sizeof(struct tm)) 98 | 99 | #endif // _WIN32 100 | 101 | #endif // SAFE_STD_H 102 | -------------------------------------------------------------------------------- /ports/qep-only/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ports/qep-only 2 | target_include_directories(qpcpp PUBLIC .) 3 | -------------------------------------------------------------------------------- /ports/qep-only/qp_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL (see ) does NOT permit the 21 | // incorporation of the QP/C++ software into proprietary programs. Please 22 | // contact Quantum Leaps for commercial licensing options, which expressly 23 | // supersede the GPL and are designed explicitly for licensees interested 24 | // in using QP/C++ in closed-source proprietary applications. 25 | // 26 | // Quantum Leaps contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QP_PORT_HPP_ 31 | #define QP_PORT_HPP_ 32 | 33 | // no-return function specifier (C++11 Standard) 34 | #define Q_NORETURN [[ noreturn ]] void 35 | 36 | // include files ------------------------------------------------------------- 37 | #include // Exact-width types. C++11 Standard 38 | #include "qp_config.hpp" // QP configuration from the application 39 | #include "qp.hpp" // QP platform-independent public interface 40 | 41 | #endif // QP_PORT_HPP_ 42 | -------------------------------------------------------------------------------- /ports/qep-only/safe_std.h: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // SafeQP/C++ Real-Time Event Framework (RTEF) 3 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 4 | // 5 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 6 | // 7 | // This software is dual-licensed under the terms of the open source GNU 8 | // General Public License version 3 (or any later version), or alternatively, 9 | // under the terms of one of the closed source Quantum Leaps commercial 10 | // licenses. 11 | // 12 | // The terms of the open source GNU General Public License version 3 13 | // can be found at: 14 | // 15 | // The terms of the closed source Quantum Leaps commercial licenses 16 | // can be found at: 17 | // 18 | // Redistributions in source code must retain this top-level comment block. 19 | // Plagiarizing this software to sidestep the license obligations is illegal. 20 | // 21 | // Contact information: 22 | // 23 | // 24 | //============================================================================ 25 | #ifndef SAFE_STD_H 26 | #define SAFE_STD_H 27 | 28 | #include 29 | #include 30 | 31 | // portable "safe" facilities from and ................ 32 | #ifdef _WIN32 // Windows OS? 33 | 34 | #define MEMMOVE_S(dest_, num_, src_, count_) \ 35 | memmove_s(dest_, num_, src_, count_) 36 | 37 | #define STRNCPY_S(dest_, destsiz_, src_) \ 38 | strncpy_s(dest_, destsiz_, src_, _TRUNCATE) 39 | 40 | #define STRCAT_S(dest_, destsiz_, src_) \ 41 | strcat_s(dest_, destsiz_, src_) 42 | 43 | #define SNPRINTF_S(buf_, bufsiz_, format_, ...) \ 44 | _snprintf_s(buf_, bufsiz_, _TRUNCATE, format_, __VA_ARGS__) 45 | 46 | #define PRINTF_S(format_, ...) \ 47 | printf_s(format_, __VA_ARGS__) 48 | 49 | #define FPRINTF_S(fp_, format_, ...) \ 50 | fprintf_s(fp_, format_, __VA_ARGS__) 51 | 52 | #ifdef _MSC_VER 53 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 54 | fread_s(buf_, bufsiz_, elsiz_, count_, fp_) 55 | #else 56 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 57 | fread(buf_, elsiz_, count_, fp_) 58 | #endif // _MSC_VER 59 | 60 | #define FOPEN_S(fp_, fName_, mode_) \ 61 | if (fopen_s(&fp_, fName_, mode_) != 0) { \ 62 | fp_ = (FILE *)0; \ 63 | } else (void)0 64 | 65 | #define LOCALTIME_S(tm_, time_) \ 66 | localtime_s(tm_, time_) 67 | 68 | #else // other OS (Linux, MacOS, etc.) ..................................... 69 | 70 | #define MEMMOVE_S(dest_, num_, src_, count_) \ 71 | memmove(dest_, src_, count_) 72 | 73 | #define STRNCPY_S(dest_, destsiz_, src_) do { \ 74 | strncpy(dest_, src_, destsiz_); \ 75 | dest_[(destsiz_) - 1] = '\0'; \ 76 | } while (false) 77 | 78 | #define STRCAT_S(dest_, destsiz_, src_) \ 79 | strcat(dest_, src_) 80 | 81 | #define SNPRINTF_S(buf_, bufsiz_, format_, ...) \ 82 | snprintf(buf_, bufsiz_, format_, __VA_ARGS__) 83 | 84 | #define PRINTF_S(format_, ...) \ 85 | printf(format_, __VA_ARGS__) 86 | 87 | #define FPRINTF_S(fp_, format_, ...) \ 88 | fprintf(fp_, format_, __VA_ARGS__) 89 | 90 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 91 | fread(buf_, elsiz_, count_, fp_) 92 | 93 | #define FOPEN_S(fp_, fName_, mode_) \ 94 | (fp_ = fopen(fName_, mode_)) 95 | 96 | #define LOCALTIME_S(tm_, time_) \ 97 | memcpy(tm_, localtime(time_), sizeof(struct tm)) 98 | 99 | #endif // _WIN32 100 | 101 | #endif // SAFE_STD_H 102 | -------------------------------------------------------------------------------- /ports/threadx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ports/os_xxx 2 | target_include_directories(qpcpp PUBLIC .) 3 | target_sources(qpcpp PRIVATE qf_port.cpp) 4 | -------------------------------------------------------------------------------- /ports/threadx/README.md: -------------------------------------------------------------------------------- 1 | # ThreadX Port 2 | 3 | Documentation for this port is available in the QP/C Manual at: 4 | 5 | - https://www.state-machine.com/qpcpp/threadx.html 6 | -------------------------------------------------------------------------------- /ports/threadx/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 3 | // 4 | // Q u a n t u m L e a P s 5 | // ------------------------ 6 | // Modern Embedded Software 7 | // 8 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 9 | // 10 | // This software is dual-licensed under the terms of the open-source GNU 11 | // General Public License (GPL) or under the terms of one of the closed- 12 | // source Quantum Leaps commercial licenses. 13 | // 14 | // Redistributions in source code must retain this top-level comment block. 15 | // Plagiarizing this software to sidestep the license obligations is illegal. 16 | // 17 | // NOTE: 18 | // The GPL (see ) does NOT permit the 19 | // incorporation of the QP/C++ software into proprietary programs. Please 20 | // contact Quantum Leaps for commercial licensing options, which expressly 21 | // supersede the GPL and are designed explicitly for licensees interested 22 | // in using QP/C++ in closed-source proprietary applications. 23 | // 24 | // Quantum Leaps contact information: 25 | // 26 | // 27 | //============================================================================ 28 | #ifndef QS_PORT_HPP_ 29 | #define QS_PORT_HPP_ 30 | 31 | // object pointer size in bytes 32 | #define QS_OBJ_PTR_SIZE 4U 33 | 34 | // function pointer size in bytes 35 | #define QS_FUN_PTR_SIZE 4U 36 | 37 | //============================================================================ 38 | // NOTE: QS might be used with or without other QP components, in which 39 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 40 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 41 | // with the other QP component, by simply including "qp_port.hpp" 42 | // *before* "qs.hpp". 43 | #ifndef QP_PORT_HPP_ 44 | #include "qp_port.hpp" // use QS with QP 45 | #endif 46 | 47 | #include "qs.hpp" // QS platform-independent public interface 48 | 49 | #endif // QS_PORT_HPP_ 50 | -------------------------------------------------------------------------------- /ports/threadx/syscalls.c: -------------------------------------------------------------------------------- 1 | // dummy system calls to eliminate the following GNU linker warning: 2 | // "warning: xxxx is not implemented and will always fail" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | extern int __io_putchar(int ch) __attribute__((weak)); 14 | extern int __io_getchar(void) __attribute__((weak)); 15 | 16 | char *__env[1] = { 0 }; 17 | char **environ = __env; 18 | 19 | void initialise_monitor_handles() { 20 | } 21 | int _getpid(void) { 22 | return 1; 23 | } 24 | int _kill(int pid, int sig) { 25 | (void)pid; 26 | (void)sig; 27 | errno = EINVAL; 28 | return -1; 29 | } 30 | void _exit (int status) { 31 | _kill(status, -1); 32 | while (1) { // do not return 33 | } 34 | } 35 | __attribute__((weak)) int _read(int file, char *ptr, int len) { 36 | (void)file; 37 | for (int i = len; i != 0; --i) { 38 | *ptr++ = __io_getchar(); 39 | } 40 | return len; 41 | } 42 | __attribute__((weak)) int _write(int file, char *ptr, int len) { 43 | (void)file; 44 | for (int i = len; i != 0; --i) { 45 | __io_putchar(*ptr++); 46 | } 47 | return len; 48 | } 49 | int _close(int file) { 50 | (void)file; 51 | return -1; 52 | } 53 | int _fstat(int file, struct stat *st) { 54 | (void)file; 55 | st->st_mode = S_IFCHR; 56 | return 0; 57 | } 58 | int _isatty(int file) { 59 | (void)file; 60 | return 1; 61 | } 62 | int _lseek(int file, int ptr, int dir) { 63 | (void)file; 64 | (void)ptr; 65 | (void)dir; 66 | return 0; 67 | } 68 | int _open(char *path, int flags, ...) { 69 | (void)path; 70 | (void)flags; 71 | return -1; 72 | } 73 | int _wait(int *status) { 74 | (void)status; 75 | errno = ECHILD; 76 | return -1; 77 | } 78 | int _unlink(char *name) { 79 | (void)name; 80 | errno = ENOENT; 81 | return -1; 82 | } 83 | int _times(struct tms *buf) { 84 | (void)buf; 85 | return -1; 86 | } 87 | int _stat(char *file, struct stat *st) { 88 | (void)file; 89 | st->st_mode = S_IFCHR; 90 | return 0; 91 | } 92 | int _link(char *old, char *new) { 93 | (void)old; 94 | (void)new; 95 | errno = EMLINK; 96 | return -1; 97 | } 98 | int _fork(void) { 99 | errno = EAGAIN; 100 | return -1; 101 | } 102 | int _execve(char *name, char **argv, char **env) { 103 | (void)name; 104 | (void)argv; 105 | (void)env; 106 | errno = ENOMEM; 107 | return -1; 108 | } 109 | -------------------------------------------------------------------------------- /ports/uc-os2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ports/uc-os2 2 | target_include_directories(qpcpp PUBLIC .) 3 | target_sources(qpcpp PRIVATE qf_port.cpp) 4 | -------------------------------------------------------------------------------- /ports/uc-os2/qp_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #ifndef QP_PORT_HPP_ 30 | #define QP_PORT_HPP_ 31 | 32 | #include // Exact-width types. C++11 Standard 33 | #include "qp_config.hpp" // QP configuration from the application 34 | 35 | // no-return function specifier (C++11 Standard) 36 | #define Q_NORETURN [[ noreturn ]] void 37 | 38 | // QActive customization for uC-OS2 39 | #define QACTIVE_EQUEUE_TYPE OS_EVENT * 40 | #define QACTIVE_THREAD_TYPE std::uint32_t 41 | 42 | // include files ------------------------------------------------------------- 43 | #include "ucos_ii.h" // uC-OS2 API, port and compile-time configuration 44 | 45 | #include "qequeue.hpp" // QP native queue for event deferral 46 | #include "qmpool.hpp" // QP native QF memory pool 47 | #include "qp.hpp" // QP platform-independent public interface 48 | 49 | // QF interrupt disable/enable for uC-OS2, NOTE1 50 | #if (OS_CRITICAL_METHOD == 1U) 51 | #define QF_CRIT_STAT 52 | #define QF_CRIT_ENTRY() OS_ENTER_CRITICAL() 53 | #define QF_CRIT_EXIT() OS_EXIT_CRITICAL() 54 | #define QF_CRIT_EST() OS_ENTER_CRITICAL() 55 | #elif (OS_CRITICAL_METHOD == 3U) 56 | #define QF_CRIT_STAT OS_CPU_SR cpu_sr; 57 | #define QF_CRIT_ENTRY() OS_ENTER_CRITICAL() 58 | #define QF_CRIT_EXIT() OS_EXIT_CRITICAL() 59 | #define QF_CRIT_EST() do { \ 60 | OS_CPU_SR cpu_sr; \ 61 | OS_ENTER_CRITICAL(); \ 62 | static_cast(cpu_sr);\ 63 | } while (false) 64 | #else 65 | #error Unsupported uC-OS2 critical section type 66 | #endif // OS_CRITICAL_METHOD 67 | 68 | namespace QP { 69 | 70 | enum UCOS2_TaskAttrs { 71 | TASK_NAME_ATTR 72 | }; 73 | 74 | } // namespace QP 75 | 76 | //============================================================================ 77 | // interface used only inside QF implementation, but not in applications 78 | #ifdef QP_IMPL 79 | 80 | // uC-OS2-specific scheduler locking, see NOTE2 81 | #define QF_SCHED_STAT_ 82 | #define QF_SCHED_LOCK_(dummy) do { \ 83 | if (OSIntNesting == 0U) { \ 84 | OSSchedLock(); \ 85 | } \ 86 | } while (false) 87 | 88 | #define QF_SCHED_UNLOCK_() do { \ 89 | if (OSIntNesting == 0U) { \ 90 | OSSchedUnlock(); \ 91 | } \ 92 | } while (false) 93 | 94 | // native QF event pool customization 95 | #define QF_EPOOL_TYPE_ QMPool 96 | #define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \ 97 | (p_).init((poolSto_), (poolSize_), (evtSize_)) 98 | #define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize()) 99 | #define QF_EPOOL_GET_(p_, e_, m_, qsId_) \ 100 | ((e_) = static_cast((p_).get((m_), (qsId_)))) 101 | #define QF_EPOOL_PUT_(p_, e_, qsId_) ((p_).put((e_), (qsId_))) 102 | 103 | #endif // ifdef QP_IMPL 104 | 105 | //============================================================================ 106 | // NOTE1: 107 | // This QP port to uC-OS2 re-uses the exact same critical section mechanism 108 | // as uC-OS2. The goal is to make this port independent on the CPU or the 109 | // toolchain by employing only the official uC-OS2 API. That way, all CPU 110 | // and toolchain dependencies are handled internally by uC-OS2. 111 | // 112 | // NOTE2: 113 | // uC-OS2 provides only global scheduler locking for all thread priorities 114 | // by means of OSSchedLock() and OSSchedUnlock(). Therefore, locking the 115 | // scheduler only up to the specified lock priority is not supported. 116 | // 117 | 118 | #endif // QP_PORT_HPP_ 119 | 120 | -------------------------------------------------------------------------------- /ports/uc-os2/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 3 | // 4 | // Q u a n t u m L e a P s 5 | // ------------------------ 6 | // Modern Embedded Software 7 | // 8 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 9 | // 10 | // This software is dual-licensed under the terms of the open-source GNU 11 | // General Public License (GPL) or under the terms of one of the closed- 12 | // source Quantum Leaps commercial licenses. 13 | // 14 | // Redistributions in source code must retain this top-level comment block. 15 | // Plagiarizing this software to sidestep the license obligations is illegal. 16 | // 17 | // NOTE: 18 | // The GPL (see ) does NOT permit the 19 | // incorporation of the QP/C++ software into proprietary programs. Please 20 | // contact Quantum Leaps for commercial licensing options, which expressly 21 | // supersede the GPL and are designed explicitly for licensees interested 22 | // in using QP/C++ in closed-source proprietary applications. 23 | // 24 | // Quantum Leaps contact information: 25 | // 26 | // 27 | //============================================================================ 28 | #ifndef QS_PORT_HPP_ 29 | #define QS_PORT_HPP_ 30 | 31 | // object pointer size in bytes 32 | #define QS_OBJ_PTR_SIZE 4U 33 | 34 | // function pointer size in bytes 35 | #define QS_FUN_PTR_SIZE 4U 36 | 37 | //============================================================================ 38 | // NOTE: QS might be used with or without other QP components, in which 39 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 40 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 41 | // with the other QP component, by simply including "qp_port.hpp" 42 | // *before* "qs.hpp". 43 | #ifndef QP_PORT_HPP_ 44 | #include "qp_port.hpp" // use QS with QP 45 | #endif 46 | 47 | #include "qs.hpp" // QS platform-independent public interface 48 | 49 | #endif // QS_PORT_HPP_ 50 | -------------------------------------------------------------------------------- /ports/uc-os2/syscalls.c: -------------------------------------------------------------------------------- 1 | // dummy system calls to eliminate the following GNU linker warning: 2 | // "warning: xxxx is not implemented and will always fail" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | extern int __io_putchar(int ch) __attribute__((weak)); 14 | extern int __io_getchar(void) __attribute__((weak)); 15 | 16 | char *__env[1] = { 0 }; 17 | char **environ = __env; 18 | 19 | void initialise_monitor_handles() { 20 | } 21 | int _getpid(void) { 22 | return 1; 23 | } 24 | int _kill(int pid, int sig) { 25 | (void)pid; 26 | (void)sig; 27 | errno = EINVAL; 28 | return -1; 29 | } 30 | void _exit (int status) { 31 | _kill(status, -1); 32 | while (1) { // do not return 33 | } 34 | } 35 | __attribute__((weak)) int _read(int file, char *ptr, int len) { 36 | (void)file; 37 | for (int i = len; i != 0; --i) { 38 | *ptr++ = __io_getchar(); 39 | } 40 | return len; 41 | } 42 | __attribute__((weak)) int _write(int file, char *ptr, int len) { 43 | (void)file; 44 | for (int i = len; i != 0; --i) { 45 | __io_putchar(*ptr++); 46 | } 47 | return len; 48 | } 49 | int _close(int file) { 50 | (void)file; 51 | return -1; 52 | } 53 | int _fstat(int file, struct stat *st) { 54 | (void)file; 55 | st->st_mode = S_IFCHR; 56 | return 0; 57 | } 58 | int _isatty(int file) { 59 | (void)file; 60 | return 1; 61 | } 62 | int _lseek(int file, int ptr, int dir) { 63 | (void)file; 64 | (void)ptr; 65 | (void)dir; 66 | return 0; 67 | } 68 | int _open(char *path, int flags, ...) { 69 | (void)path; 70 | (void)flags; 71 | return -1; 72 | } 73 | int _wait(int *status) { 74 | (void)status; 75 | errno = ECHILD; 76 | return -1; 77 | } 78 | int _unlink(char *name) { 79 | (void)name; 80 | errno = ENOENT; 81 | return -1; 82 | } 83 | int _times(struct tms *buf) { 84 | (void)buf; 85 | return -1; 86 | } 87 | int _stat(char *file, struct stat *st) { 88 | (void)file; 89 | st->st_mode = S_IFCHR; 90 | return 0; 91 | } 92 | int _link(char *old, char *new) { 93 | (void)old; 94 | (void)new; 95 | errno = EMLINK; 96 | return -1; 97 | } 98 | int _fork(void) { 99 | errno = EAGAIN; 100 | return -1; 101 | } 102 | int _execve(char *name, char **argv, char **env) { 103 | (void)name; 104 | (void)argv; 105 | (void)env; 106 | errno = ENOMEM; 107 | return -1; 108 | } 109 | -------------------------------------------------------------------------------- /ports/win32-qv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ports/win32-qv 2 | target_include_directories(qpcpp PUBLIC .) 3 | target_sources(qpcpp PRIVATE 4 | qf_port.cpp 5 | $<$:${CMAKE_CURRENT_SOURCE_DIR}/qwin_gui.c> 6 | $<$:${CMAKE_CURRENT_SOURCE_DIR}/qs_port.cpp> 7 | ) 8 | -------------------------------------------------------------------------------- /ports/win32-qv/README.md: -------------------------------------------------------------------------------- 1 | # Win32-API (Windows single-threaded) 2 | 3 | Documentation for this port is available in the QP/C Manual at: 4 | 5 | - https://www.state-machine.com/qpcpp/win32-qv.html 6 | -------------------------------------------------------------------------------- /ports/win32-qv/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Q u a n t u m L e a P s 5 | // ------------------------ 6 | // Modern Embedded Software 7 | // 8 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open source GNU 13 | // General Public License version 3 (or any later version), or alternatively, 14 | // under the terms of one of the closed source Quantum Leaps commercial 15 | // licenses. 16 | // 17 | // The terms of the open source GNU General Public License version 3 18 | // can be found at: 19 | // 20 | // The terms of the closed source Quantum Leaps commercial licenses 21 | // can be found at: 22 | // 23 | // Redistributions in source code must retain this top-level comment block. 24 | // Plagiarizing this software to sidestep the license obligations is illegal. 25 | // 26 | // Contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | #if defined(_WIN64) || defined(__LP64__) || defined(_LP64) // 64-bit OS? 34 | #define QS_OBJ_PTR_SIZE 8U 35 | #define QS_FUN_PTR_SIZE 8U 36 | #else // 32-bit OS 37 | #define QS_OBJ_PTR_SIZE 4U 38 | #define QS_FUN_PTR_SIZE 4U 39 | #endif 40 | 41 | namespace QP { 42 | void QS_output(void); // handle the QS output 43 | void QS_rx_input(void); // handle the QS-RX input 44 | } 45 | 46 | //============================================================================ 47 | // NOTE: QS might be used with or without other QP components, in which 48 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 49 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 50 | // with the other QP component, by simply including "qp_port.hpp" 51 | // *before* "qs.hpp". 52 | #ifndef QP_PORT_HPP_ 53 | #include "qp_port.hpp" // use QS with QP 54 | #endif 55 | 56 | #include "qs.hpp" // QS platform-independent public interface 57 | 58 | #endif // QS_PORT_HPP_ 59 | -------------------------------------------------------------------------------- /ports/win32-qv/safe_std.h: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // SafeQP/C++ Real-Time Event Framework (RTEF) 3 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 4 | // 5 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 6 | // 7 | // This software is dual-licensed under the terms of the open source GNU 8 | // General Public License version 3 (or any later version), or alternatively, 9 | // under the terms of one of the closed source Quantum Leaps commercial 10 | // licenses. 11 | // 12 | // The terms of the open source GNU General Public License version 3 13 | // can be found at: 14 | // 15 | // The terms of the closed source Quantum Leaps commercial licenses 16 | // can be found at: 17 | // 18 | // Redistributions in source code must retain this top-level comment block. 19 | // Plagiarizing this software to sidestep the license obligations is illegal. 20 | // 21 | // Contact information: 22 | // 23 | // 24 | //============================================================================ 25 | #ifndef SAFE_STD_H 26 | #define SAFE_STD_H 27 | 28 | #include 29 | #include 30 | 31 | // portable "safe" facilities from and ................ 32 | #ifdef _WIN32 // Windows OS? 33 | 34 | #define MEMMOVE_S(dest_, num_, src_, count_) \ 35 | memmove_s(dest_, num_, src_, count_) 36 | 37 | #define STRNCPY_S(dest_, destsiz_, src_) \ 38 | strncpy_s(dest_, destsiz_, src_, _TRUNCATE) 39 | 40 | #define STRCAT_S(dest_, destsiz_, src_) \ 41 | strcat_s(dest_, destsiz_, src_) 42 | 43 | #define SNPRINTF_S(buf_, bufsiz_, format_, ...) \ 44 | _snprintf_s(buf_, bufsiz_, _TRUNCATE, format_, __VA_ARGS__) 45 | 46 | #define PRINTF_S(format_, ...) \ 47 | printf_s(format_, __VA_ARGS__) 48 | 49 | #define FPRINTF_S(fp_, format_, ...) \ 50 | fprintf_s(fp_, format_, __VA_ARGS__) 51 | 52 | #ifdef _MSC_VER 53 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 54 | fread_s(buf_, bufsiz_, elsiz_, count_, fp_) 55 | #else 56 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 57 | fread(buf_, elsiz_, count_, fp_) 58 | #endif // _MSC_VER 59 | 60 | #define FOPEN_S(fp_, fName_, mode_) \ 61 | if (fopen_s(&fp_, fName_, mode_) != 0) { \ 62 | fp_ = (FILE *)0; \ 63 | } else (void)0 64 | 65 | #define LOCALTIME_S(tm_, time_) \ 66 | localtime_s(tm_, time_) 67 | 68 | #else // other OS (Linux, MacOS, etc.) ..................................... 69 | 70 | #define MEMMOVE_S(dest_, num_, src_, count_) \ 71 | memmove(dest_, src_, count_) 72 | 73 | #define STRNCPY_S(dest_, destsiz_, src_) do { \ 74 | strncpy(dest_, src_, destsiz_); \ 75 | dest_[(destsiz_) - 1] = '\0'; \ 76 | } while (false) 77 | 78 | #define STRCAT_S(dest_, destsiz_, src_) \ 79 | strcat(dest_, src_) 80 | 81 | #define SNPRINTF_S(buf_, bufsiz_, format_, ...) \ 82 | snprintf(buf_, bufsiz_, format_, __VA_ARGS__) 83 | 84 | #define PRINTF_S(format_, ...) \ 85 | printf(format_, __VA_ARGS__) 86 | 87 | #define FPRINTF_S(fp_, format_, ...) \ 88 | fprintf(fp_, format_, __VA_ARGS__) 89 | 90 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 91 | fread(buf_, elsiz_, count_, fp_) 92 | 93 | #define FOPEN_S(fp_, fName_, mode_) \ 94 | (fp_ = fopen(fName_, mode_)) 95 | 96 | #define LOCALTIME_S(tm_, time_) \ 97 | memcpy(tm_, localtime(time_), sizeof(struct tm)) 98 | 99 | #endif // _WIN32 100 | 101 | #endif // SAFE_STD_H 102 | -------------------------------------------------------------------------------- /ports/win32/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ports/win32 2 | target_include_directories(qpcpp PUBLIC .) 3 | target_sources(qpcpp PRIVATE 4 | qf_port.cpp 5 | $<$:${CMAKE_CURRENT_SOURCE_DIR}/qwin_gui.c> 6 | $<$:${CMAKE_CURRENT_SOURCE_DIR}/qs_port.cpp> 7 | ) 8 | -------------------------------------------------------------------------------- /ports/win32/README.md: -------------------------------------------------------------------------------- 1 | # Win32-API (Windows multi-threaded with Win32-threads) 2 | 3 | Documentation for this port is available in the QP/C Manual at: 4 | 5 | - https://www.state-machine.com/qpcpp/win32.html 6 | -------------------------------------------------------------------------------- /ports/win32/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Q u a n t u m L e a P s 5 | // ------------------------ 6 | // Modern Embedded Software 7 | // 8 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open source GNU 13 | // General Public License version 3 (or any later version), or alternatively, 14 | // under the terms of one of the closed source Quantum Leaps commercial 15 | // licenses. 16 | // 17 | // The terms of the open source GNU General Public License version 3 18 | // can be found at: 19 | // 20 | // The terms of the closed source Quantum Leaps commercial licenses 21 | // can be found at: 22 | // 23 | // Redistributions in source code must retain this top-level comment block. 24 | // Plagiarizing this software to sidestep the license obligations is illegal. 25 | // 26 | // Contact information: 27 | // 28 | // 29 | //============================================================================ 30 | #ifndef QS_PORT_HPP_ 31 | #define QS_PORT_HPP_ 32 | 33 | #if defined(_WIN64) || defined(__LP64__) || defined(_LP64) // 64-bit OS? 34 | #define QS_OBJ_PTR_SIZE 8U 35 | #define QS_FUN_PTR_SIZE 8U 36 | #else // 32-bit OS 37 | #define QS_OBJ_PTR_SIZE 4U 38 | #define QS_FUN_PTR_SIZE 4U 39 | #endif 40 | 41 | namespace QP { 42 | void QS_output(void); // handle the QS output 43 | void QS_rx_input(void); // handle the QS-RX input 44 | } 45 | 46 | //============================================================================ 47 | // NOTE: QS might be used with or without other QP components, in which 48 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 49 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 50 | // with the other QP component, by simply including "qp_port.hpp" 51 | // *before* "qs.hpp". 52 | #ifndef QP_PORT_HPP_ 53 | #include "qp_port.hpp" // use QS with QP 54 | #endif 55 | 56 | #include "qs.hpp" // QS platform-independent public interface 57 | 58 | #endif // QS_PORT_HPP_ 59 | -------------------------------------------------------------------------------- /ports/win32/qwin_gui.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief QWIN GUI facilities for building realistic embedded front panels 4 | * @cond 5 | ****************************************************************************** 6 | * Last updated for version 6.6.0 7 | * Last updated on 2019-07-30 8 | * 9 | * Q u a n t u m L e a P s 10 | * ------------------------ 11 | * Modern Embedded Software 12 | * 13 | * Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved. 14 | * 15 | * This program is open source software: you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License as published 17 | * by the Free Software Foundation, either version 3 of the License, or 18 | * (at your option) any later version. 19 | * 20 | * Alternatively, this program may be distributed and modified under the 21 | * terms of Quantum Leaps commercial licenses, which expressly supersede 22 | * the GNU General Public License and are specifically designed for 23 | * licensees interested in retaining the proprietary status of their code. 24 | * 25 | * This program is distributed in the hope that it will be useful, 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | * GNU General Public License for more details. 29 | * 30 | * You should have received a copy of the GNU General Public License 31 | * along with this program. If not, see . 32 | * 33 | * Contact information: 34 | * 35 | * 36 | ****************************************************************************** 37 | * @endcond 38 | */ 39 | #ifndef QWIN_GUI_H 40 | #define QWIN_GUI_H 41 | 42 | #ifndef QWIN_GUI 43 | #error The pre-processor macro QWIN_GUI must be defined 44 | #endif 45 | 46 | #define WIN32_LEAN_AND_MEAN 47 | #include /* Win32 API */ 48 | 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | /* create the custom dialog hosting the embedded front panel ...............*/ 54 | HWND CreateCustDialog(HINSTANCE hInst, int iDlg, HWND hParent, 55 | WNDPROC lpfnWndProc, LPCTSTR lpWndClass); 56 | 57 | /* OwnerDrawnButton "class" ................................................*/ 58 | typedef struct { 59 | UINT itemID; 60 | HBITMAP hBitmapUp; 61 | HBITMAP hBitmapDown; 62 | HCURSOR hCursor; 63 | int isDepressed; 64 | } OwnerDrawnButton; 65 | 66 | enum OwnerDrawnButtonAction { 67 | BTN_NOACTION, 68 | BTN_PAINTED, 69 | BTN_DEPRESSED, 70 | BTN_RELEASED 71 | }; 72 | 73 | void OwnerDrawnButton_init(OwnerDrawnButton * const me, 74 | UINT itemID, 75 | HBITMAP hBitmapUp, HBITMAP hBitmapDwn, 76 | HCURSOR hCursor); 77 | void OwnerDrawnButton_xtor(OwnerDrawnButton * const me); 78 | enum OwnerDrawnButtonAction OwnerDrawnButton_draw( 79 | OwnerDrawnButton * const me, 80 | LPDRAWITEMSTRUCT lpdis); 81 | void OwnerDrawnButton_set(OwnerDrawnButton * const me, 82 | int isDepressed); 83 | BOOL OwnerDrawnButton_isDepressed(OwnerDrawnButton const * const me); 84 | 85 | /* GraphicDisplay "class" for drawing graphic displays 86 | * with up to 24-bit color... 87 | */ 88 | typedef struct { 89 | HDC src_hDC; 90 | int src_width; 91 | int src_height; 92 | HDC dst_hDC; 93 | int dst_width; 94 | int dst_height; 95 | HWND hItem; 96 | HBITMAP hBitmap; 97 | BYTE *bits; 98 | BYTE bgColor[3]; 99 | } GraphicDisplay; 100 | 101 | void GraphicDisplay_init(GraphicDisplay * const me, 102 | UINT width, UINT height, 103 | UINT itemID, BYTE const bgColor[3]); 104 | void GraphicDisplay_xtor(GraphicDisplay * const me); 105 | void GraphicDisplay_clear(GraphicDisplay * const me); 106 | void GraphicDisplay_redraw(GraphicDisplay * const me); 107 | #define GraphicDisplay_setPixel(me_, x_, y_, color_) do { \ 108 | BYTE *pixelRGB = &(me_)->bits[3*((x_) \ 109 | + (me_)->src_width * ((me_)->src_height - 1U - (y_)))]; \ 110 | pixelRGB[0] = (color_)[0]; \ 111 | pixelRGB[1] = (color_)[1]; \ 112 | pixelRGB[2] = (color_)[2]; \ 113 | } while (0) 114 | 115 | #define GraphicDisplay_clearPixel(me_, x_, y_) do { \ 116 | BYTE *pixelRGB = &(me_)->bits[3*((x_) \ 117 | + (me_)->src_width * ((me_)->src_height - 1U - (y_)))]; \ 118 | pixelRGB[0] = (me_)->bgColor[0]; \ 119 | pixelRGB[1] = (me_)->bgColor[1]; \ 120 | pixelRGB[2] = (me_)->bgColor[2]; \ 121 | } while (0) 122 | 123 | /* SegmentDisplay "class" for drawing segment displays, LEDs, etc...........*/ 124 | typedef struct { 125 | HWND *hSegment; /* array of segment controls */ 126 | UINT segmentNum; /* number of segments */ 127 | HBITMAP *hBitmap; /* array of bitmap handles */ 128 | UINT bitmapNum; /* number of bitmaps */ 129 | } SegmentDisplay; 130 | 131 | void SegmentDisplay_init(SegmentDisplay * const me, 132 | UINT segNum, UINT bitmapNum); 133 | void SegmentDisplay_xtor(SegmentDisplay * const me); 134 | BOOL SegmentDisplay_initSegment(SegmentDisplay * const me, 135 | UINT segmentNum, UINT segmentID); 136 | BOOL SegmentDisplay_initBitmap(SegmentDisplay * const me, 137 | UINT bitmapNum, HBITMAP hBitmap); 138 | BOOL SegmentDisplay_setSegment(SegmentDisplay * const me, 139 | UINT segmentNum, UINT bitmapNum); 140 | 141 | /* useful helper functions .................................................*/ 142 | void DrawBitmap(HDC hdc, HBITMAP hBitmap, int xStart, int yStart); 143 | 144 | #ifdef __cplusplus 145 | } 146 | #endif 147 | 148 | #endif /* QWIN_GUI_H */ 149 | -------------------------------------------------------------------------------- /ports/win32/safe_std.h: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // SafeQP/C++ Real-Time Event Framework (RTEF) 3 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 4 | // 5 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 6 | // 7 | // This software is dual-licensed under the terms of the open source GNU 8 | // General Public License version 3 (or any later version), or alternatively, 9 | // under the terms of one of the closed source Quantum Leaps commercial 10 | // licenses. 11 | // 12 | // The terms of the open source GNU General Public License version 3 13 | // can be found at: 14 | // 15 | // The terms of the closed source Quantum Leaps commercial licenses 16 | // can be found at: 17 | // 18 | // Redistributions in source code must retain this top-level comment block. 19 | // Plagiarizing this software to sidestep the license obligations is illegal. 20 | // 21 | // Contact information: 22 | // 23 | // 24 | //============================================================================ 25 | #ifndef SAFE_STD_H 26 | #define SAFE_STD_H 27 | 28 | #include 29 | #include 30 | 31 | // portable "safe" facilities from and ................ 32 | #ifdef _WIN32 // Windows OS? 33 | 34 | #define MEMMOVE_S(dest_, num_, src_, count_) \ 35 | memmove_s(dest_, num_, src_, count_) 36 | 37 | #define STRNCPY_S(dest_, destsiz_, src_) \ 38 | strncpy_s(dest_, destsiz_, src_, _TRUNCATE) 39 | 40 | #define STRCAT_S(dest_, destsiz_, src_) \ 41 | strcat_s(dest_, destsiz_, src_) 42 | 43 | #define SNPRINTF_S(buf_, bufsiz_, format_, ...) \ 44 | _snprintf_s(buf_, bufsiz_, _TRUNCATE, format_, __VA_ARGS__) 45 | 46 | #define PRINTF_S(format_, ...) \ 47 | printf_s(format_, __VA_ARGS__) 48 | 49 | #define FPRINTF_S(fp_, format_, ...) \ 50 | fprintf_s(fp_, format_, __VA_ARGS__) 51 | 52 | #ifdef _MSC_VER 53 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 54 | fread_s(buf_, bufsiz_, elsiz_, count_, fp_) 55 | #else 56 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 57 | fread(buf_, elsiz_, count_, fp_) 58 | #endif // _MSC_VER 59 | 60 | #define FOPEN_S(fp_, fName_, mode_) \ 61 | if (fopen_s(&fp_, fName_, mode_) != 0) { \ 62 | fp_ = (FILE *)0; \ 63 | } else (void)0 64 | 65 | #define LOCALTIME_S(tm_, time_) \ 66 | localtime_s(tm_, time_) 67 | 68 | #else // other OS (Linux, MacOS, etc.) ..................................... 69 | 70 | #define MEMMOVE_S(dest_, num_, src_, count_) \ 71 | memmove(dest_, src_, count_) 72 | 73 | #define STRNCPY_S(dest_, destsiz_, src_) do { \ 74 | strncpy(dest_, src_, destsiz_); \ 75 | dest_[(destsiz_) - 1] = '\0'; \ 76 | } while (false) 77 | 78 | #define STRCAT_S(dest_, destsiz_, src_) \ 79 | strcat(dest_, src_) 80 | 81 | #define SNPRINTF_S(buf_, bufsiz_, format_, ...) \ 82 | snprintf(buf_, bufsiz_, format_, __VA_ARGS__) 83 | 84 | #define PRINTF_S(format_, ...) \ 85 | printf(format_, __VA_ARGS__) 86 | 87 | #define FPRINTF_S(fp_, format_, ...) \ 88 | fprintf(fp_, format_, __VA_ARGS__) 89 | 90 | #define FREAD_S(buf_, bufsiz_, elsiz_, count_, fp_) \ 91 | fread(buf_, elsiz_, count_, fp_) 92 | 93 | #define FOPEN_S(fp_, fName_, mode_) \ 94 | (fp_ = fopen(fName_, mode_)) 95 | 96 | #define LOCALTIME_S(tm_, time_) \ 97 | memcpy(tm_, localtime(time_), sizeof(struct tm)) 98 | 99 | #endif // _WIN32 100 | 101 | #endif // SAFE_STD_H 102 | -------------------------------------------------------------------------------- /ports/zephyr/README.md: -------------------------------------------------------------------------------- 1 | The QP/C++ port to Zephyr is located in the `qpcpp/zephyr` directory 2 | to follow the conventions established for 3 | [Zephyr modules](https://docs.zephyrproject.org/latest/develop/modules.html) 4 | -------------------------------------------------------------------------------- /qpcpp_sdk_init.cmake: -------------------------------------------------------------------------------- 1 | # Pre-initialize the QPC SDK 2 | # This file must be included prior to the project() call 3 | 4 | # Note: this file is perhaps named badly, as it provides a method qpc_sdk_init which 5 | # the enclosing project calls LATER to actually "initialize" the SDK (by including the CMakeLists.txt from this 6 | # same directory) 7 | 8 | if (NOT TARGET _qpcpp_sdk_pre_init_marker) 9 | add_library(_qpcpp_sdk_pre_init_marker INTERFACE) 10 | 11 | function(qpcpp_is_top_level_project VAR) 12 | string(TOLOWER ${CMAKE_CURRENT_LIST_DIR} __list_dir) 13 | string(TOLOWER ${CMAKE_SOURCE_DIR} __source_dir) 14 | if (__source_dir STREQUAL __list_dir) 15 | set(${VAR} 1 PARENT_SCOPE) 16 | else() 17 | set(${VAR} 0 PARENT_SCOPE) 18 | endif() 19 | endfunction() 20 | 21 | function(qpcpp_message_debug MESSAGE) 22 | # The log-level system was added in CMake 3.15. 23 | if(${CMAKE_VERSION} VERSION_LESS "3.15.0") 24 | message(${MESSAGE}) 25 | else() 26 | message(DEBUG ${MESSAGE}) 27 | endif() 28 | endfunction() 29 | 30 | if (NOT QPCPP_SDK_PATH) 31 | set(QPCPP_SDK_PATH ${CMAKE_CURRENT_LIST_DIR}) 32 | endif () 33 | 34 | file(REAL_PATH "${QPCPP_SDK_PATH}" QPCPP_SDK_PATH BASE_DIRECTORY "${CMAKE_BINARY_DIR}") 35 | 36 | set(QPCPP_SDK_PATH ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "Path to the QP/C++ SDK" FORCE) 37 | 38 | list(APPEND CMAKE_MODULE_PATH ${QPCPP_SDK_PATH}/cmake) 39 | 40 | message("QPCPP_SDK_PATH is ${CMAKE_CURRENT_LIST_DIR}") 41 | 42 | function(qpcpp_sdk_init) 43 | if (NOT CMAKE_PROJECT_NAME) 44 | message(WARNING "qpcpp_sdk_init() should be called after the project is created (and languages added)") 45 | endif() 46 | 47 | add_subdirectory(${QPCPP_SDK_PATH} qpcpp-sdk) 48 | endfunction() 49 | endif() 50 | -------------------------------------------------------------------------------- /sha1.bat: -------------------------------------------------------------------------------- 1 | @setlocal 2 | 3 | set VERSION=8.0.4 4 | 5 | :: usage 6 | @echo Usage: qppcp_sha1 [gen] 7 | @echo examples: 8 | @echo qppcp_sha1 : check the sha1 sums in the file qpcpp_%VERSION%.sha1 9 | @echo qpcpp_sha1 gen : generate the sha1 file qpcpp_%VERSION%.sha1 10 | @echo. 11 | 12 | @if NOT "%1"=="gen" ( 13 | sha1sum --check --warn qpcpp_%VERSION%.sha1 14 | goto end 15 | ) 16 | 17 | @echo generating qpcpp_%VERSION%.sha1... 18 | @sha1sum ^ 19 | include/* ^ 20 | src/qf/* src/qk/* src/qs/* src/qv/* src/qxk/* ^ 21 | ports/arm-cm/config/* ^ 22 | ports/arm-cm/qk/armclang/* ports/arm-cm/qk/gnu/* ports/arm-cm/qk/iar/* ^ 23 | ports/arm-cm/qv/armclang/* ports/arm-cm/qv/gnu/* ports/arm-cm/qv/iar/* ^ 24 | ports/arm-cm/qxk/armclang/* ports/arm-cm/qxk/gnu/* ports/arm-cm/qxk/iar/* ^ 25 | ports/arm-cm/qutest/* ^ 26 | ports/arm-cr/config/* ^ 27 | ports/arm-cr/qk/gnu/* ports/arm-cr/qk/iar/* ports/arm-cr/qk/ti/* ^ 28 | ports/arm-cr/qv/gnu/* ports/arm-cr/qv/iar/* ports/arm-cr/qv/ti/* ^ 29 | ports/msp430/qk/* ports/msp430/qv/* ports/msp430/qutest/* ^ 30 | ports/config/* ^ 31 | ports/embos/* ^ 32 | ports/freertos/* ^ 33 | ports/threadx/* ^ 34 | ports/uc-os2/* ^ 35 | ports/qep-only/* ^ 36 | ports/posix/* ports/posix-qv/* ports/posix-qutest/* ^ 37 | ports/win32/* ports/win32-qv/* ports/win32-qutest/* ^ 38 | zephyr/* ^ 39 | > qpcpp_%VERSION%.sha1 40 | qclean 41 | @echo done 42 | 43 | :end 44 | @endlocal 45 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # qpcpp/src 2 | add_subdirectory(qf) 3 | add_subdirectory(qs) 4 | if(${PORT} IN_LIST QPCPP_BAREMETAL_PORTS) 5 | message(STATUS "adding subdir '${KERNEL}' for port '${PORT}'") 6 | add_subdirectory(${KERNEL}) 7 | endif() 8 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | # Files Missing from the QP/C++ GPL Distribution 2 | Due to the widespread non-compliance with the GPL, as well as infringement 3 | on the [dual-licensing model of QP frameworks][Lic], the following files 4 | have been **removed from the open-source GPL distribution**: 5 | 6 | ``` 7 | qpcpp 8 | | 9 | +---include 10 | | qs.hpp 11 | | qs_pkg.hpp 12 | | qxk.hpp 13 | | 14 | \---src 15 | | 16 | +---qs 17 | | qs.cpp 18 | | qs_64bit.cpp 19 | | qs_fp.cpp 20 | | qs_rx.cpp 21 | | qutest.cpp 22 | | 23 | \---qxk 24 | qxk.cpp 25 | qxk_mutex.cpp 26 | qxk_sema.cpp 27 | qxk_xthr.cpp 28 | ``` 29 | 30 | > NOTE: These files are available to the [commercial licensees][Cust] with 31 | the active Support Term. Please contact [Quantum Leaps technical support][Sup] 32 | to get the complete QP/C++ framework distribution. 33 | 34 | # QP/C++ Framework Evaluation 35 | To request **evaluation** of the complete QP/C++ framework, please contact 36 | Quantum Leaps at: 37 | - https://www.state-machine.com/contact 38 | 39 | # Quantum Leaps Licensing: 40 | To learn more about the open source and commercial licensing options: 41 | - https://www.state-machine.com/licensing 42 | 43 | [Lic]: 44 | [Cust]: 45 | [Sup]: 46 | -------------------------------------------------------------------------------- /src/qf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ./src/qf 2 | target_sources(qpcpp PRIVATE 3 | qep_hsm.cpp 4 | qep_msm.cpp 5 | qf_act.cpp 6 | # qf_actq.cpp - see below 7 | qf_defer.cpp 8 | qf_dyn.cpp 9 | # qf_mem.cpp - see below 10 | qf_ps.cpp 11 | qf_qact.cpp 12 | qf_qeq.cpp 13 | qf_qmact.cpp 14 | qf_time.cpp 15 | ) 16 | if(NOT (${QPCPP_CFG_PORT} IN_LIST QPCPP_RTOS_PORTS)) 17 | target_sources(qpcpp PRIVATE 18 | qf_actq.cpp 19 | ) 20 | endif() 21 | if(NOT (${QPCPP_CFG_PORT} STREQUAL uc-os2)) 22 | target_sources(qpcpp PRIVATE 23 | qf_mem.cpp 24 | ) 25 | endif() -------------------------------------------------------------------------------- /src/qf/qf_act.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #define QP_IMPL // this is QP implementation 30 | #include "qp_port.hpp" // QP port 31 | #include "qp_pkg.hpp" // QP package-scope interface 32 | #include "qsafe.h" // QP Functional Safety (FuSa) Subsystem 33 | #ifdef Q_SPY // QS software tracing enabled? 34 | #include "qs_port.hpp" // QS port 35 | #include "qs_pkg.hpp" // QS facilities for pre-defined trace records 36 | #else 37 | #include "qs_dummy.hpp" // disable the QS software tracing 38 | #endif // Q_SPY 39 | 40 | // unnamed namespace for local definitions with internal linkage 41 | namespace { 42 | //Q_DEFINE_THIS_MODULE("qf_act") 43 | } // unnamed namespace 44 | 45 | namespace QP { 46 | 47 | // QP version string embedded in the binary image 48 | char const versionStr[] = "QP/C++ " QP_VERSION_STR; 49 | 50 | QActive * QActive::registry_[QF_MAX_ACTIVE + 1U]; 51 | 52 | namespace QF { 53 | 54 | QF::Attr priv_; 55 | 56 | void bzero_( 57 | void * const start, 58 | std::uint_fast16_t const len) noexcept 59 | { 60 | std::uint8_t *ptr = static_cast(start); 61 | for (std::uint_fast16_t n = len; n > 0U; --n) { 62 | *ptr = 0U; 63 | ++ptr; 64 | } 65 | } 66 | 67 | } // namespace QF 68 | 69 | //............................................................................ 70 | #ifndef QF_LOG2 71 | std::uint_fast8_t QF_LOG2(QP::QPSetBits const bitmask) noexcept { 72 | static constexpr std::uint8_t log2LUT[16] = { 73 | 0U, 1U, 2U, 2U, 3U, 3U, 3U, 3U, 74 | 4U, 4U, 4U, 4U, 4U, 4U, 4U, 4U 75 | }; 76 | std::uint_fast8_t n = 0U; 77 | QP::QPSetBits x = bitmask; 78 | QP::QPSetBits tmp; 79 | 80 | #if (QF_MAX_ACTIVE > 16U) 81 | tmp = static_cast(x >> 16U); 82 | if (tmp != 0U) { 83 | n += 16U; 84 | x = tmp; 85 | } 86 | #endif 87 | #if (QF_MAX_ACTIVE > 8U) 88 | tmp = (x >> 8U); 89 | if (tmp != 0U) { 90 | n += 8U; 91 | x = tmp; 92 | } 93 | #endif 94 | tmp = (x >> 4U); 95 | if (tmp != 0U) { 96 | n += 4U; 97 | x = tmp; 98 | } 99 | return n + log2LUT[x]; 100 | } 101 | #endif // ndef QF_LOG2 102 | 103 | } // namespace QP 104 | 105 | -------------------------------------------------------------------------------- /src/qf/qf_defer.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #define QP_IMPL // this is QP implementation 30 | #include "qp_port.hpp" // QP port 31 | #include "qp_pkg.hpp" // QP package-scope interface 32 | #include "qsafe.h" // QP Functional Safety (FuSa) Subsystem 33 | #ifdef Q_SPY // QS software tracing enabled? 34 | #include "qs_port.hpp" // QS port 35 | #include "qs_pkg.hpp" // QS facilities for pre-defined trace records 36 | #else 37 | #include "qs_dummy.hpp" // disable the QS software tracing 38 | #endif // Q_SPY 39 | 40 | // unnamed namespace for local definitions with internal linkage 41 | namespace { 42 | Q_DEFINE_THIS_MODULE("qf_defer") 43 | } // unnamed namespace 44 | 45 | namespace QP { 46 | 47 | //............................................................................ 48 | bool QActive::defer( 49 | QEQueue * const eq, 50 | QEvt const * const e) const noexcept 51 | { 52 | bool const status = eq->post(e, 0U, m_prio); 53 | 54 | QS_CRIT_STAT 55 | QS_CRIT_ENTRY(); 56 | if (status) { 57 | QS_BEGIN_PRE(QS_QF_ACTIVE_DEFER, m_prio) 58 | QS_TIME_PRE(); // time stamp 59 | QS_OBJ_PRE(this); // this active object 60 | QS_OBJ_PRE(eq); // the deferred queue 61 | QS_SIG_PRE(e->sig); // the signal of the event 62 | QS_2U8_PRE(e->poolNum_, e->refCtr_); 63 | QS_END_PRE() 64 | } 65 | else { 66 | QS_BEGIN_PRE(QS_QF_ACTIVE_DEFER_ATTEMPT, m_prio) 67 | QS_TIME_PRE(); // time stamp 68 | QS_OBJ_PRE(this); // this active object 69 | QS_OBJ_PRE(eq); // the deferred queue 70 | QS_SIG_PRE(e->sig); // the signal of the event 71 | QS_2U8_PRE(e->poolNum_, e->refCtr_); 72 | QS_END_PRE() 73 | } 74 | QS_CRIT_EXIT(); 75 | 76 | return status; 77 | } 78 | 79 | //............................................................................ 80 | bool QActive::recall(QEQueue * const eq) noexcept { 81 | QEvt const * const e = eq->get(m_prio); // get evt from deferred queue 82 | 83 | bool recalled = false; 84 | if (e != nullptr) { // event available? 85 | 86 | postLIFO(e); // post it to the front of the AO's queue 87 | 88 | QF_CRIT_STAT 89 | QF_CRIT_ENTRY(); 90 | 91 | if (e->poolNum_ != 0U) { // mutable event? 92 | 93 | // after posting to the AO's queue the event must be referenced 94 | // at least twice: once in the deferred event queue (eq->get() 95 | // did NOT decrement the reference counter) and once in the 96 | // AO's event queue. 97 | Q_ASSERT_INCRIT(210, e->refCtr_ >= 2U); 98 | 99 | // decrement the reference counter once, to account for removing 100 | // the event from the deferred queue. 101 | QEvt_refCtr_dec_(e); // decrement the reference counter 102 | } 103 | 104 | QS_BEGIN_PRE(QS_QF_ACTIVE_RECALL, m_prio) 105 | QS_TIME_PRE(); // time stamp 106 | QS_OBJ_PRE(this); // this active object 107 | QS_OBJ_PRE(eq); // the deferred queue 108 | QS_SIG_PRE(e->sig); // the signal of the event 109 | QS_2U8_PRE(e->poolNum_, e->refCtr_); 110 | QS_END_PRE() 111 | 112 | QF_CRIT_EXIT(); 113 | 114 | recalled = true; 115 | } 116 | else { 117 | QS_CRIT_STAT 118 | QS_CRIT_ENTRY(); 119 | 120 | QS_BEGIN_PRE(QS_QF_ACTIVE_RECALL_ATTEMPT, m_prio) 121 | QS_TIME_PRE(); // time stamp 122 | QS_OBJ_PRE(this); // this active object 123 | QS_OBJ_PRE(eq); // the deferred queue 124 | QS_END_PRE() 125 | 126 | QS_CRIT_EXIT(); 127 | } 128 | return recalled; 129 | } 130 | 131 | //............................................................................ 132 | std::uint_fast16_t QActive::flushDeferred( 133 | QEQueue * const eq, 134 | std::uint_fast16_t const num) const noexcept 135 | { 136 | std::uint_fast16_t n = 0U; 137 | while (n < num) { 138 | QEvt const * const e = eq->get(m_prio); 139 | if (e != nullptr) { 140 | ++n; // count one more flushed event 141 | #if (QF_MAX_EPOOL > 0U) 142 | QF::gc(e); // garbage collect 143 | #endif 144 | } 145 | else { 146 | break; 147 | } 148 | } 149 | 150 | return n; 151 | } 152 | 153 | } // namespace QP 154 | -------------------------------------------------------------------------------- /src/qf/qf_qact.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #define QP_IMPL // this is QP implementation 30 | #include "qp_port.hpp" // QP port 31 | #include "qp_pkg.hpp" // QP package-scope interface 32 | #include "qsafe.h" // QP Functional Safety (FuSa) Subsystem 33 | #ifdef Q_SPY // QS software tracing enabled? 34 | #include "qs_port.hpp" // QS port 35 | #include "qs_pkg.hpp" // QS facilities for pre-defined trace records 36 | #else 37 | #include "qs_dummy.hpp" // disable the QS software tracing 38 | #endif // Q_SPY 39 | 40 | // unnamed namespace for local definitions with internal linkage 41 | namespace { 42 | Q_DEFINE_THIS_MODULE("qf_qact") 43 | } // unnamed namespace 44 | 45 | namespace QP { 46 | 47 | 48 | //............................................................................ 49 | QActive::QActive(QStateHandler const initial) noexcept 50 | : QAsm(), 51 | m_prio(0U), 52 | m_pthre(0U) 53 | { 54 | m_state.fun = Q_STATE_CAST(&top); 55 | m_temp.fun = initial; 56 | } 57 | 58 | //............................................................................ 59 | void QActive::register_() noexcept { 60 | QF_CRIT_STAT 61 | QF_CRIT_ENTRY(); 62 | 63 | if (m_pthre == 0U) { // preemption-threshold not defined? 64 | m_pthre = m_prio; // apply the default 65 | } 66 | 67 | #ifndef Q_UNSAFE 68 | Q_REQUIRE_INCRIT(100, 69 | (0U < m_prio) && (m_prio <= QF_MAX_ACTIVE)); 70 | Q_REQUIRE_INCRIT(110, registry_[m_prio] == nullptr); 71 | Q_REQUIRE_INCRIT(120, m_prio <= m_pthre); 72 | 73 | std::uint8_t prev_thre = m_pthre; 74 | std::uint8_t next_thre = m_pthre; 75 | 76 | for (std::uint_fast8_t p = static_cast(m_prio) - 1U; 77 | p > 0U; 78 | --p) 79 | { 80 | if (registry_[p] != nullptr) { 81 | prev_thre = registry_[p]->m_pthre; 82 | break; 83 | } 84 | } 85 | for (std::uint_fast8_t p = static_cast(m_prio) + 1U; 86 | p <= QF_MAX_ACTIVE; 87 | ++p) 88 | { 89 | if (registry_[p] != nullptr) { 90 | next_thre = registry_[p]->m_pthre; 91 | break; 92 | } 93 | } 94 | 95 | Q_ASSERT_INCRIT(160, (prev_thre <= m_pthre) && (m_pthre <= next_thre)); 96 | 97 | #endif // Q_UNSAFE 98 | 99 | // register the AO at the QF-prio. 100 | registry_[m_prio] = this; 101 | 102 | QF_CRIT_EXIT(); 103 | } 104 | 105 | //............................................................................ 106 | void QActive::unregister_() noexcept { 107 | std::uint_fast8_t const p = static_cast(m_prio); 108 | 109 | QF_CRIT_STAT 110 | QF_CRIT_ENTRY(); 111 | 112 | Q_REQUIRE_INCRIT(200, (0U < p) && (p <= QF_MAX_ACTIVE)); 113 | Q_REQUIRE_INCRIT(210, registry_[p] == this); 114 | 115 | m_state.fun = nullptr; // invalidate the state 116 | registry_[p] = nullptr; // free-up the priority level 117 | 118 | QF_CRIT_EXIT(); 119 | } 120 | 121 | } // namespace QP 122 | -------------------------------------------------------------------------------- /src/qf/qf_qmact.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #define QP_IMPL // this is QP implementation 30 | #include "qp_port.hpp" // QP port 31 | #include "qp_pkg.hpp" // QP package-scope interface 32 | #include "qsafe.h" // QP Functional Safety (FuSa) Subsystem 33 | #ifdef Q_SPY // QS software tracing enabled? 34 | #include "qs_port.hpp" // QS port 35 | #include "qs_pkg.hpp" // QS facilities for pre-defined trace records 36 | #else 37 | #include "qs_dummy.hpp" // disable the QS software tracing 38 | #endif // Q_SPY 39 | 40 | // unnamed namespace for local definitions with internal linkage 41 | namespace { 42 | //Q_DEFINE_THIS_MODULE("qf_qmact") 43 | } // unnamed namespace 44 | 45 | namespace QP { 46 | 47 | //............................................................................ 48 | QMActive::QMActive(QStateHandler const initial) noexcept 49 | : QActive(initial) 50 | { 51 | m_state.obj = reinterpret_cast(this)->topQMState(); 52 | m_temp.fun = initial; 53 | } 54 | 55 | } // namespace QP 56 | -------------------------------------------------------------------------------- /src/qk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ./src/qf 2 | target_sources(qpcpp PRIVATE 3 | qk.cpp 4 | ) 5 | 6 | -------------------------------------------------------------------------------- /src/qs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ./src/qs 2 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/qs.cpp) 3 | target_sources(qpcpp PRIVATE 4 | "$<$:${CMAKE_CURRENT_SOURCE_DIR}/qs_64bit.cpp>" 5 | "$<$:${CMAKE_CURRENT_SOURCE_DIR}/qs_fp.cpp>" 6 | "$<$:${CMAKE_CURRENT_SOURCE_DIR}/qs_rx.cpp>" 7 | "$<$:${CMAKE_CURRENT_SOURCE_DIR}/qstamp.cpp>" 8 | "$<$:${CMAKE_CURRENT_SOURCE_DIR}/qs.cpp>" 9 | "$<$,$>:${CMAKE_CURRENT_SOURCE_DIR}/qutest.cpp>" 10 | ) 11 | else() 12 | target_sources(qpcpp PRIVATE 13 | "$<$:${CMAKE_CURRENT_SOURCE_DIR}/qstamp.cpp>" 14 | ) 15 | endif() 16 | -------------------------------------------------------------------------------- /src/qs/qstamp.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: LicenseRef-QL-commercial 11 | // 12 | // This software is licensed under the terms of the Quantum Leaps commercial 13 | // licenses. Please contact Quantum Leaps for more information about the 14 | // available licensing options. 15 | // 16 | // RESTRICTIONS 17 | // You may NOT : 18 | // (a) redistribute, encumber, sell, rent, lease, sublicense, or otherwise 19 | // transfer rights in this software, 20 | // (b) remove or alter any trademark, logo, copyright or other proprietary 21 | // notices, legends, symbols or labels present in this software, 22 | // (c) plagiarize this software to sidestep the licensing obligations. 23 | // 24 | // Quantum Leaps contact information: 25 | // 26 | // 27 | //============================================================================ 28 | #include "qstamp.hpp" 29 | 30 | namespace QP { 31 | char const BUILD_DATE[12] = __DATE__; 32 | char const BUILD_TIME[9] = __TIME__; 33 | } // namespace QP 34 | -------------------------------------------------------------------------------- /src/qv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ./src/qf 2 | target_sources(qpcpp PRIVATE 3 | qv.cpp 4 | ) 5 | -------------------------------------------------------------------------------- /zephyr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # QPCPP Zephyr module 2 | # SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 3 | 4 | zephyr_library_named(qpcpp) 5 | 6 | if(CONFIG_QPCPP) 7 | 8 | set(QPCPP_DIR ..) 9 | 10 | zephyr_include_directories( 11 | ${QPCPP_DIR}/include 12 | ${QPCPP_DIR}/zephyr 13 | ) 14 | 15 | target_include_directories(app PUBLIC 16 | ${QPCPP_DIR}/include 17 | ${QPCPP_DIR}/zephyr 18 | ) 19 | 20 | zephyr_library_sources( 21 | ${QPCPP_DIR}/src/qf/qep_hsm.cpp 22 | ${QPCPP_DIR}/src/qf/qep_msm.cpp 23 | ${QPCPP_DIR}/src/qf/qf_act.cpp 24 | ${QPCPP_DIR}/src/qf/qf_defer.cpp 25 | ${QPCPP_DIR}/src/qf/qf_dyn.cpp 26 | ${QPCPP_DIR}/src/qf/qf_mem.cpp 27 | ${QPCPP_DIR}/src/qf/qf_ps.cpp 28 | ${QPCPP_DIR}/src/qf/qf_qact.cpp 29 | ${QPCPP_DIR}/src/qf/qf_qeq.cpp 30 | ${QPCPP_DIR}/src/qf/qf_qmact.cpp 31 | ${QPCPP_DIR}/src/qf/qf_time.cpp 32 | ${QPCPP_DIR}/zephyr/qf_port.cpp 33 | ) 34 | 35 | # QSPY option... 36 | if(QSPY) 37 | 38 | target_compile_definitions(app PUBLIC Q_SPY) 39 | zephyr_library_compile_definitions(Q_SPY) 40 | 41 | zephyr_library_sources( 42 | ${QPCPP_DIR}/src/qs/qs.cpp 43 | ${QPCPP_DIR}/src/qs/qs_rx.cpp 44 | ${QPCPP_DIR}/src/qs/qs_fp.cpp 45 | ${QPCPP_DIR}/src/qs/qutest.cpp 46 | ${QPCPP_DIR}/src/qs/qs_64bit.cpp 47 | ${QPCPP_DIR}/src/qs/qstamp.cpp 48 | ) 49 | 50 | endif() # QSPY 51 | 52 | endif() # CONFIG_QPCPP 53 | -------------------------------------------------------------------------------- /zephyr/Kconfig: -------------------------------------------------------------------------------- 1 | # QPCPP Zephyr module 2 | # SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 3 | 4 | menuconfig QPCPP 5 | bool "QPCPP" 6 | default n 7 | help 8 | Enables the QPCPP Module 9 | 10 | if QPCPP 11 | 12 | module = QPCPP 13 | module-str = QPCPP 14 | 15 | endif 16 | -------------------------------------------------------------------------------- /zephyr/README.md: -------------------------------------------------------------------------------- 1 | [![QP Zephyr Module](./qp-zephyr.jpg)](https://www.state-machine.com/qpcpp/zephyr.html) 2 | 3 | # About the QPCPP Zephyr Module 4 | This directory defines the 5 | [QP/C++ Real-Time Embedded Framework](https://github.com/QuantumLeaps/qpcpp) 6 | as a [Zephyr module](https://docs.zephyrproject.org/latest/develop/modules.html). 7 | 8 | # How to use 9 | Example of use is provided in the related repository 10 | [qpcpp-zephyr-app](https://github.com/QuantumLeaps/qpcpp-zephyr-app) 11 | 12 | To create your own QP-Zephyr project, you can clone that repository 13 | and customize it to your needs: 14 | 15 | ```bash 16 | git clone https://github.com/QuantumLeaps/qpcpp-zephyr-app --recurse-submodules --depth 1 17 | ``` 18 | where `` is the name of your project. 19 | 20 | 21 | ## Configuring the QPCPP Zephyr Module 22 | The `Kconfig` file provides configuration `CONFIG_QPCPP` to activate the QPCPP module 23 | in Zephyr. To do so, you need to add the following line to your `prj.conf`: 24 | 25 | ```ini 26 | CONFIG_QPCPP=y 27 | ``` 28 | 29 | ## Option for Activating QSPY Software Tracing 30 | The QP/C++ Zephyr Module supports the 31 | [QSPY Software Tracing](https://www.state-machine.com/qtools/qpspy.html) 32 | option and will add the appropriate macros and files to build the "QSPY" 33 | configuration. 34 | 35 | If you wish to enable "QSPY" you can provide the option "QSPY" 36 | in the command-line for the build. For example: 37 | 38 | ```bash 39 | west build -b nucleo_h743zi -- -DQSPY=ON 40 | ``` 41 | -------------------------------------------------------------------------------- /zephyr/module.yml: -------------------------------------------------------------------------------- 1 | build: 2 | cmake: zephyr 3 | kconfig: zephyr/Kconfig 4 | -------------------------------------------------------------------------------- /zephyr/qp-zephyr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuantumLeaps/qpcpp/093a5037e2f19c319d22c3a95c21d5a6febb827d/zephyr/qp-zephyr.jpg -------------------------------------------------------------------------------- /zephyr/qp_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #ifndef QP_PORT_HPP_ 30 | #define QP_PORT_HPP_ 31 | 32 | #include // Exact-width types. C++11 Standard 33 | #include // Zephyr kernel API 34 | #include "qp_config.hpp" // QP configuration from the application 35 | 36 | // no-return function specifier (C++11 Standard) 37 | #define Q_NORETURN [[ noreturn ]] void 38 | 39 | // QActive event queue and thread types 40 | #define QACTIVE_EQUEUE_TYPE struct k_msgq 41 | #define QACTIVE_THREAD_TYPE struct k_thread 42 | 43 | // QF critical section entry/exit for Zephyr, see NOTE1/ 44 | #define QF_CRIT_STAT k_spinlock_key_t key_; 45 | #define QF_CRIT_ENTRY() ((key_) = k_spin_lock(&QP::QF::spinlock)) 46 | #define QF_CRIT_EXIT() k_spin_unlock(&QP::QF::spinlock, key_) 47 | #define QF_CRIT_EST() static_cast(k_spin_lock(&QP::QF::spinlock)) 48 | 49 | // Q_PRINTK() macro to avoid conflicts with Zephyr's printk() 50 | // when Q_SPY configuration is used 51 | #ifndef Q_SPY 52 | #define Q_PRINTK(fmt_, ...) printk(fmt_, ##__VA_ARGS__) 53 | #else 54 | #define Q_PRINTK(dummy, ...) static_cast(0) 55 | #endif 56 | 57 | // include files ------------------------------------------------------------- 58 | #include "qequeue.hpp" // used for event deferral 59 | #include "qmpool.hpp" // this QP port uses the native QF memory pool 60 | #include "qp.hpp" // QP platform-independent public interface 61 | 62 | namespace QP { 63 | namespace QF { 64 | 65 | // Zephyr spinlock for QF critical section 66 | extern struct k_spinlock spinlock; 67 | 68 | } // namespace QF 69 | } // namespace QP 70 | 71 | //============================================================================ 72 | // interface used only inside QF implementation, but not in applications 73 | #ifdef QP_IMPL 74 | 75 | // scheduler locking, see NOTE2 76 | #define QF_SCHED_STAT_ 77 | #define QF_SCHED_LOCK_(dummy) do { \ 78 | if (!k_is_in_isr()) { \ 79 | k_sched_lock(); \ 80 | } \ 81 | } while (false) 82 | 83 | #define QF_SCHED_UNLOCK_() do { \ 84 | if (!k_is_in_isr()) { \ 85 | k_sched_unlock(); \ 86 | } \ 87 | } while (false) 88 | 89 | // native QF event pool customization 90 | #define QF_EPOOL_TYPE_ QMPool 91 | #define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \ 92 | (p_).init((poolSto_), (poolSize_), (evtSize_)) 93 | #define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize()) 94 | #define QF_EPOOL_GET_(p_, e_, m_, qsId_) \ 95 | ((e_) = static_cast((p_).get((m_), (qsId_)))) 96 | #define QF_EPOOL_PUT_(p_, e_, qsId_) ((p_).put((e_), (qsId_))) 97 | 98 | #endif // QP_IMPL 99 | 100 | //============================================================================ 101 | // NOTE1: 102 | // This QP port to Zephyr assumes that Active Objects will use only the 103 | // preemptive Zephyr priorities [0..(CONFIG_NUM_PREEMPT_PRIORITIES - 1U)]. 104 | // In this priority numbering, the QP AO priority QF_MAX_ACTIVE (highest) 105 | // maps to Zephyr priority 0 (highest). The QP AO priority 1 (lowest) maps 106 | // to Zephyr priority (CONFIG_NUM_PREEMPT_PRIORITIES - 2U). 107 | // 108 | // NOTE2: 109 | // Zephyr does not support selective scheduler locking up to a given 110 | // priority ceiling. Therefore, this port uses global Zephyr scheduler lock. 111 | // 112 | 113 | #endif // QP_PORT_HPP_ 114 | 115 | -------------------------------------------------------------------------------- /zephyr/qs_port.hpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // QP/C++ Real-Time Event Framework (RTEF) 3 | // 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 5 | // 6 | // Q u a n t u m L e a P s 7 | // ------------------------ 8 | // Modern Embedded Software 9 | // 10 | // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 11 | // 12 | // This software is dual-licensed under the terms of the open-source GNU 13 | // General Public License (GPL) or under the terms of one of the closed- 14 | // source Quantum Leaps commercial licenses. 15 | // 16 | // Redistributions in source code must retain this top-level comment block. 17 | // Plagiarizing this software to sidestep the license obligations is illegal. 18 | // 19 | // NOTE: 20 | // The GPL does NOT permit the incorporation of this code into proprietary 21 | // programs. Please contact Quantum Leaps for commercial licensing options, 22 | // which expressly supersede the GPL and are designed explicitly for 23 | // closed-source distribution. 24 | // 25 | // Quantum Leaps contact information: 26 | // 27 | // 28 | //============================================================================ 29 | #ifndef QS_PORT_HPP_ 30 | #define QS_PORT_HPP_ 31 | 32 | // QS time-stamp size in bytes 33 | #define QS_TIME_SIZE 4U 34 | 35 | // object pointer size in bytes 36 | #define QS_OBJ_PTR_SIZE 4U 37 | 38 | // function pointer size in bytes 39 | #define QS_FUN_PTR_SIZE 4U 40 | 41 | //============================================================================ 42 | // NOTE: QS might be used with or without other QP components, in which 43 | // case the separate definitions of the macros QF_CRIT_STAT, QF_CRIT_ENTRY(), 44 | // and QF_CRIT_EXIT() are needed. In this port QS is configured to be used 45 | // with the other QP component, by simply including "qp_port.h" 46 | //*before* "qs.h". 47 | #ifndef QP_PORT_H_ 48 | #include "qp_port.hpp" // use QS with QF 49 | #endif 50 | 51 | #include "qs.hpp" // QS platform-independent public interface 52 | 53 | #endif // QS_PORT_HPP_ 54 | 55 | --------------------------------------------------------------------------------