QP/C  8.0.3
Real-Time Event Framework
Loading...
Searching...
No Matches
qf_act.c
Go to the documentation of this file.
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// <www.state-machine.com/licensing>
27// <info@state-machine.com>
28//============================================================================
29#define QP_IMPL // this is QP implementation
30#include "qp_port.h" // QP port
31#include "qp_pkg.h" // 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.h" // QS port
35 #include "qs_pkg.h" // QS facilities for pre-defined trace records
36#else
37 #include "qs_dummy.h" // disable the QS software tracing
38#endif // Q_SPY
39
40//Q_DEFINE_THIS_MODULE("qf_act")
41
42// QP version string embedded in the binary image
43char const QP_versionStr[24] = "QP/C " QP_VERSION_STR;
44
46
47//! @static @private @memberof QActive
48QActive * QActive_registry_[QF_MAX_ACTIVE + 1U];
49
50//............................................................................
51//! @static @private @memberof QF
53 void * const start,
54 uint_fast16_t const len)
55{
56 uint8_t *ptr = (uint8_t *)start;
57 for (uint_fast16_t n = len; n > 0U; --n) {
58 *ptr = 0U;
59 ++ptr;
60 }
61}
62
63//............................................................................
64#ifndef QF_LOG2
65uint_fast8_t QF_LOG2(QPSetBits const bitmask) {
66 static uint8_t const log2LUT[16] = {
67 0U, 1U, 2U, 2U, 3U, 3U, 3U, 3U,
68 4U, 4U, 4U, 4U, 4U, 4U, 4U, 4U
69 };
70 uint_fast8_t n = 0U;
71 QPSetBits x = bitmask;
72 QPSetBits tmp;
73
74#if (QF_MAX_ACTIVE > 16U)
75 tmp = (x >> 16U);
76 if (tmp != 0U) {
77 n += 16U;
78 x = tmp;
79 }
80#endif
81#if (QF_MAX_ACTIVE > 8U)
82 tmp = (x >> 8U);
83 if (tmp != 0U) {
84 n += 8U;
85 x = tmp;
86 }
87#endif
88 tmp = (x >> 4U);
89 if (tmp != 0U) {
90 n += 4U;
91 x = tmp;
92 }
93 return n + log2LUT[x];
94}
95#endif // ndef QF_LOG2
void QF_bzero_(void *const start, uint_fast16_t const len)
Definition qf_act.c:52
QF_Attr QF_priv_
Definition qf_act.c:45
uint_fast8_t QF_LOG2(QPSetBits const bitmask)
Log-base-2 calculation when hardware acceleration is NOT provided (QF_LOG2 not defined)
Definition qf_act.c:65
#define QP_VERSION_STR
Version string complying with Semantic Versioning
Definition qp.h:33
uint32_t QPSetBits
Bitmask for the internal representation of QPSet elements.
Definition qp.h:397
char const QP_versionStr[24]
Definition qf_act.c:43
#define QF_MAX_ACTIVE
Maximum # Active Objects in the system (1..64)
Definition qp_config.h:123
Internal (package scope) QP/C interface.
Sample QP/C port.
QS/C dummy public interface.
Sample QS/C port.
QP Functional Safety (FuSa) Subsystem.
Active object class (based on the QHsm implementation strategy)
Definition qp.h:504
Private attributes of the QF framework.
Definition qp_pkg.h:37